]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.12-201305101711.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.12-201305101711.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..b47493f 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,6 +75,7 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 @@ -80,6 +87,7 @@ aic7*seq.h*
53 aicasm
54 aicdb.h*
55 altivec*.c
56 +ashldi3.S
57 asm-offsets.h
58 asm_offsets.h
59 autoconf.h*
60 @@ -92,19 +100,24 @@ bounds.h
61 bsetup
62 btfixupprep
63 build
64 +builtin-policy.h
65 bvmlinux
66 bzImage*
67 capability_names.h
68 capflags.c
69 classlist.h*
70 +clut_vga16.c
71 +common-cmds.h
72 comp*.log
73 compile.h*
74 conf
75 config
76 config-*
77 config_data.h*
78 +config.c
79 config.mak
80 config.mak.autogen
81 +config.tmp
82 conmakehash
83 consolemap_deftbl.c*
84 cpustr.h
85 @@ -115,9 +128,11 @@ devlist.h*
86 dnotify_test
87 docproc
88 dslm
89 +dtc-lexer.lex.c
90 elf2ecoff
91 elfconfig.h*
92 evergreen_reg_safe.h
93 +exception_policy.conf
94 fixdep
95 flask.h
96 fore200e_mkfirm
97 @@ -125,12 +140,15 @@ fore200e_pca_fw.c*
98 gconf
99 gconf.glade.h
100 gen-devlist
101 +gen-kdb_cmds.c
102 gen_crc32table
103 gen_init_cpio
104 generated
105 genheaders
106 genksyms
107 *_gray256.c
108 +hash
109 +hid-example
110 hpet_example
111 hugepage-mmap
112 hugepage-shm
113 @@ -145,14 +163,14 @@ int32.c
114 int4.c
115 int8.c
116 kallsyms
117 -kconfig
118 +kern_constants.h
119 keywords.c
120 ksym.c*
121 ksym.h*
122 kxgettext
123 lex.c
124 lex.*.c
125 -linux
126 +lib1funcs.S
127 logo_*.c
128 logo_*_clut224.c
129 logo_*_mono.c
130 @@ -162,14 +180,15 @@ mach-types.h
131 machtypes.h
132 map
133 map_hugetlb
134 -media
135 mconf
136 +mdp
137 miboot*
138 mk_elfconfig
139 mkboot
140 mkbugboot
141 mkcpustr
142 mkdep
143 +mkpiggy
144 mkprep
145 mkregtable
146 mktables
147 @@ -185,6 +204,8 @@ oui.c*
148 page-types
149 parse.c
150 parse.h
151 +parse-events*
152 +pasyms.h
153 patches*
154 pca200e.bin
155 pca200e_ecd.bin2
156 @@ -194,6 +215,7 @@ perf-archive
157 piggyback
158 piggy.gzip
159 piggy.S
160 +pmu-*
161 pnmtologo
162 ppc_defs.h*
163 pss_boot.h
164 @@ -203,7 +225,10 @@ r200_reg_safe.h
165 r300_reg_safe.h
166 r420_reg_safe.h
167 r600_reg_safe.h
168 +realmode.lds
169 +realmode.relocs
170 recordmcount
171 +regdb.c
172 relocs
173 rlim_names.h
174 rn50_reg_safe.h
175 @@ -213,8 +238,12 @@ series
176 setup
177 setup.bin
178 setup.elf
179 +signing_key*
180 +size_overflow_hash.h
181 sImage
182 +slabinfo
183 sm_tbl*
184 +sortextable
185 split-include
186 syscalltab.h
187 tables.c
188 @@ -224,6 +253,7 @@ tftpboot.img
189 timeconst.h
190 times.h*
191 trix_boot.h
192 +user_constants.h
193 utsrelease.h*
194 vdso-syms.lds
195 vdso.lds
196 @@ -235,13 +265,17 @@ vdso32.lds
197 vdso32.so.dbg
198 vdso64.lds
199 vdso64.so.dbg
200 +vdsox32.lds
201 +vdsox32-syms.lds
202 version.h*
203 vmImage
204 vmlinux
205 vmlinux-*
206 vmlinux.aout
207 vmlinux.bin.all
208 +vmlinux.bin.bz2
209 vmlinux.lds
210 +vmlinux.relocs
211 vmlinuz
212 voffset.h
213 vsyscall.lds
214 @@ -249,9 +283,12 @@ vsyscall_32.lds
215 wanxlfw.inc
216 uImage
217 unifdef
218 +utsrelease.h
219 wakeup.bin
220 wakeup.elf
221 wakeup.lds
222 +x509*
223 zImage*
224 zconf.hash.c
225 +zconf.lex.c
226 zoffset.h
227 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
228 index 986614d..e8bfedc 100644
229 --- a/Documentation/kernel-parameters.txt
230 +++ b/Documentation/kernel-parameters.txt
231 @@ -922,6 +922,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
232 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
233 Default: 1024
234
235 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
236 + ignore grsecurity's /proc restrictions
237 +
238 +
239 hashdist= [KNL,NUMA] Large hashes allocated during boot
240 are distributed across NUMA nodes. Defaults on
241 for 64-bit NUMA, off otherwise.
242 @@ -2121,6 +2125,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
243 the specified number of seconds. This is to be used if
244 your oopses keep scrolling off the screen.
245
246 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
247 + virtualization environments that don't cope well with the
248 + expand down segment used by UDEREF on X86-32 or the frequent
249 + page table updates on X86-64.
250 +
251 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
252 +
253 + pax_extra_latent_entropy
254 + Enable a very simple form of latent entropy extraction
255 + from the first 4GB of memory as the bootmem allocator
256 + passes the memory pages to the buddy allocator.
257 +
258 pcbit= [HW,ISDN]
259
260 pcd. [PARIDE]
261 diff --git a/Makefile b/Makefile
262 index 902974f..3a7c75c 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1563 index 6ddbe44..b5e38b1 100644
1564 --- a/arch/arm/include/asm/domain.h
1565 +++ b/arch/arm/include/asm/domain.h
1566 @@ -48,18 +48,37 @@
1567 * Domain types
1568 */
1569 #define DOMAIN_NOACCESS 0
1570 -#define DOMAIN_CLIENT 1
1571 #ifdef CONFIG_CPU_USE_DOMAINS
1572 +#define DOMAIN_USERCLIENT 1
1573 +#define DOMAIN_KERNELCLIENT 1
1574 #define DOMAIN_MANAGER 3
1575 +#define DOMAIN_VECTORS DOMAIN_USER
1576 #else
1577 +
1578 +#ifdef CONFIG_PAX_KERNEXEC
1579 #define DOMAIN_MANAGER 1
1580 +#define DOMAIN_KERNEXEC 3
1581 +#else
1582 +#define DOMAIN_MANAGER 1
1583 +#endif
1584 +
1585 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1586 +#define DOMAIN_USERCLIENT 0
1587 +#define DOMAIN_UDEREF 1
1588 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1589 +#else
1590 +#define DOMAIN_USERCLIENT 1
1591 +#define DOMAIN_VECTORS DOMAIN_USER
1592 +#endif
1593 +#define DOMAIN_KERNELCLIENT 1
1594 +
1595 #endif
1596
1597 #define domain_val(dom,type) ((type) << (2*(dom)))
1598
1599 #ifndef __ASSEMBLY__
1600
1601 -#ifdef CONFIG_CPU_USE_DOMAINS
1602 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1603 static inline void set_domain(unsigned val)
1604 {
1605 asm volatile(
1606 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1607 isb();
1608 }
1609
1610 -#define modify_domain(dom,type) \
1611 - do { \
1612 - struct thread_info *thread = current_thread_info(); \
1613 - unsigned int domain = thread->cpu_domain; \
1614 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1615 - thread->cpu_domain = domain | domain_val(dom, type); \
1616 - set_domain(thread->cpu_domain); \
1617 - } while (0)
1618 -
1619 +extern void modify_domain(unsigned int dom, unsigned int type);
1620 #else
1621 static inline void set_domain(unsigned val) { }
1622 static inline void modify_domain(unsigned dom, unsigned type) { }
1623 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1624 index 38050b1..9d90e8b 100644
1625 --- a/arch/arm/include/asm/elf.h
1626 +++ b/arch/arm/include/asm/elf.h
1627 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1628 the loader. We need to make sure that it is out of the way of the program
1629 that it will "exec", and that there is sufficient room for the brk. */
1630
1631 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1632 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1633 +
1634 +#ifdef CONFIG_PAX_ASLR
1635 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1636 +
1637 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1638 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1639 +#endif
1640
1641 /* When the program starts, a1 contains a pointer to a function to be
1642 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1643 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1644 extern void elf_set_personality(const struct elf32_hdr *);
1645 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1646
1647 -struct mm_struct;
1648 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1649 -#define arch_randomize_brk arch_randomize_brk
1650 -
1651 #endif
1652 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1653 index de53547..52b9a28 100644
1654 --- a/arch/arm/include/asm/fncpy.h
1655 +++ b/arch/arm/include/asm/fncpy.h
1656 @@ -81,7 +81,9 @@
1657 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1658 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1659 \
1660 + pax_open_kernel(); \
1661 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1662 + pax_close_kernel(); \
1663 flush_icache_range((unsigned long)(dest_buf), \
1664 (unsigned long)(dest_buf) + (size)); \
1665 \
1666 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1667 index e42cf59..7b94b8f 100644
1668 --- a/arch/arm/include/asm/futex.h
1669 +++ b/arch/arm/include/asm/futex.h
1670 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1671 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1672 return -EFAULT;
1673
1674 + pax_open_userland();
1675 +
1676 smp_mb();
1677 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1678 "1: ldrex %1, [%4]\n"
1679 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1680 : "cc", "memory");
1681 smp_mb();
1682
1683 + pax_close_userland();
1684 +
1685 *uval = val;
1686 return ret;
1687 }
1688 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1689 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1690 return -EFAULT;
1691
1692 + pax_open_userland();
1693 +
1694 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1695 "1: " TUSER(ldr) " %1, [%4]\n"
1696 " teq %1, %2\n"
1697 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1699 : "cc", "memory");
1700
1701 + pax_close_userland();
1702 +
1703 *uval = val;
1704 return ret;
1705 }
1706 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1707 return -EFAULT;
1708
1709 pagefault_disable(); /* implies preempt_disable() */
1710 + pax_open_userland();
1711
1712 switch (op) {
1713 case FUTEX_OP_SET:
1714 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1715 ret = -ENOSYS;
1716 }
1717
1718 + pax_close_userland();
1719 pagefault_enable(); /* subsumes preempt_enable() */
1720
1721 if (!ret) {
1722 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1723 index 4b1ce6c..bea3f73 100644
1724 --- a/arch/arm/include/asm/hardware/gic.h
1725 +++ b/arch/arm/include/asm/hardware/gic.h
1726 @@ -34,9 +34,10 @@
1727
1728 #ifndef __ASSEMBLY__
1729 #include <linux/irqdomain.h>
1730 +#include <linux/irq.h>
1731 struct device_node;
1732
1733 -extern struct irq_chip gic_arch_extn;
1734 +extern irq_chip_no_const gic_arch_extn;
1735
1736 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1737 u32 offset, struct device_node *);
1738 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1739 index 8c5e828..91b99ab 100644
1740 --- a/arch/arm/include/asm/highmem.h
1741 +++ b/arch/arm/include/asm/highmem.h
1742 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1743 #endif
1744 #endif
1745
1746 +/*
1747 + * Needed to be able to broadcast the TLB invalidation for kmap.
1748 + */
1749 +#ifdef CONFIG_ARM_ERRATA_798181
1750 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1751 +#endif
1752 +
1753 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1754 extern void *kmap_high_get(struct page *page);
1755 #else
1756 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1757 index 83eb2f7..ed77159 100644
1758 --- a/arch/arm/include/asm/kmap_types.h
1759 +++ b/arch/arm/include/asm/kmap_types.h
1760 @@ -4,6 +4,6 @@
1761 /*
1762 * This is the "bare minimum". AIO seems to require this.
1763 */
1764 -#define KM_TYPE_NR 16
1765 +#define KM_TYPE_NR 17
1766
1767 #endif
1768 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1769 index 9e614a1..3302cca 100644
1770 --- a/arch/arm/include/asm/mach/dma.h
1771 +++ b/arch/arm/include/asm/mach/dma.h
1772 @@ -22,7 +22,7 @@ struct dma_ops {
1773 int (*residue)(unsigned int, dma_t *); /* optional */
1774 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1775 const char *type;
1776 -};
1777 +} __do_const;
1778
1779 struct dma_struct {
1780 void *addr; /* single DMA address */
1781 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1782 index 2fe141f..192dc01 100644
1783 --- a/arch/arm/include/asm/mach/map.h
1784 +++ b/arch/arm/include/asm/mach/map.h
1785 @@ -27,13 +27,16 @@ struct map_desc {
1786 #define MT_MINICLEAN 6
1787 #define MT_LOW_VECTORS 7
1788 #define MT_HIGH_VECTORS 8
1789 -#define MT_MEMORY 9
1790 +#define MT_MEMORY_RWX 9
1791 #define MT_ROM 10
1792 -#define MT_MEMORY_NONCACHED 11
1793 +#define MT_MEMORY_NONCACHED_RX 11
1794 #define MT_MEMORY_DTCM 12
1795 #define MT_MEMORY_ITCM 13
1796 #define MT_MEMORY_SO 14
1797 #define MT_MEMORY_DMA_READY 15
1798 +#define MT_MEMORY_RW 16
1799 +#define MT_MEMORY_RX 17
1800 +#define MT_MEMORY_NONCACHED_RW 18
1801
1802 #ifdef CONFIG_MMU
1803 extern void iotable_init(struct map_desc *, int);
1804 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1805 index 863a661..a7b85e0 100644
1806 --- a/arch/arm/include/asm/mmu_context.h
1807 +++ b/arch/arm/include/asm/mmu_context.h
1808 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1809 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1810 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1811
1812 +DECLARE_PER_CPU(atomic64_t, active_asids);
1813 +
1814 #else /* !CONFIG_CPU_HAS_ASID */
1815
1816 #ifdef CONFIG_MMU
1817 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1818 index 53426c6..c7baff3 100644
1819 --- a/arch/arm/include/asm/outercache.h
1820 +++ b/arch/arm/include/asm/outercache.h
1821 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1822 #endif
1823 void (*set_debug)(unsigned long);
1824 void (*resume)(void);
1825 -};
1826 +} __no_const;
1827
1828 #ifdef CONFIG_OUTER_CACHE
1829
1830 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1831 index 812a494..71fc0b6 100644
1832 --- a/arch/arm/include/asm/page.h
1833 +++ b/arch/arm/include/asm/page.h
1834 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1835 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1836 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1837 unsigned long vaddr, struct vm_area_struct *vma);
1838 -};
1839 +} __no_const;
1840
1841 #ifdef MULTI_USER
1842 extern struct cpu_user_fns cpu_user;
1843 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1844 index 943504f..c37a730 100644
1845 --- a/arch/arm/include/asm/pgalloc.h
1846 +++ b/arch/arm/include/asm/pgalloc.h
1847 @@ -17,6 +17,7 @@
1848 #include <asm/processor.h>
1849 #include <asm/cacheflush.h>
1850 #include <asm/tlbflush.h>
1851 +#include <asm/system_info.h>
1852
1853 #define check_pgt_cache() do { } while (0)
1854
1855 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1856 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1857 }
1858
1859 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1860 +{
1861 + pud_populate(mm, pud, pmd);
1862 +}
1863 +
1864 #else /* !CONFIG_ARM_LPAE */
1865
1866 /*
1867 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1868 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1869 #define pmd_free(mm, pmd) do { } while (0)
1870 #define pud_populate(mm,pmd,pte) BUG()
1871 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1872
1873 #endif /* CONFIG_ARM_LPAE */
1874
1875 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1876 __free_page(pte);
1877 }
1878
1879 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1880 +{
1881 +#ifdef CONFIG_ARM_LPAE
1882 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1883 +#else
1884 + if (addr & SECTION_SIZE)
1885 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1886 + else
1887 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1888 +#endif
1889 + flush_pmd_entry(pmdp);
1890 +}
1891 +
1892 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1893 pmdval_t prot)
1894 {
1895 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1896 static inline void
1897 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1898 {
1899 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1900 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1901 }
1902 #define pmd_pgtable(pmd) pmd_page(pmd)
1903
1904 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1905 index 5cfba15..f415e1a 100644
1906 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1907 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1908 @@ -20,12 +20,15 @@
1909 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1910 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1911 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1912 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1913 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1914 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1915 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1916 +
1917 /*
1918 * - section
1919 */
1920 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1921 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1922 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1923 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1924 @@ -37,6 +40,7 @@
1925 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1926 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1927 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1928 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1929
1930 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1931 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1932 @@ -66,6 +70,7 @@
1933 * - extended small page/tiny page
1934 */
1935 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1936 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1937 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1938 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1939 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1940 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1941 index f97ee02..07f1be5 100644
1942 --- a/arch/arm/include/asm/pgtable-2level.h
1943 +++ b/arch/arm/include/asm/pgtable-2level.h
1944 @@ -125,6 +125,7 @@
1945 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1946 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1947 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1948 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1949
1950 /*
1951 * These are the memory types, defined to be compatible with
1952 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1953 index d795282..a43ea90 100644
1954 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1955 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1956 @@ -32,15 +32,18 @@
1957 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1958 #define PMD_BIT4 (_AT(pmdval_t, 0))
1959 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1960 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1961
1962 /*
1963 * - section
1964 */
1965 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1966 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1967 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1968 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1969 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1970 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1971 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1972 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
1973 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
1974 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
1975 @@ -66,6 +69,7 @@
1976 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1977 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1978 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1979 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1980 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1981
1982 /*
1983 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1984 index a3f3792..7b932a6 100644
1985 --- a/arch/arm/include/asm/pgtable-3level.h
1986 +++ b/arch/arm/include/asm/pgtable-3level.h
1987 @@ -74,6 +74,7 @@
1988 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1989 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1990 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1991 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1992 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1993 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1994 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1995 @@ -82,6 +83,7 @@
1996 /*
1997 * To be used in assembly code with the upper page attributes.
1998 */
1999 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2000 #define L_PTE_XN_HIGH (1 << (54 - 32))
2001 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2002
2003 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2004 index 26e9ce4..461ed7f 100644
2005 --- a/arch/arm/include/asm/pgtable.h
2006 +++ b/arch/arm/include/asm/pgtable.h
2007 @@ -30,6 +30,9 @@
2008 #include <asm/pgtable-2level.h>
2009 #endif
2010
2011 +#define ktla_ktva(addr) (addr)
2012 +#define ktva_ktla(addr) (addr)
2013 +
2014 /*
2015 * Just any arbitrary offset to the start of the vmalloc VM area: the
2016 * current 8MB value just means that there will be a 8MB "hole" after the
2017 @@ -45,6 +48,9 @@
2018 #define LIBRARY_TEXT_START 0x0c000000
2019
2020 #ifndef __ASSEMBLY__
2021 +extern pteval_t __supported_pte_mask;
2022 +extern pmdval_t __supported_pmd_mask;
2023 +
2024 extern void __pte_error(const char *file, int line, pte_t);
2025 extern void __pmd_error(const char *file, int line, pmd_t);
2026 extern void __pgd_error(const char *file, int line, pgd_t);
2027 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2028 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2029 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2030
2031 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2032 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2033 +
2034 +#ifdef CONFIG_PAX_KERNEXEC
2035 +#include <asm/domain.h>
2036 +#include <linux/thread_info.h>
2037 +#include <linux/preempt.h>
2038 +#endif
2039 +
2040 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2041 +static inline int test_domain(int domain, int domaintype)
2042 +{
2043 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2044 +}
2045 +#endif
2046 +
2047 +#ifdef CONFIG_PAX_KERNEXEC
2048 +static inline unsigned long pax_open_kernel(void) {
2049 +#ifdef CONFIG_ARM_LPAE
2050 + /* TODO */
2051 +#else
2052 + preempt_disable();
2053 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2054 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2055 +#endif
2056 + return 0;
2057 +}
2058 +
2059 +static inline unsigned long pax_close_kernel(void) {
2060 +#ifdef CONFIG_ARM_LPAE
2061 + /* TODO */
2062 +#else
2063 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2064 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2065 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2066 + preempt_enable_no_resched();
2067 +#endif
2068 + return 0;
2069 +}
2070 +#else
2071 +static inline unsigned long pax_open_kernel(void) { return 0; }
2072 +static inline unsigned long pax_close_kernel(void) { return 0; }
2073 +#endif
2074 +
2075 /*
2076 * This is the lowest virtual address we can permit any user space
2077 * mapping to be mapped at. This is particularly important for
2078 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2079 /*
2080 * The pgprot_* and protection_map entries will be fixed up in runtime
2081 * to include the cachable and bufferable bits based on memory policy,
2082 - * as well as any architecture dependent bits like global/ASID and SMP
2083 - * shared mapping bits.
2084 + * as well as any architecture dependent bits like global/ASID, PXN,
2085 + * and SMP shared mapping bits.
2086 */
2087 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2088
2089 @@ -250,7 +300,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2090 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2091 {
2092 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2093 - L_PTE_NONE | L_PTE_VALID;
2094 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2095 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2096 return pte;
2097 }
2098 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2099 index f3628fb..a0672dd 100644
2100 --- a/arch/arm/include/asm/proc-fns.h
2101 +++ b/arch/arm/include/asm/proc-fns.h
2102 @@ -75,7 +75,7 @@ extern struct processor {
2103 unsigned int suspend_size;
2104 void (*do_suspend)(void *);
2105 void (*do_resume)(void *);
2106 -} processor;
2107 +} __do_const processor;
2108
2109 #ifndef MULTI_CPU
2110 extern void cpu_proc_init(void);
2111 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2112 index 06e7d50..8a8e251 100644
2113 --- a/arch/arm/include/asm/processor.h
2114 +++ b/arch/arm/include/asm/processor.h
2115 @@ -65,9 +65,8 @@ struct thread_struct {
2116 regs->ARM_cpsr |= PSR_ENDSTATE; \
2117 regs->ARM_pc = pc & ~1; /* pc */ \
2118 regs->ARM_sp = sp; /* sp */ \
2119 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2120 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2121 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2122 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2123 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2124 nommu_start_thread(regs); \
2125 })
2126
2127 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2128 index d3a22be..3a69ad5 100644
2129 --- a/arch/arm/include/asm/smp.h
2130 +++ b/arch/arm/include/asm/smp.h
2131 @@ -107,7 +107,7 @@ struct smp_operations {
2132 int (*cpu_disable)(unsigned int cpu);
2133 #endif
2134 #endif
2135 -};
2136 +} __no_const;
2137
2138 /*
2139 * set platform specific SMP operations
2140 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2141 index cddda1f..ff357f7 100644
2142 --- a/arch/arm/include/asm/thread_info.h
2143 +++ b/arch/arm/include/asm/thread_info.h
2144 @@ -77,9 +77,9 @@ struct thread_info {
2145 .flags = 0, \
2146 .preempt_count = INIT_PREEMPT_COUNT, \
2147 .addr_limit = KERNEL_DS, \
2148 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2149 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2150 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2151 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2152 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2153 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2154 .restart_block = { \
2155 .fn = do_no_restart_syscall, \
2156 }, \
2157 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2158 #define TIF_SYSCALL_AUDIT 9
2159 #define TIF_SYSCALL_TRACEPOINT 10
2160 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2161 +
2162 +/* within 8 bits of TIF_SYSCALL_TRACE
2163 + * to meet flexible second operand requirements
2164 + */
2165 +#define TIF_GRSEC_SETXID 12
2166 +
2167 #define TIF_USING_IWMMXT 17
2168 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2169 #define TIF_RESTORE_SIGMASK 20
2170 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2171 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2172 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2173 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2174 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2175
2176 /* Checks for any syscall work in entry-common.S */
2177 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2178 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2179 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2180
2181 /*
2182 * Change these and you break ASM code in entry-common.S
2183 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2184 index 6e924d3..a9f3ddf 100644
2185 --- a/arch/arm/include/asm/tlbflush.h
2186 +++ b/arch/arm/include/asm/tlbflush.h
2187 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2188 }
2189 }
2190
2191 +#ifdef CONFIG_ARM_ERRATA_798181
2192 +static inline void dummy_flush_tlb_a15_erratum(void)
2193 +{
2194 + /*
2195 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2196 + */
2197 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2198 + dsb();
2199 +}
2200 +#else
2201 +static inline void dummy_flush_tlb_a15_erratum(void)
2202 +{
2203 +}
2204 +#endif
2205 +
2206 /*
2207 * flush_pmd_entry
2208 *
2209 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2210 index 7e1f760..752fcb7 100644
2211 --- a/arch/arm/include/asm/uaccess.h
2212 +++ b/arch/arm/include/asm/uaccess.h
2213 @@ -18,6 +18,7 @@
2214 #include <asm/domain.h>
2215 #include <asm/unified.h>
2216 #include <asm/compiler.h>
2217 +#include <asm/pgtable.h>
2218
2219 #define VERIFY_READ 0
2220 #define VERIFY_WRITE 1
2221 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2222 #define USER_DS TASK_SIZE
2223 #define get_fs() (current_thread_info()->addr_limit)
2224
2225 +static inline void pax_open_userland(void)
2226 +{
2227 +
2228 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2229 + if (get_fs() == USER_DS) {
2230 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2231 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2232 + }
2233 +#endif
2234 +
2235 +}
2236 +
2237 +static inline void pax_close_userland(void)
2238 +{
2239 +
2240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2241 + if (get_fs() == USER_DS) {
2242 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2243 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2244 + }
2245 +#endif
2246 +
2247 +}
2248 +
2249 static inline void set_fs(mm_segment_t fs)
2250 {
2251 current_thread_info()->addr_limit = fs;
2252 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2253 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2254 }
2255
2256 #define segment_eq(a,b) ((a) == (b))
2257 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2258
2259 #define get_user(x,p) \
2260 ({ \
2261 + int __e; \
2262 might_fault(); \
2263 - __get_user_check(x,p); \
2264 + pax_open_userland(); \
2265 + __e = __get_user_check(x,p); \
2266 + pax_close_userland(); \
2267 + __e; \
2268 })
2269
2270 extern int __put_user_1(void *, unsigned int);
2271 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2272
2273 #define put_user(x,p) \
2274 ({ \
2275 + int __e; \
2276 might_fault(); \
2277 - __put_user_check(x,p); \
2278 + pax_open_userland(); \
2279 + __e = __put_user_check(x,p); \
2280 + pax_close_userland(); \
2281 + __e; \
2282 })
2283
2284 #else /* CONFIG_MMU */
2285 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2286 #define __get_user(x,ptr) \
2287 ({ \
2288 long __gu_err = 0; \
2289 + pax_open_userland(); \
2290 __get_user_err((x),(ptr),__gu_err); \
2291 + pax_close_userland(); \
2292 __gu_err; \
2293 })
2294
2295 #define __get_user_error(x,ptr,err) \
2296 ({ \
2297 + pax_open_userland(); \
2298 __get_user_err((x),(ptr),err); \
2299 + pax_close_userland(); \
2300 (void) 0; \
2301 })
2302
2303 @@ -312,13 +349,17 @@ do { \
2304 #define __put_user(x,ptr) \
2305 ({ \
2306 long __pu_err = 0; \
2307 + pax_open_userland(); \
2308 __put_user_err((x),(ptr),__pu_err); \
2309 + pax_close_userland(); \
2310 __pu_err; \
2311 })
2312
2313 #define __put_user_error(x,ptr,err) \
2314 ({ \
2315 + pax_open_userland(); \
2316 __put_user_err((x),(ptr),err); \
2317 + pax_close_userland(); \
2318 (void) 0; \
2319 })
2320
2321 @@ -418,11 +459,44 @@ do { \
2322
2323
2324 #ifdef CONFIG_MMU
2325 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2326 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2327 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2328 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2329 +
2330 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2331 +{
2332 + unsigned long ret;
2333 +
2334 + check_object_size(to, n, false);
2335 + pax_open_userland();
2336 + ret = ___copy_from_user(to, from, n);
2337 + pax_close_userland();
2338 + return ret;
2339 +}
2340 +
2341 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2342 +{
2343 + unsigned long ret;
2344 +
2345 + check_object_size(from, n, true);
2346 + pax_open_userland();
2347 + ret = ___copy_to_user(to, from, n);
2348 + pax_close_userland();
2349 + return ret;
2350 +}
2351 +
2352 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2353 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2354 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2355 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 + pax_open_userland();
2361 + ret = ___clear_user(addr, n);
2362 + pax_close_userland();
2363 + return ret;
2364 +}
2365 +
2366 #else
2367 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2368 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2369 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2370
2371 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2372 {
2373 + if ((long)n < 0)
2374 + return n;
2375 +
2376 if (access_ok(VERIFY_READ, from, n))
2377 n = __copy_from_user(to, from, n);
2378 else /* security hole - plug it */
2379 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2380
2381 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2382 {
2383 + if ((long)n < 0)
2384 + return n;
2385 +
2386 if (access_ok(VERIFY_WRITE, to, n))
2387 n = __copy_to_user(to, from, n);
2388 return n;
2389 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2390 index 96ee092..37f1844 100644
2391 --- a/arch/arm/include/uapi/asm/ptrace.h
2392 +++ b/arch/arm/include/uapi/asm/ptrace.h
2393 @@ -73,7 +73,7 @@
2394 * ARMv7 groups of PSR bits
2395 */
2396 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2397 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2398 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2399 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2400 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2401
2402 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2403 index 60d3b73..d27ee09 100644
2404 --- a/arch/arm/kernel/armksyms.c
2405 +++ b/arch/arm/kernel/armksyms.c
2406 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2407 #ifdef CONFIG_MMU
2408 EXPORT_SYMBOL(copy_page);
2409
2410 -EXPORT_SYMBOL(__copy_from_user);
2411 -EXPORT_SYMBOL(__copy_to_user);
2412 -EXPORT_SYMBOL(__clear_user);
2413 +EXPORT_SYMBOL(___copy_from_user);
2414 +EXPORT_SYMBOL(___copy_to_user);
2415 +EXPORT_SYMBOL(___clear_user);
2416
2417 EXPORT_SYMBOL(__get_user_1);
2418 EXPORT_SYMBOL(__get_user_2);
2419 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2420 index 0f82098..3dbd3ee 100644
2421 --- a/arch/arm/kernel/entry-armv.S
2422 +++ b/arch/arm/kernel/entry-armv.S
2423 @@ -47,6 +47,87 @@
2424 9997:
2425 .endm
2426
2427 + .macro pax_enter_kernel
2428 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2429 + @ make aligned space for saved DACR
2430 + sub sp, sp, #8
2431 + @ save regs
2432 + stmdb sp!, {r1, r2}
2433 + @ read DACR from cpu_domain into r1
2434 + mov r2, sp
2435 + @ assume 8K pages, since we have to split the immediate in two
2436 + bic r2, r2, #(0x1fc0)
2437 + bic r2, r2, #(0x3f)
2438 + ldr r1, [r2, #TI_CPU_DOMAIN]
2439 + @ store old DACR on stack
2440 + str r1, [sp, #8]
2441 +#ifdef CONFIG_PAX_KERNEXEC
2442 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2443 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2444 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2445 +#endif
2446 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2447 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2448 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2449 +#endif
2450 + @ write r1 to current_thread_info()->cpu_domain
2451 + str r1, [r2, #TI_CPU_DOMAIN]
2452 + @ write r1 to DACR
2453 + mcr p15, 0, r1, c3, c0, 0
2454 + @ instruction sync
2455 + instr_sync
2456 + @ restore regs
2457 + ldmia sp!, {r1, r2}
2458 +#endif
2459 + .endm
2460 +
2461 + .macro pax_open_userland
2462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2463 + @ save regs
2464 + stmdb sp!, {r0, r1}
2465 + @ read DACR from cpu_domain into r1
2466 + mov r0, sp
2467 + @ assume 8K pages, since we have to split the immediate in two
2468 + bic r0, r0, #(0x1fc0)
2469 + bic r0, r0, #(0x3f)
2470 + ldr r1, [r0, #TI_CPU_DOMAIN]
2471 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2472 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2473 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2474 + @ write r1 to current_thread_info()->cpu_domain
2475 + str r1, [r0, #TI_CPU_DOMAIN]
2476 + @ write r1 to DACR
2477 + mcr p15, 0, r1, c3, c0, 0
2478 + @ instruction sync
2479 + instr_sync
2480 + @ restore regs
2481 + ldmia sp!, {r0, r1}
2482 +#endif
2483 + .endm
2484 +
2485 + .macro pax_close_userland
2486 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2487 + @ save regs
2488 + stmdb sp!, {r0, r1}
2489 + @ read DACR from cpu_domain into r1
2490 + mov r0, sp
2491 + @ assume 8K pages, since we have to split the immediate in two
2492 + bic r0, r0, #(0x1fc0)
2493 + bic r0, r0, #(0x3f)
2494 + ldr r1, [r0, #TI_CPU_DOMAIN]
2495 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2496 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2497 + @ write r1 to current_thread_info()->cpu_domain
2498 + str r1, [r0, #TI_CPU_DOMAIN]
2499 + @ write r1 to DACR
2500 + mcr p15, 0, r1, c3, c0, 0
2501 + @ instruction sync
2502 + instr_sync
2503 + @ restore regs
2504 + ldmia sp!, {r0, r1}
2505 +#endif
2506 + .endm
2507 +
2508 .macro pabt_helper
2509 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2510 #ifdef MULTI_PABORT
2511 @@ -89,11 +170,15 @@
2512 * Invalid mode handlers
2513 */
2514 .macro inv_entry, reason
2515 +
2516 + pax_enter_kernel
2517 +
2518 sub sp, sp, #S_FRAME_SIZE
2519 ARM( stmib sp, {r1 - lr} )
2520 THUMB( stmia sp, {r0 - r12} )
2521 THUMB( str sp, [sp, #S_SP] )
2522 THUMB( str lr, [sp, #S_LR] )
2523 +
2524 mov r1, #\reason
2525 .endm
2526
2527 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2528 .macro svc_entry, stack_hole=0
2529 UNWIND(.fnstart )
2530 UNWIND(.save {r0 - pc} )
2531 +
2532 + pax_enter_kernel
2533 +
2534 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2535 +
2536 #ifdef CONFIG_THUMB2_KERNEL
2537 SPFIX( str r0, [sp] ) @ temporarily saved
2538 SPFIX( mov r0, sp )
2539 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2540 ldmia r0, {r3 - r5}
2541 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2542 mov r6, #-1 @ "" "" "" ""
2543 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 + @ offset sp by 8 as done in pax_enter_kernel
2545 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2546 +#else
2547 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2548 +#endif
2549 SPFIX( addeq r2, r2, #4 )
2550 str r3, [sp, #-4]! @ save the "real" r0 copied
2551 @ from the exception stack
2552 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2553 .macro usr_entry
2554 UNWIND(.fnstart )
2555 UNWIND(.cantunwind ) @ don't unwind the user space
2556 +
2557 + pax_enter_kernel_user
2558 +
2559 sub sp, sp, #S_FRAME_SIZE
2560 ARM( stmib sp, {r1 - r12} )
2561 THUMB( stmia sp, {r0 - r12} )
2562 @@ -456,7 +553,9 @@ __und_usr:
2563 tst r3, #PSR_T_BIT @ Thumb mode?
2564 bne __und_usr_thumb
2565 sub r4, r2, #4 @ ARM instr at LR - 4
2566 + pax_open_userland
2567 1: ldrt r0, [r4]
2568 + pax_close_userland
2569 #ifdef CONFIG_CPU_ENDIAN_BE8
2570 rev r0, r0 @ little endian instruction
2571 #endif
2572 @@ -491,10 +590,14 @@ __und_usr_thumb:
2573 */
2574 .arch armv6t2
2575 #endif
2576 + pax_open_userland
2577 2: ldrht r5, [r4]
2578 + pax_close_userland
2579 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2580 blo __und_usr_fault_16 @ 16bit undefined instruction
2581 + pax_open_userland
2582 3: ldrht r0, [r2]
2583 + pax_close_userland
2584 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2585 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2586 orr r0, r0, r5, lsl #16
2587 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2588 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2589 THUMB( str sp, [ip], #4 )
2590 THUMB( str lr, [ip], #4 )
2591 -#ifdef CONFIG_CPU_USE_DOMAINS
2592 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2593 ldr r6, [r2, #TI_CPU_DOMAIN]
2594 #endif
2595 set_tls r3, r4, r5
2596 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2597 ldr r8, =__stack_chk_guard
2598 ldr r7, [r7, #TSK_STACK_CANARY]
2599 #endif
2600 -#ifdef CONFIG_CPU_USE_DOMAINS
2601 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2602 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2603 #endif
2604 mov r5, r0
2605 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2606 index a6c301e..908821b 100644
2607 --- a/arch/arm/kernel/entry-common.S
2608 +++ b/arch/arm/kernel/entry-common.S
2609 @@ -10,18 +10,46 @@
2610
2611 #include <asm/unistd.h>
2612 #include <asm/ftrace.h>
2613 +#include <asm/domain.h>
2614 #include <asm/unwind.h>
2615
2616 +#include "entry-header.S"
2617 +
2618 #ifdef CONFIG_NEED_RET_TO_USER
2619 #include <mach/entry-macro.S>
2620 #else
2621 .macro arch_ret_to_user, tmp1, tmp2
2622 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2623 + @ save regs
2624 + stmdb sp!, {r1, r2}
2625 + @ read DACR from cpu_domain into r1
2626 + mov r2, sp
2627 + @ assume 8K pages, since we have to split the immediate in two
2628 + bic r2, r2, #(0x1fc0)
2629 + bic r2, r2, #(0x3f)
2630 + ldr r1, [r2, #TI_CPU_DOMAIN]
2631 +#ifdef CONFIG_PAX_KERNEXEC
2632 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2633 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2634 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2635 +#endif
2636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2637 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2638 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2639 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2640 +#endif
2641 + @ write r1 to current_thread_info()->cpu_domain
2642 + str r1, [r2, #TI_CPU_DOMAIN]
2643 + @ write r1 to DACR
2644 + mcr p15, 0, r1, c3, c0, 0
2645 + @ instruction sync
2646 + instr_sync
2647 + @ restore regs
2648 + ldmia sp!, {r1, r2}
2649 +#endif
2650 .endm
2651 #endif
2652
2653 -#include "entry-header.S"
2654 -
2655 -
2656 .align 5
2657 /*
2658 * This is the fast syscall return path. We do as little as
2659 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2660
2661 .align 5
2662 ENTRY(vector_swi)
2663 +
2664 sub sp, sp, #S_FRAME_SIZE
2665 stmia sp, {r0 - r12} @ Calling r0 - r12
2666 ARM( add r8, sp, #S_PC )
2667 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2668 ldr scno, [lr, #-4] @ get SWI instruction
2669 #endif
2670
2671 + /*
2672 + * do this here to avoid a performance hit of wrapping the code above
2673 + * that directly dereferences userland to parse the SWI instruction
2674 + */
2675 + pax_enter_kernel_user
2676 +
2677 #ifdef CONFIG_ALIGNMENT_TRAP
2678 ldr ip, __cr_alignment
2679 ldr ip, [ip]
2680 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2681 index 9a8531e..812e287 100644
2682 --- a/arch/arm/kernel/entry-header.S
2683 +++ b/arch/arm/kernel/entry-header.S
2684 @@ -73,9 +73,66 @@
2685 msr cpsr_c, \rtemp @ switch back to the SVC mode
2686 .endm
2687
2688 + .macro pax_enter_kernel_user
2689 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2690 + @ save regs
2691 + stmdb sp!, {r0, r1}
2692 + @ read DACR from cpu_domain into r1
2693 + mov r0, sp
2694 + @ assume 8K pages, since we have to split the immediate in two
2695 + bic r0, r0, #(0x1fc0)
2696 + bic r0, r0, #(0x3f)
2697 + ldr r1, [r0, #TI_CPU_DOMAIN]
2698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2699 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2700 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2701 +#endif
2702 +#ifdef CONFIG_PAX_KERNEXEC
2703 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2704 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2705 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2706 +#endif
2707 + @ write r1 to current_thread_info()->cpu_domain
2708 + str r1, [r0, #TI_CPU_DOMAIN]
2709 + @ write r1 to DACR
2710 + mcr p15, 0, r1, c3, c0, 0
2711 + @ instruction sync
2712 + instr_sync
2713 + @ restore regs
2714 + ldmia sp!, {r0, r1}
2715 +#endif
2716 + .endm
2717 +
2718 + .macro pax_exit_kernel
2719 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2720 + @ save regs
2721 + stmdb sp!, {r0, r1}
2722 + @ read old DACR from stack into r1
2723 + ldr r1, [sp, #(8 + S_SP)]
2724 + sub r1, r1, #8
2725 + ldr r1, [r1]
2726 +
2727 + @ write r1 to current_thread_info()->cpu_domain
2728 + mov r0, sp
2729 + @ assume 8K pages, since we have to split the immediate in two
2730 + bic r0, r0, #(0x1fc0)
2731 + bic r0, r0, #(0x3f)
2732 + str r1, [r0, #TI_CPU_DOMAIN]
2733 + @ write r1 to DACR
2734 + mcr p15, 0, r1, c3, c0, 0
2735 + @ instruction sync
2736 + instr_sync
2737 + @ restore regs
2738 + ldmia sp!, {r0, r1}
2739 +#endif
2740 + .endm
2741 +
2742 #ifndef CONFIG_THUMB2_KERNEL
2743 .macro svc_exit, rpsr
2744 msr spsr_cxsf, \rpsr
2745 +
2746 + pax_exit_kernel
2747 +
2748 #if defined(CONFIG_CPU_V6)
2749 ldr r0, [sp]
2750 strex r1, r2, [sp] @ clear the exclusive monitor
2751 @@ -121,6 +178,9 @@
2752 .endm
2753 #else /* CONFIG_THUMB2_KERNEL */
2754 .macro svc_exit, rpsr
2755 +
2756 + pax_exit_kernel
2757 +
2758 ldr lr, [sp, #S_SP] @ top of the stack
2759 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2760 clrex @ clear the exclusive monitor
2761 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2762 index 2adda11..7fbe958 100644
2763 --- a/arch/arm/kernel/fiq.c
2764 +++ b/arch/arm/kernel/fiq.c
2765 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2766 #if defined(CONFIG_CPU_USE_DOMAINS)
2767 memcpy((void *)0xffff001c, start, length);
2768 #else
2769 + pax_open_kernel();
2770 memcpy(vectors_page + 0x1c, start, length);
2771 + pax_close_kernel();
2772 #endif
2773 flush_icache_range(0xffff001c, 0xffff001c + length);
2774 if (!vectors_high())
2775 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2776 index e0eb9a1..caee108 100644
2777 --- a/arch/arm/kernel/head.S
2778 +++ b/arch/arm/kernel/head.S
2779 @@ -52,7 +52,9 @@
2780 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2781
2782 .macro pgtbl, rd, phys
2783 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2784 + mov \rd, #TEXT_OFFSET
2785 + sub \rd, #PG_DIR_SIZE
2786 + add \rd, \rd, \phys
2787 .endm
2788
2789 /*
2790 @@ -267,7 +269,7 @@ __create_page_tables:
2791 addne r6, r6, #1 << SECTION_SHIFT
2792 strne r6, [r3]
2793
2794 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2795 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2796 sub r4, r4, #4 @ Fixup page table pointer
2797 @ for 64-bit descriptors
2798 #endif
2799 @@ -434,7 +436,7 @@ __enable_mmu:
2800 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2801 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2802 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2803 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2804 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2805 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2806 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2807 #endif
2808 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2809 index 5ff2e77..556d030 100644
2810 --- a/arch/arm/kernel/hw_breakpoint.c
2811 +++ b/arch/arm/kernel/hw_breakpoint.c
2812 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2813 return NOTIFY_OK;
2814 }
2815
2816 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2817 +static struct notifier_block dbg_reset_nb = {
2818 .notifier_call = dbg_reset_notify,
2819 };
2820
2821 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2822 index 1e9be5d..03edbc2 100644
2823 --- a/arch/arm/kernel/module.c
2824 +++ b/arch/arm/kernel/module.c
2825 @@ -37,12 +37,37 @@
2826 #endif
2827
2828 #ifdef CONFIG_MMU
2829 -void *module_alloc(unsigned long size)
2830 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2831 {
2832 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2833 + return NULL;
2834 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2835 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2836 + GFP_KERNEL, prot, -1,
2837 __builtin_return_address(0));
2838 }
2839 +
2840 +void *module_alloc(unsigned long size)
2841 +{
2842 +
2843 +#ifdef CONFIG_PAX_KERNEXEC
2844 + return __module_alloc(size, PAGE_KERNEL);
2845 +#else
2846 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2847 +#endif
2848 +
2849 +}
2850 +
2851 +#ifdef CONFIG_PAX_KERNEXEC
2852 +void module_free_exec(struct module *mod, void *module_region)
2853 +{
2854 + module_free(mod, module_region);
2855 +}
2856 +
2857 +void *module_alloc_exec(unsigned long size)
2858 +{
2859 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2860 +}
2861 +#endif
2862 #endif
2863
2864 int
2865 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2866 index 07314af..c46655c 100644
2867 --- a/arch/arm/kernel/patch.c
2868 +++ b/arch/arm/kernel/patch.c
2869 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2870 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2871 int size;
2872
2873 + pax_open_kernel();
2874 if (thumb2 && __opcode_is_thumb16(insn)) {
2875 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2876 size = sizeof(u16);
2877 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2878 *(u32 *)addr = insn;
2879 size = sizeof(u32);
2880 }
2881 + pax_close_kernel();
2882
2883 flush_icache_range((uintptr_t)(addr),
2884 (uintptr_t)(addr) + size);
2885 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2886 index 5f66206..dce492f 100644
2887 --- a/arch/arm/kernel/perf_event_cpu.c
2888 +++ b/arch/arm/kernel/perf_event_cpu.c
2889 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2890 return NOTIFY_OK;
2891 }
2892
2893 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2894 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2895 .notifier_call = cpu_pmu_notify,
2896 };
2897
2898 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2899 index c6dec5f..e0fddd1 100644
2900 --- a/arch/arm/kernel/process.c
2901 +++ b/arch/arm/kernel/process.c
2902 @@ -28,7 +28,6 @@
2903 #include <linux/tick.h>
2904 #include <linux/utsname.h>
2905 #include <linux/uaccess.h>
2906 -#include <linux/random.h>
2907 #include <linux/hw_breakpoint.h>
2908 #include <linux/cpuidle.h>
2909 #include <linux/leds.h>
2910 @@ -256,9 +255,10 @@ void machine_power_off(void)
2911 machine_shutdown();
2912 if (pm_power_off)
2913 pm_power_off();
2914 + BUG();
2915 }
2916
2917 -void machine_restart(char *cmd)
2918 +__noreturn void machine_restart(char *cmd)
2919 {
2920 machine_shutdown();
2921
2922 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2923 init_utsname()->release,
2924 (int)strcspn(init_utsname()->version, " "),
2925 init_utsname()->version);
2926 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2927 - print_symbol("LR is at %s\n", regs->ARM_lr);
2928 + printk("PC is at %pA\n", instruction_pointer(regs));
2929 + printk("LR is at %pA\n", regs->ARM_lr);
2930 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2931 "sp : %08lx ip : %08lx fp : %08lx\n",
2932 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2933 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2934 return 0;
2935 }
2936
2937 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2938 -{
2939 - unsigned long range_end = mm->brk + 0x02000000;
2940 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2941 -}
2942 -
2943 #ifdef CONFIG_MMU
2944 /*
2945 * The vectors page is always readable from user space for the
2946 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2947 {
2948 gate_vma.vm_start = 0xffff0000;
2949 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2950 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2951 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2952 - VM_MAYREAD | VM_MAYEXEC;
2953 + gate_vma.vm_flags = VM_NONE;
2954 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2955 return 0;
2956 }
2957 arch_initcall(gate_vma_init);
2958 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2959 index 03deeff..741ce88 100644
2960 --- a/arch/arm/kernel/ptrace.c
2961 +++ b/arch/arm/kernel/ptrace.c
2962 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2963 return current_thread_info()->syscall;
2964 }
2965
2966 +#ifdef CONFIG_GRKERNSEC_SETXID
2967 +extern void gr_delayed_cred_worker(void);
2968 +#endif
2969 +
2970 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2971 {
2972 current_thread_info()->syscall = scno;
2973
2974 +#ifdef CONFIG_GRKERNSEC_SETXID
2975 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2976 + gr_delayed_cred_worker();
2977 +#endif
2978 +
2979 /* Do the secure computing check first; failures should be fast. */
2980 if (secure_computing(scno) == -1)
2981 return -1;
2982 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2983 index 3f6cbb2..39305c7 100644
2984 --- a/arch/arm/kernel/setup.c
2985 +++ b/arch/arm/kernel/setup.c
2986 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2987 unsigned int elf_hwcap __read_mostly;
2988 EXPORT_SYMBOL(elf_hwcap);
2989
2990 +pteval_t __supported_pte_mask __read_only;
2991 +pmdval_t __supported_pmd_mask __read_only;
2992
2993 #ifdef MULTI_CPU
2994 -struct processor processor __read_mostly;
2995 +struct processor processor;
2996 #endif
2997 #ifdef MULTI_TLB
2998 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2999 +struct cpu_tlb_fns cpu_tlb __read_only;
3000 #endif
3001 #ifdef MULTI_USER
3002 -struct cpu_user_fns cpu_user __read_mostly;
3003 +struct cpu_user_fns cpu_user __read_only;
3004 #endif
3005 #ifdef MULTI_CACHE
3006 -struct cpu_cache_fns cpu_cache __read_mostly;
3007 +struct cpu_cache_fns cpu_cache __read_only;
3008 #endif
3009 #ifdef CONFIG_OUTER_CACHE
3010 -struct outer_cache_fns outer_cache __read_mostly;
3011 +struct outer_cache_fns outer_cache __read_only;
3012 EXPORT_SYMBOL(outer_cache);
3013 #endif
3014
3015 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3016 asm("mrc p15, 0, %0, c0, c1, 4"
3017 : "=r" (mmfr0));
3018 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3019 - (mmfr0 & 0x000000f0) >= 0x00000030)
3020 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3021 cpu_arch = CPU_ARCH_ARMv7;
3022 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3023 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3024 + __supported_pte_mask |= L_PTE_PXN;
3025 + __supported_pmd_mask |= PMD_PXNTABLE;
3026 + }
3027 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3028 (mmfr0 & 0x000000f0) == 0x00000020)
3029 cpu_arch = CPU_ARCH_ARMv6;
3030 else
3031 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3032 __cpu_architecture = __get_cpu_architecture();
3033
3034 #ifdef MULTI_CPU
3035 - processor = *list->proc;
3036 + memcpy((void *)&processor, list->proc, sizeof processor);
3037 #endif
3038 #ifdef MULTI_TLB
3039 cpu_tlb = *list->tlb;
3040 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3041 size -= start & ~PAGE_MASK;
3042 bank->start = PAGE_ALIGN(start);
3043
3044 -#ifndef CONFIG_LPAE
3045 +#ifndef CONFIG_ARM_LPAE
3046 if (bank->start + size < bank->start) {
3047 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3048 "32-bit physical address space\n", (long long)start);
3049 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3050 index 56f72d2..6924200 100644
3051 --- a/arch/arm/kernel/signal.c
3052 +++ b/arch/arm/kernel/signal.c
3053 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3054 __put_user(sigreturn_codes[idx+1], rc+1))
3055 return 1;
3056
3057 - if (cpsr & MODE32_BIT) {
3058 - /*
3059 - * 32-bit code can use the new high-page
3060 - * signal return code support.
3061 - */
3062 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3063 - } else {
3064 - /*
3065 - * Ensure that the instruction cache sees
3066 - * the return code written onto the stack.
3067 - */
3068 - flush_icache_range((unsigned long)rc,
3069 - (unsigned long)(rc + 2));
3070 + /*
3071 + * Ensure that the instruction cache sees
3072 + * the return code written onto the stack.
3073 + */
3074 + flush_icache_range((unsigned long)rc,
3075 + (unsigned long)(rc + 2));
3076
3077 - retcode = ((unsigned long)rc) + thumb;
3078 - }
3079 + retcode = ((unsigned long)rc) + thumb;
3080 }
3081
3082 regs->ARM_r0 = usig;
3083 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3084 index 58af91c..343ce99 100644
3085 --- a/arch/arm/kernel/smp.c
3086 +++ b/arch/arm/kernel/smp.c
3087 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3088
3089 static DECLARE_COMPLETION(cpu_running);
3090
3091 -static struct smp_operations smp_ops;
3092 +static struct smp_operations smp_ops __read_only;
3093
3094 void __init smp_set_ops(struct smp_operations *ops)
3095 {
3096 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3097 index 02c5d2c..e5695ad 100644
3098 --- a/arch/arm/kernel/smp_tlb.c
3099 +++ b/arch/arm/kernel/smp_tlb.c
3100 @@ -12,6 +12,7 @@
3101
3102 #include <asm/smp_plat.h>
3103 #include <asm/tlbflush.h>
3104 +#include <asm/mmu_context.h>
3105
3106 /**********************************************************************/
3107
3108 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3109 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3110 }
3111
3112 +#ifdef CONFIG_ARM_ERRATA_798181
3113 +static int erratum_a15_798181(void)
3114 +{
3115 + unsigned int midr = read_cpuid_id();
3116 +
3117 + /* Cortex-A15 r0p0..r3p2 affected */
3118 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3119 + return 0;
3120 + return 1;
3121 +}
3122 +#else
3123 +static int erratum_a15_798181(void)
3124 +{
3125 + return 0;
3126 +}
3127 +#endif
3128 +
3129 +static void ipi_flush_tlb_a15_erratum(void *arg)
3130 +{
3131 + dmb();
3132 +}
3133 +
3134 +static void broadcast_tlb_a15_erratum(void)
3135 +{
3136 + if (!erratum_a15_798181())
3137 + return;
3138 +
3139 + dummy_flush_tlb_a15_erratum();
3140 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3141 + NULL, 1);
3142 +}
3143 +
3144 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3145 +{
3146 + int cpu;
3147 + cpumask_t mask = { CPU_BITS_NONE };
3148 +
3149 + if (!erratum_a15_798181())
3150 + return;
3151 +
3152 + dummy_flush_tlb_a15_erratum();
3153 + for_each_online_cpu(cpu) {
3154 + if (cpu == smp_processor_id())
3155 + continue;
3156 + /*
3157 + * We only need to send an IPI if the other CPUs are running
3158 + * the same ASID as the one being invalidated. There is no
3159 + * need for locking around the active_asids check since the
3160 + * switch_mm() function has at least one dmb() (as required by
3161 + * this workaround) in case a context switch happens on
3162 + * another CPU after the condition below.
3163 + */
3164 + if (atomic64_read(&mm->context.id) ==
3165 + atomic64_read(&per_cpu(active_asids, cpu)))
3166 + cpumask_set_cpu(cpu, &mask);
3167 + }
3168 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3169 +}
3170 +
3171 void flush_tlb_all(void)
3172 {
3173 if (tlb_ops_need_broadcast())
3174 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3175 else
3176 local_flush_tlb_all();
3177 + broadcast_tlb_a15_erratum();
3178 }
3179
3180 void flush_tlb_mm(struct mm_struct *mm)
3181 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3182 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3183 else
3184 local_flush_tlb_mm(mm);
3185 + broadcast_tlb_mm_a15_erratum(mm);
3186 }
3187
3188 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3189 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3190 &ta, 1);
3191 } else
3192 local_flush_tlb_page(vma, uaddr);
3193 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3194 }
3195
3196 void flush_tlb_kernel_page(unsigned long kaddr)
3197 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3198 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3199 } else
3200 local_flush_tlb_kernel_page(kaddr);
3201 + broadcast_tlb_a15_erratum();
3202 }
3203
3204 void flush_tlb_range(struct vm_area_struct *vma,
3205 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3206 &ta, 1);
3207 } else
3208 local_flush_tlb_range(vma, start, end);
3209 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3210 }
3211
3212 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3213 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3214 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3215 } else
3216 local_flush_tlb_kernel_range(start, end);
3217 + broadcast_tlb_a15_erratum();
3218 }
3219
3220 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3221 index b0179b8..829510e 100644
3222 --- a/arch/arm/kernel/traps.c
3223 +++ b/arch/arm/kernel/traps.c
3224 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3225 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3226 {
3227 #ifdef CONFIG_KALLSYMS
3228 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3229 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3230 #else
3231 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3232 #endif
3233 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3234 static int die_owner = -1;
3235 static unsigned int die_nest_count;
3236
3237 +extern void gr_handle_kernel_exploit(void);
3238 +
3239 static unsigned long oops_begin(void)
3240 {
3241 int cpu;
3242 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3243 panic("Fatal exception in interrupt");
3244 if (panic_on_oops)
3245 panic("Fatal exception");
3246 +
3247 + gr_handle_kernel_exploit();
3248 +
3249 if (signr)
3250 do_exit(signr);
3251 }
3252 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3253 * The user helper at 0xffff0fe0 must be used instead.
3254 * (see entry-armv.S for details)
3255 */
3256 + pax_open_kernel();
3257 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3258 + pax_close_kernel();
3259 }
3260 return 0;
3261
3262 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3263 */
3264 kuser_get_tls_init(vectors);
3265
3266 - /*
3267 - * Copy signal return handlers into the vector page, and
3268 - * set sigreturn to be a pointer to these.
3269 - */
3270 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3271 - sigreturn_codes, sizeof(sigreturn_codes));
3272 -
3273 flush_icache_range(vectors, vectors + PAGE_SIZE);
3274 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3275 +
3276 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3277 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3278 +#endif
3279 +
3280 }
3281 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3282 index 11c1785..1b209f4 100644
3283 --- a/arch/arm/kernel/vmlinux.lds.S
3284 +++ b/arch/arm/kernel/vmlinux.lds.S
3285 @@ -8,7 +8,11 @@
3286 #include <asm/thread_info.h>
3287 #include <asm/memory.h>
3288 #include <asm/page.h>
3289 -
3290 +
3291 +#ifdef CONFIG_PAX_KERNEXEC
3292 +#include <asm/pgtable.h>
3293 +#endif
3294 +
3295 #define PROC_INFO \
3296 . = ALIGN(4); \
3297 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3298 @@ -90,6 +94,11 @@ SECTIONS
3299 _text = .;
3300 HEAD_TEXT
3301 }
3302 +
3303 +#ifdef CONFIG_PAX_KERNEXEC
3304 + . = ALIGN(1<<SECTION_SHIFT);
3305 +#endif
3306 +
3307 .text : { /* Real text segment */
3308 _stext = .; /* Text and read-only data */
3309 __exception_text_start = .;
3310 @@ -112,6 +121,8 @@ SECTIONS
3311 ARM_CPU_KEEP(PROC_INFO)
3312 }
3313
3314 + _etext = .; /* End of text section */
3315 +
3316 RO_DATA(PAGE_SIZE)
3317
3318 . = ALIGN(4);
3319 @@ -142,7 +153,9 @@ SECTIONS
3320
3321 NOTES
3322
3323 - _etext = .; /* End of text and rodata section */
3324 +#ifdef CONFIG_PAX_KERNEXEC
3325 + . = ALIGN(1<<SECTION_SHIFT);
3326 +#endif
3327
3328 #ifndef CONFIG_XIP_KERNEL
3329 . = ALIGN(PAGE_SIZE);
3330 @@ -203,6 +216,11 @@ SECTIONS
3331 . = PAGE_OFFSET + TEXT_OFFSET;
3332 #else
3333 __init_end = .;
3334 +
3335 +#ifdef CONFIG_PAX_KERNEXEC
3336 + . = ALIGN(1<<SECTION_SHIFT);
3337 +#endif
3338 +
3339 . = ALIGN(THREAD_SIZE);
3340 __data_loc = .;
3341 #endif
3342 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3343 index 14a0d98..7771a7d 100644
3344 --- a/arch/arm/lib/clear_user.S
3345 +++ b/arch/arm/lib/clear_user.S
3346 @@ -12,14 +12,14 @@
3347
3348 .text
3349
3350 -/* Prototype: int __clear_user(void *addr, size_t sz)
3351 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3352 * Purpose : clear some user memory
3353 * Params : addr - user memory address to clear
3354 * : sz - number of bytes to clear
3355 * Returns : number of bytes NOT cleared
3356 */
3357 ENTRY(__clear_user_std)
3358 -WEAK(__clear_user)
3359 +WEAK(___clear_user)
3360 stmfd sp!, {r1, lr}
3361 mov r2, #0
3362 cmp r1, #4
3363 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3364 USER( strnebt r2, [r0])
3365 mov r0, #0
3366 ldmfd sp!, {r1, pc}
3367 -ENDPROC(__clear_user)
3368 +ENDPROC(___clear_user)
3369 ENDPROC(__clear_user_std)
3370
3371 .pushsection .fixup,"ax"
3372 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3373 index 66a477a..bee61d3 100644
3374 --- a/arch/arm/lib/copy_from_user.S
3375 +++ b/arch/arm/lib/copy_from_user.S
3376 @@ -16,7 +16,7 @@
3377 /*
3378 * Prototype:
3379 *
3380 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3381 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3382 *
3383 * Purpose:
3384 *
3385 @@ -84,11 +84,11 @@
3386
3387 .text
3388
3389 -ENTRY(__copy_from_user)
3390 +ENTRY(___copy_from_user)
3391
3392 #include "copy_template.S"
3393
3394 -ENDPROC(__copy_from_user)
3395 +ENDPROC(___copy_from_user)
3396
3397 .pushsection .fixup,"ax"
3398 .align 0
3399 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3400 index 6ee2f67..d1cce76 100644
3401 --- a/arch/arm/lib/copy_page.S
3402 +++ b/arch/arm/lib/copy_page.S
3403 @@ -10,6 +10,7 @@
3404 * ASM optimised string functions
3405 */
3406 #include <linux/linkage.h>
3407 +#include <linux/const.h>
3408 #include <asm/assembler.h>
3409 #include <asm/asm-offsets.h>
3410 #include <asm/cache.h>
3411 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3412 index d066df6..df28194 100644
3413 --- a/arch/arm/lib/copy_to_user.S
3414 +++ b/arch/arm/lib/copy_to_user.S
3415 @@ -16,7 +16,7 @@
3416 /*
3417 * Prototype:
3418 *
3419 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3420 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3421 *
3422 * Purpose:
3423 *
3424 @@ -88,11 +88,11 @@
3425 .text
3426
3427 ENTRY(__copy_to_user_std)
3428 -WEAK(__copy_to_user)
3429 +WEAK(___copy_to_user)
3430
3431 #include "copy_template.S"
3432
3433 -ENDPROC(__copy_to_user)
3434 +ENDPROC(___copy_to_user)
3435 ENDPROC(__copy_to_user_std)
3436
3437 .pushsection .fixup,"ax"
3438 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3439 index 7d08b43..f7ca7ea 100644
3440 --- a/arch/arm/lib/csumpartialcopyuser.S
3441 +++ b/arch/arm/lib/csumpartialcopyuser.S
3442 @@ -57,8 +57,8 @@
3443 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3444 */
3445
3446 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3447 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3448 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3449 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3450
3451 #include "csumpartialcopygeneric.S"
3452
3453 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3454 index 6b93f6a..4aa5e85 100644
3455 --- a/arch/arm/lib/delay.c
3456 +++ b/arch/arm/lib/delay.c
3457 @@ -28,7 +28,7 @@
3458 /*
3459 * Default to the loop-based delay implementation.
3460 */
3461 -struct arm_delay_ops arm_delay_ops = {
3462 +struct arm_delay_ops arm_delay_ops __read_only = {
3463 .delay = __loop_delay,
3464 .const_udelay = __loop_const_udelay,
3465 .udelay = __loop_udelay,
3466 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3467 index 025f742..8432b08 100644
3468 --- a/arch/arm/lib/uaccess_with_memcpy.c
3469 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3470 @@ -104,7 +104,7 @@ out:
3471 }
3472
3473 unsigned long
3474 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3475 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3476 {
3477 /*
3478 * This test is stubbed out of the main function above to keep
3479 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3480 index bac21a5..b67ef8e 100644
3481 --- a/arch/arm/mach-kirkwood/common.c
3482 +++ b/arch/arm/mach-kirkwood/common.c
3483 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3484 clk_gate_ops.disable(hw);
3485 }
3486
3487 -static struct clk_ops clk_gate_fn_ops;
3488 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3489 +{
3490 + return clk_gate_ops.is_enabled(hw);
3491 +}
3492 +
3493 +static struct clk_ops clk_gate_fn_ops = {
3494 + .enable = clk_gate_fn_enable,
3495 + .disable = clk_gate_fn_disable,
3496 + .is_enabled = clk_gate_fn_is_enabled,
3497 +};
3498
3499 static struct clk __init *clk_register_gate_fn(struct device *dev,
3500 const char *name,
3501 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3502 gate_fn->fn_en = fn_en;
3503 gate_fn->fn_dis = fn_dis;
3504
3505 - /* ops is the gate ops, but with our enable/disable functions */
3506 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3507 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3508 - clk_gate_fn_ops = clk_gate_ops;
3509 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3510 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3511 - }
3512 -
3513 clk = clk_register(dev, &gate_fn->gate.hw);
3514
3515 if (IS_ERR(clk))
3516 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3517 index 0abb30f..54064da 100644
3518 --- a/arch/arm/mach-omap2/board-n8x0.c
3519 +++ b/arch/arm/mach-omap2/board-n8x0.c
3520 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3521 }
3522 #endif
3523
3524 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3525 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3526 .late_init = n8x0_menelaus_late_init,
3527 };
3528
3529 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3530 index 8033cb7..2f7cb62 100644
3531 --- a/arch/arm/mach-omap2/gpmc.c
3532 +++ b/arch/arm/mach-omap2/gpmc.c
3533 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3534 };
3535
3536 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3537 -static struct irq_chip gpmc_irq_chip;
3538 static unsigned gpmc_irq_start;
3539
3540 static struct resource gpmc_mem_root;
3541 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3542
3543 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3544
3545 +static struct irq_chip gpmc_irq_chip = {
3546 + .name = "gpmc",
3547 + .irq_startup = gpmc_irq_noop_ret,
3548 + .irq_enable = gpmc_irq_enable,
3549 + .irq_disable = gpmc_irq_disable,
3550 + .irq_shutdown = gpmc_irq_noop,
3551 + .irq_ack = gpmc_irq_noop,
3552 + .irq_mask = gpmc_irq_noop,
3553 + .irq_unmask = gpmc_irq_noop,
3554 +
3555 +};
3556 +
3557 static int gpmc_setup_irq(void)
3558 {
3559 int i;
3560 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3561 return gpmc_irq_start;
3562 }
3563
3564 - gpmc_irq_chip.name = "gpmc";
3565 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3566 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3567 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3568 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3569 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3570 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3571 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3572 -
3573 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3574 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3575
3576 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3577 index 5d3b4f4..ddba3c0 100644
3578 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3579 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3580 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3581 return NOTIFY_OK;
3582 }
3583
3584 -static struct notifier_block __refdata irq_hotplug_notifier = {
3585 +static struct notifier_block irq_hotplug_notifier = {
3586 .notifier_call = irq_cpu_hotplug_notify,
3587 };
3588
3589 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3590 index e065daa..7b1ad9b 100644
3591 --- a/arch/arm/mach-omap2/omap_device.c
3592 +++ b/arch/arm/mach-omap2/omap_device.c
3593 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3594 * passes along the return value of omap_device_build_ss().
3595 */
3596 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3597 - struct omap_hwmod *oh, void *pdata,
3598 + struct omap_hwmod *oh, const void *pdata,
3599 int pdata_len,
3600 struct omap_device_pm_latency *pm_lats,
3601 int pm_lats_cnt, int is_early_device)
3602 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3603 */
3604 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3605 struct omap_hwmod **ohs, int oh_cnt,
3606 - void *pdata, int pdata_len,
3607 + const void *pdata, int pdata_len,
3608 struct omap_device_pm_latency *pm_lats,
3609 int pm_lats_cnt, int is_early_device)
3610 {
3611 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3612 index 0933c59..42b8e2d 100644
3613 --- a/arch/arm/mach-omap2/omap_device.h
3614 +++ b/arch/arm/mach-omap2/omap_device.h
3615 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3616 /* Core code interface */
3617
3618 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3619 - struct omap_hwmod *oh, void *pdata,
3620 + struct omap_hwmod *oh, const void *pdata,
3621 int pdata_len,
3622 struct omap_device_pm_latency *pm_lats,
3623 int pm_lats_cnt, int is_early_device);
3624
3625 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3626 struct omap_hwmod **oh, int oh_cnt,
3627 - void *pdata, int pdata_len,
3628 + const void *pdata, int pdata_len,
3629 struct omap_device_pm_latency *pm_lats,
3630 int pm_lats_cnt, int is_early_device);
3631
3632 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3633 index 4653efb..8c60bf7 100644
3634 --- a/arch/arm/mach-omap2/omap_hwmod.c
3635 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3636 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3637 int (*init_clkdm)(struct omap_hwmod *oh);
3638 void (*update_context_lost)(struct omap_hwmod *oh);
3639 int (*get_context_lost)(struct omap_hwmod *oh);
3640 -};
3641 +} __no_const;
3642
3643 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3644 -static struct omap_hwmod_soc_ops soc_ops;
3645 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3646
3647 /* omap_hwmod_list contains all registered struct omap_hwmods */
3648 static LIST_HEAD(omap_hwmod_list);
3649 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3650 index 7c2b4ed..b2ea51f 100644
3651 --- a/arch/arm/mach-omap2/wd_timer.c
3652 +++ b/arch/arm/mach-omap2/wd_timer.c
3653 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3654 struct omap_hwmod *oh;
3655 char *oh_name = "wd_timer2";
3656 char *dev_name = "omap_wdt";
3657 - struct omap_wd_timer_platform_data pdata;
3658 + static struct omap_wd_timer_platform_data pdata = {
3659 + .read_reset_sources = prm_read_reset_sources
3660 + };
3661
3662 if (!cpu_class_is_omap2() || of_have_populated_dt())
3663 return 0;
3664 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3665 return -EINVAL;
3666 }
3667
3668 - pdata.read_reset_sources = prm_read_reset_sources;
3669 -
3670 pdev = omap_device_build(dev_name, id, oh, &pdata,
3671 sizeof(struct omap_wd_timer_platform_data),
3672 NULL, 0, 0);
3673 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3674 index 6be4c4d..32ac32a 100644
3675 --- a/arch/arm/mach-ux500/include/mach/setup.h
3676 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3677 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3678 .type = MT_DEVICE, \
3679 }
3680
3681 -#define __MEM_DEV_DESC(x, sz) { \
3682 - .virtual = IO_ADDRESS(x), \
3683 - .pfn = __phys_to_pfn(x), \
3684 - .length = sz, \
3685 - .type = MT_MEMORY, \
3686 -}
3687 -
3688 extern struct smp_operations ux500_smp_ops;
3689 extern void ux500_cpu_die(unsigned int cpu);
3690
3691 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3692 index 3fd629d..8b1aca9 100644
3693 --- a/arch/arm/mm/Kconfig
3694 +++ b/arch/arm/mm/Kconfig
3695 @@ -425,7 +425,7 @@ config CPU_32v5
3696
3697 config CPU_32v6
3698 bool
3699 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3700 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3701 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3702
3703 config CPU_32v6K
3704 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3705
3706 config CPU_USE_DOMAINS
3707 bool
3708 + depends on !ARM_LPAE && !PAX_KERNEXEC
3709 help
3710 This option enables or disables the use of domain switching
3711 via the set_fs() function.
3712 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3713 index db26e2e..ee44569 100644
3714 --- a/arch/arm/mm/alignment.c
3715 +++ b/arch/arm/mm/alignment.c
3716 @@ -211,10 +211,12 @@ union offset_union {
3717 #define __get16_unaligned_check(ins,val,addr) \
3718 do { \
3719 unsigned int err = 0, v, a = addr; \
3720 + pax_open_userland(); \
3721 __get8_unaligned_check(ins,v,a,err); \
3722 val = v << ((BE) ? 8 : 0); \
3723 __get8_unaligned_check(ins,v,a,err); \
3724 val |= v << ((BE) ? 0 : 8); \
3725 + pax_close_userland(); \
3726 if (err) \
3727 goto fault; \
3728 } while (0)
3729 @@ -228,6 +230,7 @@ union offset_union {
3730 #define __get32_unaligned_check(ins,val,addr) \
3731 do { \
3732 unsigned int err = 0, v, a = addr; \
3733 + pax_open_userland(); \
3734 __get8_unaligned_check(ins,v,a,err); \
3735 val = v << ((BE) ? 24 : 0); \
3736 __get8_unaligned_check(ins,v,a,err); \
3737 @@ -236,6 +239,7 @@ union offset_union {
3738 val |= v << ((BE) ? 8 : 16); \
3739 __get8_unaligned_check(ins,v,a,err); \
3740 val |= v << ((BE) ? 0 : 24); \
3741 + pax_close_userland(); \
3742 if (err) \
3743 goto fault; \
3744 } while (0)
3745 @@ -249,6 +253,7 @@ union offset_union {
3746 #define __put16_unaligned_check(ins,val,addr) \
3747 do { \
3748 unsigned int err = 0, v = val, a = addr; \
3749 + pax_open_userland(); \
3750 __asm__( FIRST_BYTE_16 \
3751 ARM( "1: "ins" %1, [%2], #1\n" ) \
3752 THUMB( "1: "ins" %1, [%2]\n" ) \
3753 @@ -268,6 +273,7 @@ union offset_union {
3754 " .popsection\n" \
3755 : "=r" (err), "=&r" (v), "=&r" (a) \
3756 : "0" (err), "1" (v), "2" (a)); \
3757 + pax_close_userland(); \
3758 if (err) \
3759 goto fault; \
3760 } while (0)
3761 @@ -281,6 +287,7 @@ union offset_union {
3762 #define __put32_unaligned_check(ins,val,addr) \
3763 do { \
3764 unsigned int err = 0, v = val, a = addr; \
3765 + pax_open_userland(); \
3766 __asm__( FIRST_BYTE_32 \
3767 ARM( "1: "ins" %1, [%2], #1\n" ) \
3768 THUMB( "1: "ins" %1, [%2]\n" ) \
3769 @@ -310,6 +317,7 @@ union offset_union {
3770 " .popsection\n" \
3771 : "=r" (err), "=&r" (v), "=&r" (a) \
3772 : "0" (err), "1" (v), "2" (a)); \
3773 + pax_close_userland(); \
3774 if (err) \
3775 goto fault; \
3776 } while (0)
3777 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3778 index d07df17..59d5493 100644
3779 --- a/arch/arm/mm/context.c
3780 +++ b/arch/arm/mm/context.c
3781 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3782 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3783 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3784
3785 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3786 +DEFINE_PER_CPU(atomic64_t, active_asids);
3787 static DEFINE_PER_CPU(u64, reserved_asids);
3788 static cpumask_t tlb_flush_pending;
3789
3790 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3791 atomic64_set(&mm->context.id, asid);
3792 }
3793
3794 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3795 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3796 local_flush_tlb_all();
3797 + dummy_flush_tlb_a15_erratum();
3798 + }
3799
3800 atomic64_set(&per_cpu(active_asids, cpu), asid);
3801 cpumask_set_cpu(cpu, mm_cpumask(mm));
3802 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3803 index 5dbf13f..1a60561 100644
3804 --- a/arch/arm/mm/fault.c
3805 +++ b/arch/arm/mm/fault.c
3806 @@ -25,6 +25,7 @@
3807 #include <asm/system_misc.h>
3808 #include <asm/system_info.h>
3809 #include <asm/tlbflush.h>
3810 +#include <asm/sections.h>
3811
3812 #include "fault.h"
3813
3814 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3815 if (fixup_exception(regs))
3816 return;
3817
3818 +#ifdef CONFIG_PAX_KERNEXEC
3819 + if ((fsr & FSR_WRITE) &&
3820 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3821 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3822 + {
3823 + if (current->signal->curr_ip)
3824 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3825 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3826 + else
3827 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3829 + }
3830 +#endif
3831 +
3832 /*
3833 * No handler, we'll have to terminate things with extreme prejudice.
3834 */
3835 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3836 }
3837 #endif
3838
3839 +#ifdef CONFIG_PAX_PAGEEXEC
3840 + if (fsr & FSR_LNX_PF) {
3841 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3842 + do_group_exit(SIGKILL);
3843 + }
3844 +#endif
3845 +
3846 tsk->thread.address = addr;
3847 tsk->thread.error_code = fsr;
3848 tsk->thread.trap_no = 14;
3849 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3850 }
3851 #endif /* CONFIG_MMU */
3852
3853 +#ifdef CONFIG_PAX_PAGEEXEC
3854 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3855 +{
3856 + long i;
3857 +
3858 + printk(KERN_ERR "PAX: bytes at PC: ");
3859 + for (i = 0; i < 20; i++) {
3860 + unsigned char c;
3861 + if (get_user(c, (__force unsigned char __user *)pc+i))
3862 + printk(KERN_CONT "?? ");
3863 + else
3864 + printk(KERN_CONT "%02x ", c);
3865 + }
3866 + printk("\n");
3867 +
3868 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3869 + for (i = -1; i < 20; i++) {
3870 + unsigned long c;
3871 + if (get_user(c, (__force unsigned long __user *)sp+i))
3872 + printk(KERN_CONT "???????? ");
3873 + else
3874 + printk(KERN_CONT "%08lx ", c);
3875 + }
3876 + printk("\n");
3877 +}
3878 +#endif
3879 +
3880 /*
3881 * First Level Translation Fault Handler
3882 *
3883 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3884 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3885 struct siginfo info;
3886
3887 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3888 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3889 + if (current->signal->curr_ip)
3890 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3891 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3892 + else
3893 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3894 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3895 + goto die;
3896 + }
3897 +#endif
3898 +
3899 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3900 return;
3901
3902 +die:
3903 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3904 inf->name, fsr, addr);
3905
3906 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3907 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3908 struct siginfo info;
3909
3910 + if (user_mode(regs)) {
3911 + if (addr == 0xffff0fe0UL) {
3912 + /*
3913 + * PaX: __kuser_get_tls emulation
3914 + */
3915 + regs->ARM_r0 = current_thread_info()->tp_value;
3916 + regs->ARM_pc = regs->ARM_lr;
3917 + return;
3918 + }
3919 + }
3920 +
3921 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3922 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3923 + if (current->signal->curr_ip)
3924 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3925 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3926 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3927 + else
3928 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3929 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3930 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3931 + goto die;
3932 + }
3933 +#endif
3934 +
3935 +#ifdef CONFIG_PAX_REFCOUNT
3936 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3937 + unsigned int bkpt;
3938 +
3939 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3940 + current->thread.error_code = ifsr;
3941 + current->thread.trap_no = 0;
3942 + pax_report_refcount_overflow(regs);
3943 + fixup_exception(regs);
3944 + return;
3945 + }
3946 + }
3947 +#endif
3948 +
3949 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3950 return;
3951
3952 +die:
3953 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3954 inf->name, ifsr, addr);
3955
3956 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3957 index cf08bdf..772656c 100644
3958 --- a/arch/arm/mm/fault.h
3959 +++ b/arch/arm/mm/fault.h
3960 @@ -3,6 +3,7 @@
3961
3962 /*
3963 * Fault status register encodings. We steal bit 31 for our own purposes.
3964 + * Set when the FSR value is from an instruction fault.
3965 */
3966 #define FSR_LNX_PF (1 << 31)
3967 #define FSR_WRITE (1 << 11)
3968 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3969 }
3970 #endif
3971
3972 +/* valid for LPAE and !LPAE */
3973 +static inline int is_xn_fault(unsigned int fsr)
3974 +{
3975 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3976 +}
3977 +
3978 +static inline int is_domain_fault(unsigned int fsr)
3979 +{
3980 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3981 +}
3982 +
3983 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3984 unsigned long search_exception_table(unsigned long addr);
3985
3986 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3987 index ad722f1..763fdd3 100644
3988 --- a/arch/arm/mm/init.c
3989 +++ b/arch/arm/mm/init.c
3990 @@ -30,6 +30,8 @@
3991 #include <asm/setup.h>
3992 #include <asm/tlb.h>
3993 #include <asm/fixmap.h>
3994 +#include <asm/system_info.h>
3995 +#include <asm/cp15.h>
3996
3997 #include <asm/mach/arch.h>
3998 #include <asm/mach/map.h>
3999 @@ -736,7 +738,46 @@ void free_initmem(void)
4000 {
4001 #ifdef CONFIG_HAVE_TCM
4002 extern char __tcm_start, __tcm_end;
4003 +#endif
4004
4005 +#ifdef CONFIG_PAX_KERNEXEC
4006 + unsigned long addr;
4007 + pgd_t *pgd;
4008 + pud_t *pud;
4009 + pmd_t *pmd;
4010 + int cpu_arch = cpu_architecture();
4011 + unsigned int cr = get_cr();
4012 +
4013 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4014 + /* make pages tables, etc before .text NX */
4015 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4016 + pgd = pgd_offset_k(addr);
4017 + pud = pud_offset(pgd, addr);
4018 + pmd = pmd_offset(pud, addr);
4019 + __section_update(pmd, addr, PMD_SECT_XN);
4020 + }
4021 + /* make init NX */
4022 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4023 + pgd = pgd_offset_k(addr);
4024 + pud = pud_offset(pgd, addr);
4025 + pmd = pmd_offset(pud, addr);
4026 + __section_update(pmd, addr, PMD_SECT_XN);
4027 + }
4028 + /* make kernel code/rodata RX */
4029 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4030 + pgd = pgd_offset_k(addr);
4031 + pud = pud_offset(pgd, addr);
4032 + pmd = pmd_offset(pud, addr);
4033 +#ifdef CONFIG_ARM_LPAE
4034 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4035 +#else
4036 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4037 +#endif
4038 + }
4039 + }
4040 +#endif
4041 +
4042 +#ifdef CONFIG_HAVE_TCM
4043 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4044 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4045 __phys_to_pfn(__pa(&__tcm_end)),
4046 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4047 index 88fd86c..7a224ce 100644
4048 --- a/arch/arm/mm/ioremap.c
4049 +++ b/arch/arm/mm/ioremap.c
4050 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4051 unsigned int mtype;
4052
4053 if (cached)
4054 - mtype = MT_MEMORY;
4055 + mtype = MT_MEMORY_RX;
4056 else
4057 - mtype = MT_MEMORY_NONCACHED;
4058 + mtype = MT_MEMORY_NONCACHED_RX;
4059
4060 return __arm_ioremap_caller(phys_addr, size, mtype,
4061 __builtin_return_address(0));
4062 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4063 index 10062ce..aa96dd7 100644
4064 --- a/arch/arm/mm/mmap.c
4065 +++ b/arch/arm/mm/mmap.c
4066 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4067 struct vm_area_struct *vma;
4068 int do_align = 0;
4069 int aliasing = cache_is_vipt_aliasing();
4070 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4071 struct vm_unmapped_area_info info;
4072
4073 /*
4074 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4075 if (len > TASK_SIZE)
4076 return -ENOMEM;
4077
4078 +#ifdef CONFIG_PAX_RANDMMAP
4079 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4080 +#endif
4081 +
4082 if (addr) {
4083 if (do_align)
4084 addr = COLOUR_ALIGN(addr, pgoff);
4085 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4086 addr = PAGE_ALIGN(addr);
4087
4088 vma = find_vma(mm, addr);
4089 - if (TASK_SIZE - len >= addr &&
4090 - (!vma || addr + len <= vma->vm_start))
4091 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4092 return addr;
4093 }
4094
4095 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4096 unsigned long addr = addr0;
4097 int do_align = 0;
4098 int aliasing = cache_is_vipt_aliasing();
4099 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4100 struct vm_unmapped_area_info info;
4101
4102 /*
4103 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4104 return addr;
4105 }
4106
4107 +#ifdef CONFIG_PAX_RANDMMAP
4108 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4109 +#endif
4110 +
4111 /* requesting a specific address */
4112 if (addr) {
4113 if (do_align)
4114 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4115 else
4116 addr = PAGE_ALIGN(addr);
4117 vma = find_vma(mm, addr);
4118 - if (TASK_SIZE - len >= addr &&
4119 - (!vma || addr + len <= vma->vm_start))
4120 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4121 return addr;
4122 }
4123
4124 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4125 VM_BUG_ON(addr != -ENOMEM);
4126 info.flags = 0;
4127 info.low_limit = mm->mmap_base;
4128 +
4129 +#ifdef CONFIG_PAX_RANDMMAP
4130 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4131 + info.low_limit += mm->delta_mmap;
4132 +#endif
4133 +
4134 info.high_limit = TASK_SIZE;
4135 addr = vm_unmapped_area(&info);
4136 }
4137 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4138 {
4139 unsigned long random_factor = 0UL;
4140
4141 +#ifdef CONFIG_PAX_RANDMMAP
4142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4143 +#endif
4144 +
4145 /* 8 bits of randomness in 20 address space bits */
4146 if ((current->flags & PF_RANDOMIZE) &&
4147 !(current->personality & ADDR_NO_RANDOMIZE))
4148 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4149
4150 if (mmap_is_legacy()) {
4151 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4152 +
4153 +#ifdef CONFIG_PAX_RANDMMAP
4154 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4155 + mm->mmap_base += mm->delta_mmap;
4156 +#endif
4157 +
4158 mm->get_unmapped_area = arch_get_unmapped_area;
4159 mm->unmap_area = arch_unmap_area;
4160 } else {
4161 mm->mmap_base = mmap_base(random_factor);
4162 +
4163 +#ifdef CONFIG_PAX_RANDMMAP
4164 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4165 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4166 +#endif
4167 +
4168 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4169 mm->unmap_area = arch_unmap_area_topdown;
4170 }
4171 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4172 index ce328c7..35b88dc 100644
4173 --- a/arch/arm/mm/mmu.c
4174 +++ b/arch/arm/mm/mmu.c
4175 @@ -35,6 +35,23 @@
4176
4177 #include "mm.h"
4178
4179 +
4180 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4181 +void modify_domain(unsigned int dom, unsigned int type)
4182 +{
4183 + struct thread_info *thread = current_thread_info();
4184 + unsigned int domain = thread->cpu_domain;
4185 + /*
4186 + * DOMAIN_MANAGER might be defined to some other value,
4187 + * use the arch-defined constant
4188 + */
4189 + domain &= ~domain_val(dom, 3);
4190 + thread->cpu_domain = domain | domain_val(dom, type);
4191 + set_domain(thread->cpu_domain);
4192 +}
4193 +EXPORT_SYMBOL(modify_domain);
4194 +#endif
4195 +
4196 /*
4197 * empty_zero_page is a special page that is used for
4198 * zero-initialized data and COW.
4199 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4200 }
4201 #endif
4202
4203 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4204 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4205 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4206
4207 -static struct mem_type mem_types[] = {
4208 +#ifdef CONFIG_PAX_KERNEXEC
4209 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4210 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4211 +#else
4212 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4213 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4214 +#endif
4215 +
4216 +static struct mem_type mem_types[] __read_only = {
4217 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4218 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4219 L_PTE_SHARED,
4220 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4221 [MT_UNCACHED] = {
4222 .prot_pte = PROT_PTE_DEVICE,
4223 .prot_l1 = PMD_TYPE_TABLE,
4224 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4225 + .prot_sect = PROT_SECT_DEVICE,
4226 .domain = DOMAIN_IO,
4227 },
4228 [MT_CACHECLEAN] = {
4229 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4230 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4231 .domain = DOMAIN_KERNEL,
4232 },
4233 #ifndef CONFIG_ARM_LPAE
4234 [MT_MINICLEAN] = {
4235 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4236 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4237 .domain = DOMAIN_KERNEL,
4238 },
4239 #endif
4240 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4241 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4242 L_PTE_RDONLY,
4243 .prot_l1 = PMD_TYPE_TABLE,
4244 - .domain = DOMAIN_USER,
4245 + .domain = DOMAIN_VECTORS,
4246 },
4247 [MT_HIGH_VECTORS] = {
4248 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4249 - L_PTE_USER | L_PTE_RDONLY,
4250 + L_PTE_RDONLY,
4251 .prot_l1 = PMD_TYPE_TABLE,
4252 - .domain = DOMAIN_USER,
4253 + .domain = DOMAIN_VECTORS,
4254 },
4255 - [MT_MEMORY] = {
4256 + [MT_MEMORY_RWX] = {
4257 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4258 .prot_l1 = PMD_TYPE_TABLE,
4259 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4260 .domain = DOMAIN_KERNEL,
4261 },
4262 + [MT_MEMORY_RW] = {
4263 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4264 + .prot_l1 = PMD_TYPE_TABLE,
4265 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4266 + .domain = DOMAIN_KERNEL,
4267 + },
4268 + [MT_MEMORY_RX] = {
4269 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4270 + .prot_l1 = PMD_TYPE_TABLE,
4271 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4272 + .domain = DOMAIN_KERNEL,
4273 + },
4274 [MT_ROM] = {
4275 - .prot_sect = PMD_TYPE_SECT,
4276 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4277 .domain = DOMAIN_KERNEL,
4278 },
4279 - [MT_MEMORY_NONCACHED] = {
4280 + [MT_MEMORY_NONCACHED_RW] = {
4281 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4282 L_PTE_MT_BUFFERABLE,
4283 .prot_l1 = PMD_TYPE_TABLE,
4284 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4285 .domain = DOMAIN_KERNEL,
4286 },
4287 + [MT_MEMORY_NONCACHED_RX] = {
4288 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4289 + L_PTE_MT_BUFFERABLE,
4290 + .prot_l1 = PMD_TYPE_TABLE,
4291 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4292 + .domain = DOMAIN_KERNEL,
4293 + },
4294 [MT_MEMORY_DTCM] = {
4295 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4296 - L_PTE_XN,
4297 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4298 .prot_l1 = PMD_TYPE_TABLE,
4299 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4300 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4301 .domain = DOMAIN_KERNEL,
4302 },
4303 [MT_MEMORY_ITCM] = {
4304 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4305 },
4306 [MT_MEMORY_SO] = {
4307 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4308 - L_PTE_MT_UNCACHED | L_PTE_XN,
4309 + L_PTE_MT_UNCACHED,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4312 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4313 + PMD_SECT_UNCACHED,
4314 .domain = DOMAIN_KERNEL,
4315 },
4316 [MT_MEMORY_DMA_READY] = {
4317 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4318 * to prevent speculative instruction fetches.
4319 */
4320 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4321 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4322 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4323 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4324 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4325 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4326 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4327 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4328 +
4329 + /* Mark other regions on ARMv6+ as execute-never */
4330 +
4331 +#ifdef CONFIG_PAX_KERNEXEC
4332 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4333 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4334 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4335 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4336 +#ifndef CONFIG_ARM_LPAE
4337 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4338 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4339 +#endif
4340 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4341 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4342 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4343 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4344 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4345 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4346 +#endif
4347 +
4348 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4349 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4350 }
4351 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4352 /*
4353 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4354 * from SVC mode and no access from userspace.
4355 */
4356 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4357 +#ifdef CONFIG_PAX_KERNEXEC
4358 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4359 +#endif
4360 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4361 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4362 #endif
4363 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4364 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4365 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4366 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4367 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4368 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4369 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4370 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4371 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4372 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4373 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4374 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4375 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4376 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4377 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4378 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4379 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4380 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4381 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4382 }
4383 }
4384
4385 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4386 if (cpu_arch >= CPU_ARCH_ARMv6) {
4387 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4388 /* Non-cacheable Normal is XCB = 001 */
4389 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4390 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4391 + PMD_SECT_BUFFERED;
4392 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4393 PMD_SECT_BUFFERED;
4394 } else {
4395 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4396 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4397 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4398 + PMD_SECT_TEX(1);
4399 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4400 PMD_SECT_TEX(1);
4401 }
4402 } else {
4403 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4404 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4405 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4406 }
4407
4408 #ifdef CONFIG_ARM_LPAE
4409 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4410 vecs_pgprot |= PTE_EXT_AF;
4411 #endif
4412
4413 + user_pgprot |= __supported_pte_mask;
4414 +
4415 for (i = 0; i < 16; i++) {
4416 pteval_t v = pgprot_val(protection_map[i]);
4417 protection_map[i] = __pgprot(v | user_pgprot);
4418 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4419
4420 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4421 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4422 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4423 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4424 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4425 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4426 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4427 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4428 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4429 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4430 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4431 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4432 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4434 mem_types[MT_ROM].prot_sect |= cp->pmd;
4435
4436 switch (cp->pmd) {
4437 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4438 * called function. This means you can't use any function or debugging
4439 * method which may touch any device, otherwise the kernel _will_ crash.
4440 */
4441 +
4442 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4443 +
4444 static void __init devicemaps_init(struct machine_desc *mdesc)
4445 {
4446 struct map_desc map;
4447 unsigned long addr;
4448 - void *vectors;
4449
4450 - /*
4451 - * Allocate the vector page early.
4452 - */
4453 - vectors = early_alloc(PAGE_SIZE);
4454 -
4455 - early_trap_init(vectors);
4456 + early_trap_init(&vectors);
4457
4458 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4459 pmd_clear(pmd_off_k(addr));
4460 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4461 * location (0xffff0000). If we aren't using high-vectors, also
4462 * create a mapping at the low-vectors virtual address.
4463 */
4464 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4465 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4466 map.virtual = 0xffff0000;
4467 map.length = PAGE_SIZE;
4468 map.type = MT_HIGH_VECTORS;
4469 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4470 map.pfn = __phys_to_pfn(start);
4471 map.virtual = __phys_to_virt(start);
4472 map.length = end - start;
4473 - map.type = MT_MEMORY;
4474
4475 +#ifdef CONFIG_PAX_KERNEXEC
4476 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4477 + struct map_desc kernel;
4478 + struct map_desc initmap;
4479 +
4480 + /* when freeing initmem we will make this RW */
4481 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4482 + initmap.virtual = (unsigned long)__init_begin;
4483 + initmap.length = _sdata - __init_begin;
4484 + initmap.type = MT_MEMORY_RWX;
4485 + create_mapping(&initmap);
4486 +
4487 + /* when freeing initmem we will make this RX */
4488 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4489 + kernel.virtual = (unsigned long)_stext;
4490 + kernel.length = __init_begin - _stext;
4491 + kernel.type = MT_MEMORY_RWX;
4492 + create_mapping(&kernel);
4493 +
4494 + if (map.virtual < (unsigned long)_stext) {
4495 + map.length = (unsigned long)_stext - map.virtual;
4496 + map.type = MT_MEMORY_RWX;
4497 + create_mapping(&map);
4498 + }
4499 +
4500 + map.pfn = __phys_to_pfn(__pa(_sdata));
4501 + map.virtual = (unsigned long)_sdata;
4502 + map.length = end - __pa(_sdata);
4503 + }
4504 +#endif
4505 +
4506 + map.type = MT_MEMORY_RW;
4507 create_mapping(&map);
4508 }
4509 }
4510 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4511 index 6d98c13..3cfb174 100644
4512 --- a/arch/arm/mm/proc-v7-2level.S
4513 +++ b/arch/arm/mm/proc-v7-2level.S
4514 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4515 tst r1, #L_PTE_XN
4516 orrne r3, r3, #PTE_EXT_XN
4517
4518 + tst r1, #L_PTE_PXN
4519 + orrne r3, r3, #PTE_EXT_PXN
4520 +
4521 tst r1, #L_PTE_YOUNG
4522 tstne r1, #L_PTE_VALID
4523 #ifndef CONFIG_CPU_USE_DOMAINS
4524 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4525 index a5bc92d..0bb4730 100644
4526 --- a/arch/arm/plat-omap/sram.c
4527 +++ b/arch/arm/plat-omap/sram.c
4528 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4529 * Looks like we need to preserve some bootloader code at the
4530 * beginning of SRAM for jumping to flash for reboot to work...
4531 */
4532 + pax_open_kernel();
4533 memset_io(omap_sram_base + omap_sram_skip, 0,
4534 omap_sram_size - omap_sram_skip);
4535 + pax_close_kernel();
4536 }
4537 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4538 index f5144cd..71f6d1f 100644
4539 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4540 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4541 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4542 int (*started)(unsigned ch);
4543 int (*flush)(unsigned ch);
4544 int (*stop)(unsigned ch);
4545 -};
4546 +} __no_const;
4547
4548 extern void *samsung_dmadev_get_ops(void);
4549 extern void *s3c_dma_get_ops(void);
4550 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4551 index 0c3ba9f..95722b3 100644
4552 --- a/arch/arm64/kernel/debug-monitors.c
4553 +++ b/arch/arm64/kernel/debug-monitors.c
4554 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4555 return NOTIFY_OK;
4556 }
4557
4558 -static struct notifier_block __cpuinitdata os_lock_nb = {
4559 +static struct notifier_block os_lock_nb = {
4560 .notifier_call = os_lock_notify,
4561 };
4562
4563 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4564 index 5ab825c..96aaec8 100644
4565 --- a/arch/arm64/kernel/hw_breakpoint.c
4566 +++ b/arch/arm64/kernel/hw_breakpoint.c
4567 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4568 return NOTIFY_OK;
4569 }
4570
4571 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4572 +static struct notifier_block hw_breakpoint_reset_nb = {
4573 .notifier_call = hw_breakpoint_reset_notify,
4574 };
4575
4576 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4577 index c3a58a1..78fbf54 100644
4578 --- a/arch/avr32/include/asm/cache.h
4579 +++ b/arch/avr32/include/asm/cache.h
4580 @@ -1,8 +1,10 @@
4581 #ifndef __ASM_AVR32_CACHE_H
4582 #define __ASM_AVR32_CACHE_H
4583
4584 +#include <linux/const.h>
4585 +
4586 #define L1_CACHE_SHIFT 5
4587 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4588 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4589
4590 /*
4591 * Memory returned by kmalloc() may be used for DMA, so we must make
4592 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4593 index e2c3287..6c4f98c 100644
4594 --- a/arch/avr32/include/asm/elf.h
4595 +++ b/arch/avr32/include/asm/elf.h
4596 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4597 the loader. We need to make sure that it is out of the way of the program
4598 that it will "exec", and that there is sufficient room for the brk. */
4599
4600 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4601 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4602
4603 +#ifdef CONFIG_PAX_ASLR
4604 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4605 +
4606 +#define PAX_DELTA_MMAP_LEN 15
4607 +#define PAX_DELTA_STACK_LEN 15
4608 +#endif
4609
4610 /* This yields a mask that user programs can use to figure out what
4611 instruction set this CPU supports. This could be done in user space,
4612 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4613 index 479330b..53717a8 100644
4614 --- a/arch/avr32/include/asm/kmap_types.h
4615 +++ b/arch/avr32/include/asm/kmap_types.h
4616 @@ -2,9 +2,9 @@
4617 #define __ASM_AVR32_KMAP_TYPES_H
4618
4619 #ifdef CONFIG_DEBUG_HIGHMEM
4620 -# define KM_TYPE_NR 29
4621 +# define KM_TYPE_NR 30
4622 #else
4623 -# define KM_TYPE_NR 14
4624 +# define KM_TYPE_NR 15
4625 #endif
4626
4627 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4628 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4629 index b2f2d2d..d1c85cb 100644
4630 --- a/arch/avr32/mm/fault.c
4631 +++ b/arch/avr32/mm/fault.c
4632 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4633
4634 int exception_trace = 1;
4635
4636 +#ifdef CONFIG_PAX_PAGEEXEC
4637 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4638 +{
4639 + unsigned long i;
4640 +
4641 + printk(KERN_ERR "PAX: bytes at PC: ");
4642 + for (i = 0; i < 20; i++) {
4643 + unsigned char c;
4644 + if (get_user(c, (unsigned char *)pc+i))
4645 + printk(KERN_CONT "???????? ");
4646 + else
4647 + printk(KERN_CONT "%02x ", c);
4648 + }
4649 + printk("\n");
4650 +}
4651 +#endif
4652 +
4653 /*
4654 * This routine handles page faults. It determines the address and the
4655 * problem, and then passes it off to one of the appropriate routines.
4656 @@ -174,6 +191,16 @@ bad_area:
4657 up_read(&mm->mmap_sem);
4658
4659 if (user_mode(regs)) {
4660 +
4661 +#ifdef CONFIG_PAX_PAGEEXEC
4662 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4663 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4664 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4665 + do_group_exit(SIGKILL);
4666 + }
4667 + }
4668 +#endif
4669 +
4670 if (exception_trace && printk_ratelimit())
4671 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4672 "sp %08lx ecr %lu\n",
4673 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4674 index 568885a..f8008df 100644
4675 --- a/arch/blackfin/include/asm/cache.h
4676 +++ b/arch/blackfin/include/asm/cache.h
4677 @@ -7,6 +7,7 @@
4678 #ifndef __ARCH_BLACKFIN_CACHE_H
4679 #define __ARCH_BLACKFIN_CACHE_H
4680
4681 +#include <linux/const.h>
4682 #include <linux/linkage.h> /* for asmlinkage */
4683
4684 /*
4685 @@ -14,7 +15,7 @@
4686 * Blackfin loads 32 bytes for cache
4687 */
4688 #define L1_CACHE_SHIFT 5
4689 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4690 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4691 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4692
4693 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4694 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4695 index aea2718..3639a60 100644
4696 --- a/arch/cris/include/arch-v10/arch/cache.h
4697 +++ b/arch/cris/include/arch-v10/arch/cache.h
4698 @@ -1,8 +1,9 @@
4699 #ifndef _ASM_ARCH_CACHE_H
4700 #define _ASM_ARCH_CACHE_H
4701
4702 +#include <linux/const.h>
4703 /* Etrax 100LX have 32-byte cache-lines. */
4704 -#define L1_CACHE_BYTES 32
4705 #define L1_CACHE_SHIFT 5
4706 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4707
4708 #endif /* _ASM_ARCH_CACHE_H */
4709 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4710 index 7caf25d..ee65ac5 100644
4711 --- a/arch/cris/include/arch-v32/arch/cache.h
4712 +++ b/arch/cris/include/arch-v32/arch/cache.h
4713 @@ -1,11 +1,12 @@
4714 #ifndef _ASM_CRIS_ARCH_CACHE_H
4715 #define _ASM_CRIS_ARCH_CACHE_H
4716
4717 +#include <linux/const.h>
4718 #include <arch/hwregs/dma.h>
4719
4720 /* A cache-line is 32 bytes. */
4721 -#define L1_CACHE_BYTES 32
4722 #define L1_CACHE_SHIFT 5
4723 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4724
4725 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4726
4727 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4728 index b86329d..6709906 100644
4729 --- a/arch/frv/include/asm/atomic.h
4730 +++ b/arch/frv/include/asm/atomic.h
4731 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4732 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4733 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4734
4735 +#define atomic64_read_unchecked(v) atomic64_read(v)
4736 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4737 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4738 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4739 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4740 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4741 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4742 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4743 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4744 +
4745 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4746 {
4747 int c, old;
4748 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4749 index 2797163..c2a401d 100644
4750 --- a/arch/frv/include/asm/cache.h
4751 +++ b/arch/frv/include/asm/cache.h
4752 @@ -12,10 +12,11 @@
4753 #ifndef __ASM_CACHE_H
4754 #define __ASM_CACHE_H
4755
4756 +#include <linux/const.h>
4757
4758 /* bytes per L1 cache line */
4759 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4760 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4761 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4762
4763 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4764 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4765 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4766 index 43901f2..0d8b865 100644
4767 --- a/arch/frv/include/asm/kmap_types.h
4768 +++ b/arch/frv/include/asm/kmap_types.h
4769 @@ -2,6 +2,6 @@
4770 #ifndef _ASM_KMAP_TYPES_H
4771 #define _ASM_KMAP_TYPES_H
4772
4773 -#define KM_TYPE_NR 17
4774 +#define KM_TYPE_NR 18
4775
4776 #endif
4777 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4778 index 385fd30..3aaf4fe 100644
4779 --- a/arch/frv/mm/elf-fdpic.c
4780 +++ b/arch/frv/mm/elf-fdpic.c
4781 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4782 {
4783 struct vm_area_struct *vma;
4784 unsigned long limit;
4785 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4786
4787 if (len > TASK_SIZE)
4788 return -ENOMEM;
4789 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4790 if (addr) {
4791 addr = PAGE_ALIGN(addr);
4792 vma = find_vma(current->mm, addr);
4793 - if (TASK_SIZE - len >= addr &&
4794 - (!vma || addr + len <= vma->vm_start))
4795 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4796 goto success;
4797 }
4798
4799 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4800 for (; vma; vma = vma->vm_next) {
4801 if (addr > limit)
4802 break;
4803 - if (addr + len <= vma->vm_start)
4804 + if (check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 addr = vma->vm_end;
4807 }
4808 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 for (; vma; vma = vma->vm_next) {
4810 if (addr > limit)
4811 break;
4812 - if (addr + len <= vma->vm_start)
4813 + if (check_heap_stack_gap(vma, addr, len, offset))
4814 goto success;
4815 addr = vma->vm_end;
4816 }
4817 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4818 index f4ca594..adc72fd6 100644
4819 --- a/arch/hexagon/include/asm/cache.h
4820 +++ b/arch/hexagon/include/asm/cache.h
4821 @@ -21,9 +21,11 @@
4822 #ifndef __ASM_CACHE_H
4823 #define __ASM_CACHE_H
4824
4825 +#include <linux/const.h>
4826 +
4827 /* Bytes per L1 cache line */
4828 -#define L1_CACHE_SHIFT (5)
4829 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4830 +#define L1_CACHE_SHIFT 5
4831 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4832
4833 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4835 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4836 index 6e6fe18..a6ae668 100644
4837 --- a/arch/ia64/include/asm/atomic.h
4838 +++ b/arch/ia64/include/asm/atomic.h
4839 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4840 #define atomic64_inc(v) atomic64_add(1, (v))
4841 #define atomic64_dec(v) atomic64_sub(1, (v))
4842
4843 +#define atomic64_read_unchecked(v) atomic64_read(v)
4844 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4845 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4846 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4847 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4848 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4849 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4850 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4851 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4852 +
4853 /* Atomic operations are already serializing */
4854 #define smp_mb__before_atomic_dec() barrier()
4855 #define smp_mb__after_atomic_dec() barrier()
4856 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4857 index 988254a..e1ee885 100644
4858 --- a/arch/ia64/include/asm/cache.h
4859 +++ b/arch/ia64/include/asm/cache.h
4860 @@ -1,6 +1,7 @@
4861 #ifndef _ASM_IA64_CACHE_H
4862 #define _ASM_IA64_CACHE_H
4863
4864 +#include <linux/const.h>
4865
4866 /*
4867 * Copyright (C) 1998-2000 Hewlett-Packard Co
4868 @@ -9,7 +10,7 @@
4869
4870 /* Bytes per L1 (data) cache line. */
4871 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4872 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4873 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4874
4875 #ifdef CONFIG_SMP
4876 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4877 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4878 index b5298eb..67c6e62 100644
4879 --- a/arch/ia64/include/asm/elf.h
4880 +++ b/arch/ia64/include/asm/elf.h
4881 @@ -42,6 +42,13 @@
4882 */
4883 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4884
4885 +#ifdef CONFIG_PAX_ASLR
4886 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4887 +
4888 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4890 +#endif
4891 +
4892 #define PT_IA_64_UNWIND 0x70000001
4893
4894 /* IA-64 relocations: */
4895 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4896 index 96a8d92..617a1cf 100644
4897 --- a/arch/ia64/include/asm/pgalloc.h
4898 +++ b/arch/ia64/include/asm/pgalloc.h
4899 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4900 pgd_val(*pgd_entry) = __pa(pud);
4901 }
4902
4903 +static inline void
4904 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4905 +{
4906 + pgd_populate(mm, pgd_entry, pud);
4907 +}
4908 +
4909 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4910 {
4911 return quicklist_alloc(0, GFP_KERNEL, NULL);
4912 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4913 pud_val(*pud_entry) = __pa(pmd);
4914 }
4915
4916 +static inline void
4917 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4918 +{
4919 + pud_populate(mm, pud_entry, pmd);
4920 +}
4921 +
4922 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4923 {
4924 return quicklist_alloc(0, GFP_KERNEL, NULL);
4925 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4926 index 815810c..d60bd4c 100644
4927 --- a/arch/ia64/include/asm/pgtable.h
4928 +++ b/arch/ia64/include/asm/pgtable.h
4929 @@ -12,7 +12,7 @@
4930 * David Mosberger-Tang <davidm@hpl.hp.com>
4931 */
4932
4933 -
4934 +#include <linux/const.h>
4935 #include <asm/mman.h>
4936 #include <asm/page.h>
4937 #include <asm/processor.h>
4938 @@ -142,6 +142,17 @@
4939 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4941 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4942 +
4943 +#ifdef CONFIG_PAX_PAGEEXEC
4944 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4945 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4947 +#else
4948 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4949 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4950 +# define PAGE_COPY_NOEXEC PAGE_COPY
4951 +#endif
4952 +
4953 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4954 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4955 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4956 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4957 index 54ff557..70c88b7 100644
4958 --- a/arch/ia64/include/asm/spinlock.h
4959 +++ b/arch/ia64/include/asm/spinlock.h
4960 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4961 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4962
4963 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4964 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4965 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4966 }
4967
4968 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4969 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4970 index 449c8c0..18965fb 100644
4971 --- a/arch/ia64/include/asm/uaccess.h
4972 +++ b/arch/ia64/include/asm/uaccess.h
4973 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4974 static inline unsigned long
4975 __copy_to_user (void __user *to, const void *from, unsigned long count)
4976 {
4977 + if (count > INT_MAX)
4978 + return count;
4979 +
4980 + if (!__builtin_constant_p(count))
4981 + check_object_size(from, count, true);
4982 +
4983 return __copy_user(to, (__force void __user *) from, count);
4984 }
4985
4986 static inline unsigned long
4987 __copy_from_user (void *to, const void __user *from, unsigned long count)
4988 {
4989 + if (count > INT_MAX)
4990 + return count;
4991 +
4992 + if (!__builtin_constant_p(count))
4993 + check_object_size(to, count, false);
4994 +
4995 return __copy_user((__force void __user *) to, from, count);
4996 }
4997
4998 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4999 ({ \
5000 void __user *__cu_to = (to); \
5001 const void *__cu_from = (from); \
5002 - long __cu_len = (n); \
5003 + unsigned long __cu_len = (n); \
5004 \
5005 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5006 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5007 + if (!__builtin_constant_p(n)) \
5008 + check_object_size(__cu_from, __cu_len, true); \
5009 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5010 + } \
5011 __cu_len; \
5012 })
5013
5014 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5015 ({ \
5016 void *__cu_to = (to); \
5017 const void __user *__cu_from = (from); \
5018 - long __cu_len = (n); \
5019 + unsigned long __cu_len = (n); \
5020 \
5021 __chk_user_ptr(__cu_from); \
5022 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5023 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5024 + if (!__builtin_constant_p(n)) \
5025 + check_object_size(__cu_to, __cu_len, false); \
5026 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5027 + } \
5028 __cu_len; \
5029 })
5030
5031 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5032 index 2d67317..07d8bfa 100644
5033 --- a/arch/ia64/kernel/err_inject.c
5034 +++ b/arch/ia64/kernel/err_inject.c
5035 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5036 return NOTIFY_OK;
5037 }
5038
5039 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5040 +static struct notifier_block err_inject_cpu_notifier =
5041 {
5042 .notifier_call = err_inject_cpu_callback,
5043 };
5044 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5045 index d7396db..b33e873 100644
5046 --- a/arch/ia64/kernel/mca.c
5047 +++ b/arch/ia64/kernel/mca.c
5048 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5049 return NOTIFY_OK;
5050 }
5051
5052 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5053 +static struct notifier_block mca_cpu_notifier = {
5054 .notifier_call = mca_cpu_callback
5055 };
5056
5057 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5058 index 24603be..948052d 100644
5059 --- a/arch/ia64/kernel/module.c
5060 +++ b/arch/ia64/kernel/module.c
5061 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5062 void
5063 module_free (struct module *mod, void *module_region)
5064 {
5065 - if (mod && mod->arch.init_unw_table &&
5066 - module_region == mod->module_init) {
5067 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5068 unw_remove_unwind_table(mod->arch.init_unw_table);
5069 mod->arch.init_unw_table = NULL;
5070 }
5071 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5072 }
5073
5074 static inline int
5075 +in_init_rx (const struct module *mod, uint64_t addr)
5076 +{
5077 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5078 +}
5079 +
5080 +static inline int
5081 +in_init_rw (const struct module *mod, uint64_t addr)
5082 +{
5083 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5084 +}
5085 +
5086 +static inline int
5087 in_init (const struct module *mod, uint64_t addr)
5088 {
5089 - return addr - (uint64_t) mod->module_init < mod->init_size;
5090 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5091 +}
5092 +
5093 +static inline int
5094 +in_core_rx (const struct module *mod, uint64_t addr)
5095 +{
5096 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5097 +}
5098 +
5099 +static inline int
5100 +in_core_rw (const struct module *mod, uint64_t addr)
5101 +{
5102 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5103 }
5104
5105 static inline int
5106 in_core (const struct module *mod, uint64_t addr)
5107 {
5108 - return addr - (uint64_t) mod->module_core < mod->core_size;
5109 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5110 }
5111
5112 static inline int
5113 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5114 break;
5115
5116 case RV_BDREL:
5117 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5118 + if (in_init_rx(mod, val))
5119 + val -= (uint64_t) mod->module_init_rx;
5120 + else if (in_init_rw(mod, val))
5121 + val -= (uint64_t) mod->module_init_rw;
5122 + else if (in_core_rx(mod, val))
5123 + val -= (uint64_t) mod->module_core_rx;
5124 + else if (in_core_rw(mod, val))
5125 + val -= (uint64_t) mod->module_core_rw;
5126 break;
5127
5128 case RV_LTV:
5129 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5130 * addresses have been selected...
5131 */
5132 uint64_t gp;
5133 - if (mod->core_size > MAX_LTOFF)
5134 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5135 /*
5136 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5137 * at the end of the module.
5138 */
5139 - gp = mod->core_size - MAX_LTOFF / 2;
5140 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5141 else
5142 - gp = mod->core_size / 2;
5143 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5144 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5145 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5146 mod->arch.gp = gp;
5147 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5148 }
5149 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5150 index 77597e5..189dd62f 100644
5151 --- a/arch/ia64/kernel/palinfo.c
5152 +++ b/arch/ia64/kernel/palinfo.c
5153 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5154 struct proc_dir_entry **pdir;
5155 struct proc_dir_entry *cpu_dir;
5156 int j;
5157 - char cpustr[sizeof(CPUSTR)];
5158 + char cpustr[3+4+1];
5159
5160
5161 /*
5162 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5163 return NOTIFY_OK;
5164 }
5165
5166 -static struct notifier_block __refdata palinfo_cpu_notifier =
5167 +static struct notifier_block palinfo_cpu_notifier =
5168 {
5169 .notifier_call = palinfo_cpu_callback,
5170 .priority = 0,
5171 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5172 index 79802e5..1a89ec5 100644
5173 --- a/arch/ia64/kernel/salinfo.c
5174 +++ b/arch/ia64/kernel/salinfo.c
5175 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5176 return NOTIFY_OK;
5177 }
5178
5179 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5180 +static struct notifier_block salinfo_cpu_notifier =
5181 {
5182 .notifier_call = salinfo_cpu_callback,
5183 .priority = 0,
5184 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5185 index d9439ef..d0cac6b 100644
5186 --- a/arch/ia64/kernel/sys_ia64.c
5187 +++ b/arch/ia64/kernel/sys_ia64.c
5188 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5189 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5190 struct mm_struct *mm = current->mm;
5191 struct vm_area_struct *vma;
5192 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5193
5194 if (len > RGN_MAP_LIMIT)
5195 return -ENOMEM;
5196 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5197 if (REGION_NUMBER(addr) == RGN_HPAGE)
5198 addr = 0;
5199 #endif
5200 +
5201 +#ifdef CONFIG_PAX_RANDMMAP
5202 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5203 + addr = mm->free_area_cache;
5204 + else
5205 +#endif
5206 +
5207 if (!addr)
5208 addr = mm->free_area_cache;
5209
5210 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5211 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5212 /* At this point: (!vma || addr < vma->vm_end). */
5213 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5214 - if (start_addr != TASK_UNMAPPED_BASE) {
5215 + if (start_addr != mm->mmap_base) {
5216 /* Start a new search --- just in case we missed some holes. */
5217 - addr = TASK_UNMAPPED_BASE;
5218 + addr = mm->mmap_base;
5219 goto full_search;
5220 }
5221 return -ENOMEM;
5222 }
5223 - if (!vma || addr + len <= vma->vm_start) {
5224 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5225 /* Remember the address where we stopped this search: */
5226 mm->free_area_cache = addr + len;
5227 return addr;
5228 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5229 index dc00b2c..cce53c2 100644
5230 --- a/arch/ia64/kernel/topology.c
5231 +++ b/arch/ia64/kernel/topology.c
5232 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5233 return NOTIFY_OK;
5234 }
5235
5236 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5237 +static struct notifier_block cache_cpu_notifier =
5238 {
5239 .notifier_call = cache_cpu_callback
5240 };
5241 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5242 index 0ccb28f..8992469 100644
5243 --- a/arch/ia64/kernel/vmlinux.lds.S
5244 +++ b/arch/ia64/kernel/vmlinux.lds.S
5245 @@ -198,7 +198,7 @@ SECTIONS {
5246 /* Per-cpu data: */
5247 . = ALIGN(PERCPU_PAGE_SIZE);
5248 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5249 - __phys_per_cpu_start = __per_cpu_load;
5250 + __phys_per_cpu_start = per_cpu_load;
5251 /*
5252 * ensure percpu data fits
5253 * into percpu page size
5254 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5255 index 6cf0341..d352594 100644
5256 --- a/arch/ia64/mm/fault.c
5257 +++ b/arch/ia64/mm/fault.c
5258 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5259 return pte_present(pte);
5260 }
5261
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5264 +{
5265 + unsigned long i;
5266 +
5267 + printk(KERN_ERR "PAX: bytes at PC: ");
5268 + for (i = 0; i < 8; i++) {
5269 + unsigned int c;
5270 + if (get_user(c, (unsigned int *)pc+i))
5271 + printk(KERN_CONT "???????? ");
5272 + else
5273 + printk(KERN_CONT "%08x ", c);
5274 + }
5275 + printk("\n");
5276 +}
5277 +#endif
5278 +
5279 # define VM_READ_BIT 0
5280 # define VM_WRITE_BIT 1
5281 # define VM_EXEC_BIT 2
5282 @@ -149,8 +166,21 @@ retry:
5283 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5284 goto bad_area;
5285
5286 - if ((vma->vm_flags & mask) != mask)
5287 + if ((vma->vm_flags & mask) != mask) {
5288 +
5289 +#ifdef CONFIG_PAX_PAGEEXEC
5290 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5291 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5292 + goto bad_area;
5293 +
5294 + up_read(&mm->mmap_sem);
5295 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5296 + do_group_exit(SIGKILL);
5297 + }
5298 +#endif
5299 +
5300 goto bad_area;
5301 + }
5302
5303 /*
5304 * If for any reason at all we couldn't handle the fault, make
5305 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5306 index 5ca674b..127c3cb 100644
5307 --- a/arch/ia64/mm/hugetlbpage.c
5308 +++ b/arch/ia64/mm/hugetlbpage.c
5309 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5310 unsigned long pgoff, unsigned long flags)
5311 {
5312 struct vm_area_struct *vmm;
5313 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5314
5315 if (len > RGN_MAP_LIMIT)
5316 return -ENOMEM;
5317 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5318 /* At this point: (!vmm || addr < vmm->vm_end). */
5319 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5320 return -ENOMEM;
5321 - if (!vmm || (addr + len) <= vmm->vm_start)
5322 + if (check_heap_stack_gap(vmm, addr, len, offset))
5323 return addr;
5324 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5325 }
5326 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5327 index b755ea9..b9a969e 100644
5328 --- a/arch/ia64/mm/init.c
5329 +++ b/arch/ia64/mm/init.c
5330 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5331 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5332 vma->vm_end = vma->vm_start + PAGE_SIZE;
5333 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5334 +
5335 +#ifdef CONFIG_PAX_PAGEEXEC
5336 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5337 + vma->vm_flags &= ~VM_EXEC;
5338 +
5339 +#ifdef CONFIG_PAX_MPROTECT
5340 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5341 + vma->vm_flags &= ~VM_MAYEXEC;
5342 +#endif
5343 +
5344 + }
5345 +#endif
5346 +
5347 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5348 down_write(&current->mm->mmap_sem);
5349 if (insert_vm_struct(current->mm, vma)) {
5350 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5351 index 40b3ee9..8c2c112 100644
5352 --- a/arch/m32r/include/asm/cache.h
5353 +++ b/arch/m32r/include/asm/cache.h
5354 @@ -1,8 +1,10 @@
5355 #ifndef _ASM_M32R_CACHE_H
5356 #define _ASM_M32R_CACHE_H
5357
5358 +#include <linux/const.h>
5359 +
5360 /* L1 cache line size */
5361 #define L1_CACHE_SHIFT 4
5362 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5363 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5364
5365 #endif /* _ASM_M32R_CACHE_H */
5366 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5367 index 82abd15..d95ae5d 100644
5368 --- a/arch/m32r/lib/usercopy.c
5369 +++ b/arch/m32r/lib/usercopy.c
5370 @@ -14,6 +14,9 @@
5371 unsigned long
5372 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5373 {
5374 + if ((long)n < 0)
5375 + return n;
5376 +
5377 prefetch(from);
5378 if (access_ok(VERIFY_WRITE, to, n))
5379 __copy_user(to,from,n);
5380 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5381 unsigned long
5382 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5383 {
5384 + if ((long)n < 0)
5385 + return n;
5386 +
5387 prefetchw(to);
5388 if (access_ok(VERIFY_READ, from, n))
5389 __copy_user_zeroing(to,from,n);
5390 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5391 index 0395c51..5f26031 100644
5392 --- a/arch/m68k/include/asm/cache.h
5393 +++ b/arch/m68k/include/asm/cache.h
5394 @@ -4,9 +4,11 @@
5395 #ifndef __ARCH_M68K_CACHE_H
5396 #define __ARCH_M68K_CACHE_H
5397
5398 +#include <linux/const.h>
5399 +
5400 /* bytes per L1 cache line */
5401 #define L1_CACHE_SHIFT 4
5402 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5403 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5404
5405 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5406
5407 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5408 index 4efe96a..60e8699 100644
5409 --- a/arch/microblaze/include/asm/cache.h
5410 +++ b/arch/microblaze/include/asm/cache.h
5411 @@ -13,11 +13,12 @@
5412 #ifndef _ASM_MICROBLAZE_CACHE_H
5413 #define _ASM_MICROBLAZE_CACHE_H
5414
5415 +#include <linux/const.h>
5416 #include <asm/registers.h>
5417
5418 #define L1_CACHE_SHIFT 5
5419 /* word-granular cache in microblaze */
5420 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5421 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5422
5423 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5424
5425 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5426 index 01cc6ba..bcb7a5d 100644
5427 --- a/arch/mips/include/asm/atomic.h
5428 +++ b/arch/mips/include/asm/atomic.h
5429 @@ -21,6 +21,10 @@
5430 #include <asm/cmpxchg.h>
5431 #include <asm/war.h>
5432
5433 +#ifdef CONFIG_GENERIC_ATOMIC64
5434 +#include <asm-generic/atomic64.h>
5435 +#endif
5436 +
5437 #define ATOMIC_INIT(i) { (i) }
5438
5439 /*
5440 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5441 */
5442 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5443
5444 +#define atomic64_read_unchecked(v) atomic64_read(v)
5445 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5446 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5447 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5448 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5449 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5450 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5451 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5452 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5453 +
5454 #endif /* CONFIG_64BIT */
5455
5456 /*
5457 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5458 index b4db69f..8f3b093 100644
5459 --- a/arch/mips/include/asm/cache.h
5460 +++ b/arch/mips/include/asm/cache.h
5461 @@ -9,10 +9,11 @@
5462 #ifndef _ASM_CACHE_H
5463 #define _ASM_CACHE_H
5464
5465 +#include <linux/const.h>
5466 #include <kmalloc.h>
5467
5468 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5469 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5470 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5471
5472 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5473 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5474 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5475 index 455c0ac..ad65fbe 100644
5476 --- a/arch/mips/include/asm/elf.h
5477 +++ b/arch/mips/include/asm/elf.h
5478 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5479 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5480 #endif
5481
5482 +#ifdef CONFIG_PAX_ASLR
5483 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5484 +
5485 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5486 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5487 +#endif
5488 +
5489 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5490 struct linux_binprm;
5491 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5492 int uses_interp);
5493
5494 -struct mm_struct;
5495 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5496 -#define arch_randomize_brk arch_randomize_brk
5497 -
5498 #endif /* _ASM_ELF_H */
5499 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5500 index c1f6afa..38cc6e9 100644
5501 --- a/arch/mips/include/asm/exec.h
5502 +++ b/arch/mips/include/asm/exec.h
5503 @@ -12,6 +12,6 @@
5504 #ifndef _ASM_EXEC_H
5505 #define _ASM_EXEC_H
5506
5507 -extern unsigned long arch_align_stack(unsigned long sp);
5508 +#define arch_align_stack(x) ((x) & ~0xfUL)
5509
5510 #endif /* _ASM_EXEC_H */
5511 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5512 index 21bff32..9f0c3b8 100644
5513 --- a/arch/mips/include/asm/page.h
5514 +++ b/arch/mips/include/asm/page.h
5515 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5516 #ifdef CONFIG_CPU_MIPS32
5517 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5518 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5519 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5520 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5521 #else
5522 typedef struct { unsigned long long pte; } pte_t;
5523 #define pte_val(x) ((x).pte)
5524 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5525 index 881d18b..cea38bc 100644
5526 --- a/arch/mips/include/asm/pgalloc.h
5527 +++ b/arch/mips/include/asm/pgalloc.h
5528 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5529 {
5530 set_pud(pud, __pud((unsigned long)pmd));
5531 }
5532 +
5533 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5534 +{
5535 + pud_populate(mm, pud, pmd);
5536 +}
5537 #endif
5538
5539 /*
5540 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5541 index b2050b9..d71bb1b 100644
5542 --- a/arch/mips/include/asm/thread_info.h
5543 +++ b/arch/mips/include/asm/thread_info.h
5544 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5545 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5546 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5547 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5548 +/* li takes a 32bit immediate */
5549 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5550 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5551
5552 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5553 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5554 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5555 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5556 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5557 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5558 +
5559 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5560
5561 /* work to do in syscall_trace_leave() */
5562 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5563 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5564
5565 /* work to do on interrupt/exception return */
5566 #define _TIF_WORK_MASK \
5567 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5568 /* work to do on any return to u-space */
5569 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5570 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5571
5572 #endif /* __KERNEL__ */
5573
5574 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5575 index 9fdd8bc..4bd7f1a 100644
5576 --- a/arch/mips/kernel/binfmt_elfn32.c
5577 +++ b/arch/mips/kernel/binfmt_elfn32.c
5578 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5579 #undef ELF_ET_DYN_BASE
5580 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5581
5582 +#ifdef CONFIG_PAX_ASLR
5583 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5584 +
5585 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5586 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5587 +#endif
5588 +
5589 #include <asm/processor.h>
5590 #include <linux/module.h>
5591 #include <linux/elfcore.h>
5592 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5593 index ff44823..97f8906 100644
5594 --- a/arch/mips/kernel/binfmt_elfo32.c
5595 +++ b/arch/mips/kernel/binfmt_elfo32.c
5596 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5597 #undef ELF_ET_DYN_BASE
5598 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5599
5600 +#ifdef CONFIG_PAX_ASLR
5601 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5602 +
5603 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5604 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5605 +#endif
5606 +
5607 #include <asm/processor.h>
5608
5609 /*
5610 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5611 index a11c6f9..be5e164 100644
5612 --- a/arch/mips/kernel/process.c
5613 +++ b/arch/mips/kernel/process.c
5614 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5615 out:
5616 return pc;
5617 }
5618 -
5619 -/*
5620 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5621 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5622 - */
5623 -unsigned long arch_align_stack(unsigned long sp)
5624 -{
5625 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5626 - sp -= get_random_int() & ~PAGE_MASK;
5627 -
5628 - return sp & ALMASK;
5629 -}
5630 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5631 index 4812c6d..2069554 100644
5632 --- a/arch/mips/kernel/ptrace.c
5633 +++ b/arch/mips/kernel/ptrace.c
5634 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5635 return arch;
5636 }
5637
5638 +#ifdef CONFIG_GRKERNSEC_SETXID
5639 +extern void gr_delayed_cred_worker(void);
5640 +#endif
5641 +
5642 /*
5643 * Notification of system call entry/exit
5644 * - triggered by current->work.syscall_trace
5645 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5646 /* do the secure computing check first */
5647 secure_computing_strict(regs->regs[2]);
5648
5649 +#ifdef CONFIG_GRKERNSEC_SETXID
5650 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5651 + gr_delayed_cred_worker();
5652 +#endif
5653 +
5654 if (!(current->ptrace & PT_PTRACED))
5655 goto out;
5656
5657 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5658 index d20a4bc..7096ae5 100644
5659 --- a/arch/mips/kernel/scall32-o32.S
5660 +++ b/arch/mips/kernel/scall32-o32.S
5661 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5662
5663 stack_done:
5664 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5665 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5666 + li t1, _TIF_SYSCALL_WORK
5667 and t0, t1
5668 bnez t0, syscall_trace_entry # -> yes
5669
5670 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5671 index b64f642..0fe6eab 100644
5672 --- a/arch/mips/kernel/scall64-64.S
5673 +++ b/arch/mips/kernel/scall64-64.S
5674 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5675
5676 sd a3, PT_R26(sp) # save a3 for syscall restarting
5677
5678 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5679 + li t1, _TIF_SYSCALL_WORK
5680 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5681 and t0, t1, t0
5682 bnez t0, syscall_trace_entry
5683 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5684 index c29ac19..c592d05 100644
5685 --- a/arch/mips/kernel/scall64-n32.S
5686 +++ b/arch/mips/kernel/scall64-n32.S
5687 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5688
5689 sd a3, PT_R26(sp) # save a3 for syscall restarting
5690
5691 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5692 + li t1, _TIF_SYSCALL_WORK
5693 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5694 and t0, t1, t0
5695 bnez t0, n32_syscall_trace_entry
5696 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5697 index cf3e75e..72e93fe 100644
5698 --- a/arch/mips/kernel/scall64-o32.S
5699 +++ b/arch/mips/kernel/scall64-o32.S
5700 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5701 PTR 4b, bad_stack
5702 .previous
5703
5704 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5705 + li t1, _TIF_SYSCALL_WORK
5706 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5707 and t0, t1, t0
5708 bnez t0, trace_a_syscall
5709 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5710 index ddcec1e..c7f983e 100644
5711 --- a/arch/mips/mm/fault.c
5712 +++ b/arch/mips/mm/fault.c
5713 @@ -27,6 +27,23 @@
5714 #include <asm/highmem.h> /* For VMALLOC_END */
5715 #include <linux/kdebug.h>
5716
5717 +#ifdef CONFIG_PAX_PAGEEXEC
5718 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5719 +{
5720 + unsigned long i;
5721 +
5722 + printk(KERN_ERR "PAX: bytes at PC: ");
5723 + for (i = 0; i < 5; i++) {
5724 + unsigned int c;
5725 + if (get_user(c, (unsigned int *)pc+i))
5726 + printk(KERN_CONT "???????? ");
5727 + else
5728 + printk(KERN_CONT "%08x ", c);
5729 + }
5730 + printk("\n");
5731 +}
5732 +#endif
5733 +
5734 /*
5735 * This routine handles page faults. It determines the address,
5736 * and the problem, and then passes it off to one of the appropriate
5737 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5738 index 7e5fe27..479a219 100644
5739 --- a/arch/mips/mm/mmap.c
5740 +++ b/arch/mips/mm/mmap.c
5741 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5742 struct vm_area_struct *vma;
5743 unsigned long addr = addr0;
5744 int do_color_align;
5745 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5746 struct vm_unmapped_area_info info;
5747
5748 if (unlikely(len > TASK_SIZE))
5749 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5750 do_color_align = 1;
5751
5752 /* requesting a specific address */
5753 +
5754 +#ifdef CONFIG_PAX_RANDMMAP
5755 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5756 +#endif
5757 +
5758 if (addr) {
5759 if (do_color_align)
5760 addr = COLOUR_ALIGN(addr, pgoff);
5761 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5762 addr = PAGE_ALIGN(addr);
5763
5764 vma = find_vma(mm, addr);
5765 - if (TASK_SIZE - len >= addr &&
5766 - (!vma || addr + len <= vma->vm_start))
5767 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5768 return addr;
5769 }
5770
5771 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5772 {
5773 unsigned long random_factor = 0UL;
5774
5775 +#ifdef CONFIG_PAX_RANDMMAP
5776 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5777 +#endif
5778 +
5779 if (current->flags & PF_RANDOMIZE) {
5780 random_factor = get_random_int();
5781 random_factor = random_factor << PAGE_SHIFT;
5782 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5783
5784 if (mmap_is_legacy()) {
5785 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5786 +
5787 +#ifdef CONFIG_PAX_RANDMMAP
5788 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5789 + mm->mmap_base += mm->delta_mmap;
5790 +#endif
5791 +
5792 mm->get_unmapped_area = arch_get_unmapped_area;
5793 mm->unmap_area = arch_unmap_area;
5794 } else {
5795 mm->mmap_base = mmap_base(random_factor);
5796 +
5797 +#ifdef CONFIG_PAX_RANDMMAP
5798 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5799 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5800 +#endif
5801 +
5802 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5803 mm->unmap_area = arch_unmap_area_topdown;
5804 }
5805 }
5806
5807 -static inline unsigned long brk_rnd(void)
5808 -{
5809 - unsigned long rnd = get_random_int();
5810 -
5811 - rnd = rnd << PAGE_SHIFT;
5812 - /* 8MB for 32bit, 256MB for 64bit */
5813 - if (TASK_IS_32BIT_ADDR)
5814 - rnd = rnd & 0x7ffffful;
5815 - else
5816 - rnd = rnd & 0xffffffful;
5817 -
5818 - return rnd;
5819 -}
5820 -
5821 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5822 -{
5823 - unsigned long base = mm->brk;
5824 - unsigned long ret;
5825 -
5826 - ret = PAGE_ALIGN(base + brk_rnd());
5827 -
5828 - if (ret < mm->brk)
5829 - return mm->brk;
5830 -
5831 - return ret;
5832 -}
5833 -
5834 int __virt_addr_valid(const volatile void *kaddr)
5835 {
5836 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5837 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5838 index 967d144..db12197 100644
5839 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5840 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5841 @@ -11,12 +11,14 @@
5842 #ifndef _ASM_PROC_CACHE_H
5843 #define _ASM_PROC_CACHE_H
5844
5845 +#include <linux/const.h>
5846 +
5847 /* L1 cache */
5848
5849 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5850 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5851 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5852 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5853 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5854 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5855
5856 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5857 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5858 index bcb5df2..84fabd2 100644
5859 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5860 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5861 @@ -16,13 +16,15 @@
5862 #ifndef _ASM_PROC_CACHE_H
5863 #define _ASM_PROC_CACHE_H
5864
5865 +#include <linux/const.h>
5866 +
5867 /*
5868 * L1 cache
5869 */
5870 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5871 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5872 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5873 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5874 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5875 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5876
5877 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5878 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5879 index 4ce7a01..449202a 100644
5880 --- a/arch/openrisc/include/asm/cache.h
5881 +++ b/arch/openrisc/include/asm/cache.h
5882 @@ -19,11 +19,13 @@
5883 #ifndef __ASM_OPENRISC_CACHE_H
5884 #define __ASM_OPENRISC_CACHE_H
5885
5886 +#include <linux/const.h>
5887 +
5888 /* FIXME: How can we replace these with values from the CPU...
5889 * they shouldn't be hard-coded!
5890 */
5891
5892 -#define L1_CACHE_BYTES 16
5893 #define L1_CACHE_SHIFT 4
5894 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5895
5896 #endif /* __ASM_OPENRISC_CACHE_H */
5897 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5898 index af9cf30..2aae9b2 100644
5899 --- a/arch/parisc/include/asm/atomic.h
5900 +++ b/arch/parisc/include/asm/atomic.h
5901 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5902
5903 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5904
5905 +#define atomic64_read_unchecked(v) atomic64_read(v)
5906 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5907 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5908 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5909 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5910 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5911 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5912 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5913 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5914 +
5915 #endif /* !CONFIG_64BIT */
5916
5917
5918 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5919 index 47f11c7..3420df2 100644
5920 --- a/arch/parisc/include/asm/cache.h
5921 +++ b/arch/parisc/include/asm/cache.h
5922 @@ -5,6 +5,7 @@
5923 #ifndef __ARCH_PARISC_CACHE_H
5924 #define __ARCH_PARISC_CACHE_H
5925
5926 +#include <linux/const.h>
5927
5928 /*
5929 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5930 @@ -15,13 +16,13 @@
5931 * just ruin performance.
5932 */
5933 #ifdef CONFIG_PA20
5934 -#define L1_CACHE_BYTES 64
5935 #define L1_CACHE_SHIFT 6
5936 #else
5937 -#define L1_CACHE_BYTES 32
5938 #define L1_CACHE_SHIFT 5
5939 #endif
5940
5941 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5942 +
5943 #ifndef __ASSEMBLY__
5944
5945 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5946 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5947 index 19f6cb1..6c78cf2 100644
5948 --- a/arch/parisc/include/asm/elf.h
5949 +++ b/arch/parisc/include/asm/elf.h
5950 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5951
5952 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5953
5954 +#ifdef CONFIG_PAX_ASLR
5955 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5956 +
5957 +#define PAX_DELTA_MMAP_LEN 16
5958 +#define PAX_DELTA_STACK_LEN 16
5959 +#endif
5960 +
5961 /* This yields a mask that user programs can use to figure out what
5962 instruction set this CPU supports. This could be done in user space,
5963 but it's not easy, and we've already done it here. */
5964 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5965 index fc987a1..6e068ef 100644
5966 --- a/arch/parisc/include/asm/pgalloc.h
5967 +++ b/arch/parisc/include/asm/pgalloc.h
5968 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5969 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5970 }
5971
5972 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5973 +{
5974 + pgd_populate(mm, pgd, pmd);
5975 +}
5976 +
5977 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5978 {
5979 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5980 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5981 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5982 #define pmd_free(mm, x) do { } while (0)
5983 #define pgd_populate(mm, pmd, pte) BUG()
5984 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5985
5986 #endif
5987
5988 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5989 index 7df49fa..a3eb445 100644
5990 --- a/arch/parisc/include/asm/pgtable.h
5991 +++ b/arch/parisc/include/asm/pgtable.h
5992 @@ -16,6 +16,8 @@
5993 #include <asm/processor.h>
5994 #include <asm/cache.h>
5995
5996 +extern spinlock_t pa_dbit_lock;
5997 +
5998 /*
5999 * kern_addr_valid(ADDR) tests if ADDR is pointing to valid kernel
6000 * memory. For the return value to be meaningful, ADDR must be >=
6001 @@ -44,8 +46,11 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6002
6003 #define set_pte_at(mm, addr, ptep, pteval) \
6004 do { \
6005 + unsigned long flags; \
6006 + spin_lock_irqsave(&pa_dbit_lock, flags); \
6007 set_pte(ptep, pteval); \
6008 purge_tlb_entries(mm, addr); \
6009 + spin_unlock_irqrestore(&pa_dbit_lock, flags); \
6010 } while (0)
6011
6012 #endif /* !__ASSEMBLY__ */
6013 @@ -218,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6014 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6015 #define PAGE_COPY PAGE_EXECREAD
6016 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6017 +
6018 +#ifdef CONFIG_PAX_PAGEEXEC
6019 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6020 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6021 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6022 +#else
6023 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6024 +# define PAGE_COPY_NOEXEC PAGE_COPY
6025 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6026 +#endif
6027 +
6028 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6029 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6030 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6031 @@ -435,48 +451,46 @@ extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t *);
6032
6033 static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
6034 {
6035 -#ifdef CONFIG_SMP
6036 + pte_t pte;
6037 + unsigned long flags;
6038 +
6039 if (!pte_young(*ptep))
6040 return 0;
6041 - return test_and_clear_bit(xlate_pabit(_PAGE_ACCESSED_BIT), &pte_val(*ptep));
6042 -#else
6043 - pte_t pte = *ptep;
6044 - if (!pte_young(pte))
6045 +
6046 + spin_lock_irqsave(&pa_dbit_lock, flags);
6047 + pte = *ptep;
6048 + if (!pte_young(pte)) {
6049 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6050 return 0;
6051 - set_pte_at(vma->vm_mm, addr, ptep, pte_mkold(pte));
6052 + }
6053 + set_pte(ptep, pte_mkold(pte));
6054 + purge_tlb_entries(vma->vm_mm, addr);
6055 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6056 return 1;
6057 -#endif
6058 }
6059
6060 -extern spinlock_t pa_dbit_lock;
6061 -
6062 struct mm_struct;
6063 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6064 {
6065 pte_t old_pte;
6066 + unsigned long flags;
6067
6068 - spin_lock(&pa_dbit_lock);
6069 + spin_lock_irqsave(&pa_dbit_lock, flags);
6070 old_pte = *ptep;
6071 pte_clear(mm,addr,ptep);
6072 - spin_unlock(&pa_dbit_lock);
6073 + purge_tlb_entries(mm, addr);
6074 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6075
6076 return old_pte;
6077 }
6078
6079 static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
6080 {
6081 -#ifdef CONFIG_SMP
6082 - unsigned long new, old;
6083 -
6084 - do {
6085 - old = pte_val(*ptep);
6086 - new = pte_val(pte_wrprotect(__pte (old)));
6087 - } while (cmpxchg((unsigned long *) ptep, old, new) != old);
6088 + unsigned long flags;
6089 + spin_lock_irqsave(&pa_dbit_lock, flags);
6090 + set_pte(ptep, pte_wrprotect(*ptep));
6091 purge_tlb_entries(mm, addr);
6092 -#else
6093 - pte_t old_pte = *ptep;
6094 - set_pte_at(mm, addr, ptep, pte_wrprotect(old_pte));
6095 -#endif
6096 + spin_unlock_irqrestore(&pa_dbit_lock, flags);
6097 }
6098
6099 #define pte_same(A,B) (pte_val(A) == pte_val(B))
6100 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6101 index 4ba2c93..f5e3974 100644
6102 --- a/arch/parisc/include/asm/uaccess.h
6103 +++ b/arch/parisc/include/asm/uaccess.h
6104 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6105 const void __user *from,
6106 unsigned long n)
6107 {
6108 - int sz = __compiletime_object_size(to);
6109 + size_t sz = __compiletime_object_size(to);
6110 int ret = -EFAULT;
6111
6112 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6113 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6114 ret = __copy_from_user(to, from, n);
6115 else
6116 copy_from_user_overflow();
6117 diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c
6118 index b89a85a..a9891fa 100644
6119 --- a/arch/parisc/kernel/cache.c
6120 +++ b/arch/parisc/kernel/cache.c
6121 @@ -426,14 +426,11 @@ void purge_tlb_entries(struct mm_struct *mm, unsigned long addr)
6122 /* Note: purge_tlb_entries can be called at startup with
6123 no context. */
6124
6125 - /* Disable preemption while we play with %sr1. */
6126 - preempt_disable();
6127 + purge_tlb_start(flags);
6128 mtsp(mm->context, 1);
6129 - purge_tlb_start(flags);
6130 pdtlb(addr);
6131 pitlb(addr);
6132 purge_tlb_end(flags);
6133 - preempt_enable();
6134 }
6135 EXPORT_SYMBOL(purge_tlb_entries);
6136
6137 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6138 index 2a625fb..9908930 100644
6139 --- a/arch/parisc/kernel/module.c
6140 +++ b/arch/parisc/kernel/module.c
6141 @@ -98,16 +98,38 @@
6142
6143 /* three functions to determine where in the module core
6144 * or init pieces the location is */
6145 +static inline int in_init_rx(struct module *me, void *loc)
6146 +{
6147 + return (loc >= me->module_init_rx &&
6148 + loc < (me->module_init_rx + me->init_size_rx));
6149 +}
6150 +
6151 +static inline int in_init_rw(struct module *me, void *loc)
6152 +{
6153 + return (loc >= me->module_init_rw &&
6154 + loc < (me->module_init_rw + me->init_size_rw));
6155 +}
6156 +
6157 static inline int in_init(struct module *me, void *loc)
6158 {
6159 - return (loc >= me->module_init &&
6160 - loc <= (me->module_init + me->init_size));
6161 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6162 +}
6163 +
6164 +static inline int in_core_rx(struct module *me, void *loc)
6165 +{
6166 + return (loc >= me->module_core_rx &&
6167 + loc < (me->module_core_rx + me->core_size_rx));
6168 +}
6169 +
6170 +static inline int in_core_rw(struct module *me, void *loc)
6171 +{
6172 + return (loc >= me->module_core_rw &&
6173 + loc < (me->module_core_rw + me->core_size_rw));
6174 }
6175
6176 static inline int in_core(struct module *me, void *loc)
6177 {
6178 - return (loc >= me->module_core &&
6179 - loc <= (me->module_core + me->core_size));
6180 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6181 }
6182
6183 static inline int in_local(struct module *me, void *loc)
6184 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6185 }
6186
6187 /* align things a bit */
6188 - me->core_size = ALIGN(me->core_size, 16);
6189 - me->arch.got_offset = me->core_size;
6190 - me->core_size += gots * sizeof(struct got_entry);
6191 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6192 + me->arch.got_offset = me->core_size_rw;
6193 + me->core_size_rw += gots * sizeof(struct got_entry);
6194
6195 - me->core_size = ALIGN(me->core_size, 16);
6196 - me->arch.fdesc_offset = me->core_size;
6197 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6198 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6199 + me->arch.fdesc_offset = me->core_size_rw;
6200 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6201
6202 me->arch.got_max = gots;
6203 me->arch.fdesc_max = fdescs;
6204 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6205
6206 BUG_ON(value == 0);
6207
6208 - got = me->module_core + me->arch.got_offset;
6209 + got = me->module_core_rw + me->arch.got_offset;
6210 for (i = 0; got[i].addr; i++)
6211 if (got[i].addr == value)
6212 goto out;
6213 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6214 #ifdef CONFIG_64BIT
6215 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6216 {
6217 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6218 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6219
6220 if (!value) {
6221 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6222 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6223
6224 /* Create new one */
6225 fdesc->addr = value;
6226 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6227 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6228 return (Elf_Addr)fdesc;
6229 }
6230 #endif /* CONFIG_64BIT */
6231 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6232
6233 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6234 end = table + sechdrs[me->arch.unwind_section].sh_size;
6235 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6236 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6237
6238 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6239 me->arch.unwind_section, table, end, gp);
6240 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6241 index f76c108..92bad82 100644
6242 --- a/arch/parisc/kernel/sys_parisc.c
6243 +++ b/arch/parisc/kernel/sys_parisc.c
6244 @@ -33,9 +33,11 @@
6245 #include <linux/utsname.h>
6246 #include <linux/personality.h>
6247
6248 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6249 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6250 + unsigned long flags)
6251 {
6252 struct vm_area_struct *vma;
6253 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6254
6255 addr = PAGE_ALIGN(addr);
6256
6257 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6258 /* At this point: (!vma || addr < vma->vm_end). */
6259 if (TASK_SIZE - len < addr)
6260 return -ENOMEM;
6261 - if (!vma || addr + len <= vma->vm_start)
6262 + if (check_heap_stack_gap(vma, addr, len, offset))
6263 return addr;
6264 addr = vma->vm_end;
6265 }
6266 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6267 return offset & 0x3FF000;
6268 }
6269
6270 -static unsigned long get_shared_area(struct address_space *mapping,
6271 - unsigned long addr, unsigned long len, unsigned long pgoff)
6272 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6273 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6274 {
6275 struct vm_area_struct *vma;
6276 int offset = mapping ? get_offset(mapping) : 0;
6277 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6278
6279 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6280
6281 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6282 /* At this point: (!vma || addr < vma->vm_end). */
6283 if (TASK_SIZE - len < addr)
6284 return -ENOMEM;
6285 - if (!vma || addr + len <= vma->vm_start)
6286 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6287 return addr;
6288 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6289 if (addr < vma->vm_end) /* handle wraparound */
6290 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6291 if (flags & MAP_FIXED)
6292 return addr;
6293 if (!addr)
6294 - addr = TASK_UNMAPPED_BASE;
6295 + addr = current->mm->mmap_base;
6296
6297 if (filp) {
6298 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6299 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6300 } else if(flags & MAP_SHARED) {
6301 - addr = get_shared_area(NULL, addr, len, pgoff);
6302 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6303 } else {
6304 - addr = get_unshared_area(addr, len);
6305 + addr = get_unshared_area(filp, addr, len, flags);
6306 }
6307 return addr;
6308 }
6309 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6310 index 45ba99f..8e22c33 100644
6311 --- a/arch/parisc/kernel/traps.c
6312 +++ b/arch/parisc/kernel/traps.c
6313 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6314
6315 down_read(&current->mm->mmap_sem);
6316 vma = find_vma(current->mm,regs->iaoq[0]);
6317 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6318 - && (vma->vm_flags & VM_EXEC)) {
6319 -
6320 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6321 fault_address = regs->iaoq[0];
6322 fault_space = regs->iasq[0];
6323
6324 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6325 index 18162ce..94de376 100644
6326 --- a/arch/parisc/mm/fault.c
6327 +++ b/arch/parisc/mm/fault.c
6328 @@ -15,6 +15,7 @@
6329 #include <linux/sched.h>
6330 #include <linux/interrupt.h>
6331 #include <linux/module.h>
6332 +#include <linux/unistd.h>
6333
6334 #include <asm/uaccess.h>
6335 #include <asm/traps.h>
6336 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6337 static unsigned long
6338 parisc_acctyp(unsigned long code, unsigned int inst)
6339 {
6340 - if (code == 6 || code == 16)
6341 + if (code == 6 || code == 7 || code == 16)
6342 return VM_EXEC;
6343
6344 switch (inst & 0xf0000000) {
6345 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6346 }
6347 #endif
6348
6349 +#ifdef CONFIG_PAX_PAGEEXEC
6350 +/*
6351 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6352 + *
6353 + * returns 1 when task should be killed
6354 + * 2 when rt_sigreturn trampoline was detected
6355 + * 3 when unpatched PLT trampoline was detected
6356 + */
6357 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6358 +{
6359 +
6360 +#ifdef CONFIG_PAX_EMUPLT
6361 + int err;
6362 +
6363 + do { /* PaX: unpatched PLT emulation */
6364 + unsigned int bl, depwi;
6365 +
6366 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6367 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6368 +
6369 + if (err)
6370 + break;
6371 +
6372 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6373 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6374 +
6375 + err = get_user(ldw, (unsigned int *)addr);
6376 + err |= get_user(bv, (unsigned int *)(addr+4));
6377 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6378 +
6379 + if (err)
6380 + break;
6381 +
6382 + if (ldw == 0x0E801096U &&
6383 + bv == 0xEAC0C000U &&
6384 + ldw2 == 0x0E881095U)
6385 + {
6386 + unsigned int resolver, map;
6387 +
6388 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6389 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6390 + if (err)
6391 + break;
6392 +
6393 + regs->gr[20] = instruction_pointer(regs)+8;
6394 + regs->gr[21] = map;
6395 + regs->gr[22] = resolver;
6396 + regs->iaoq[0] = resolver | 3UL;
6397 + regs->iaoq[1] = regs->iaoq[0] + 4;
6398 + return 3;
6399 + }
6400 + }
6401 + } while (0);
6402 +#endif
6403 +
6404 +#ifdef CONFIG_PAX_EMUTRAMP
6405 +
6406 +#ifndef CONFIG_PAX_EMUSIGRT
6407 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6408 + return 1;
6409 +#endif
6410 +
6411 + do { /* PaX: rt_sigreturn emulation */
6412 + unsigned int ldi1, ldi2, bel, nop;
6413 +
6414 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6415 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6416 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6417 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6418 +
6419 + if (err)
6420 + break;
6421 +
6422 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6423 + ldi2 == 0x3414015AU &&
6424 + bel == 0xE4008200U &&
6425 + nop == 0x08000240U)
6426 + {
6427 + regs->gr[25] = (ldi1 & 2) >> 1;
6428 + regs->gr[20] = __NR_rt_sigreturn;
6429 + regs->gr[31] = regs->iaoq[1] + 16;
6430 + regs->sr[0] = regs->iasq[1];
6431 + regs->iaoq[0] = 0x100UL;
6432 + regs->iaoq[1] = regs->iaoq[0] + 4;
6433 + regs->iasq[0] = regs->sr[2];
6434 + regs->iasq[1] = regs->sr[2];
6435 + return 2;
6436 + }
6437 + } while (0);
6438 +#endif
6439 +
6440 + return 1;
6441 +}
6442 +
6443 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6444 +{
6445 + unsigned long i;
6446 +
6447 + printk(KERN_ERR "PAX: bytes at PC: ");
6448 + for (i = 0; i < 5; i++) {
6449 + unsigned int c;
6450 + if (get_user(c, (unsigned int *)pc+i))
6451 + printk(KERN_CONT "???????? ");
6452 + else
6453 + printk(KERN_CONT "%08x ", c);
6454 + }
6455 + printk("\n");
6456 +}
6457 +#endif
6458 +
6459 int fixup_exception(struct pt_regs *regs)
6460 {
6461 const struct exception_table_entry *fix;
6462 @@ -192,8 +303,33 @@ good_area:
6463
6464 acc_type = parisc_acctyp(code,regs->iir);
6465
6466 - if ((vma->vm_flags & acc_type) != acc_type)
6467 + if ((vma->vm_flags & acc_type) != acc_type) {
6468 +
6469 +#ifdef CONFIG_PAX_PAGEEXEC
6470 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6471 + (address & ~3UL) == instruction_pointer(regs))
6472 + {
6473 + up_read(&mm->mmap_sem);
6474 + switch (pax_handle_fetch_fault(regs)) {
6475 +
6476 +#ifdef CONFIG_PAX_EMUPLT
6477 + case 3:
6478 + return;
6479 +#endif
6480 +
6481 +#ifdef CONFIG_PAX_EMUTRAMP
6482 + case 2:
6483 + return;
6484 +#endif
6485 +
6486 + }
6487 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6488 + do_group_exit(SIGKILL);
6489 + }
6490 +#endif
6491 +
6492 goto bad_area;
6493 + }
6494
6495 /*
6496 * If for any reason at all we couldn't handle the fault, make
6497 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6498 index e3b1d41..8e81edf 100644
6499 --- a/arch/powerpc/include/asm/atomic.h
6500 +++ b/arch/powerpc/include/asm/atomic.h
6501 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6502 return t1;
6503 }
6504
6505 +#define atomic64_read_unchecked(v) atomic64_read(v)
6506 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6507 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6508 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6509 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6510 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6511 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6512 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6513 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6514 +
6515 #endif /* __powerpc64__ */
6516
6517 #endif /* __KERNEL__ */
6518 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6519 index 9e495c9..b6878e5 100644
6520 --- a/arch/powerpc/include/asm/cache.h
6521 +++ b/arch/powerpc/include/asm/cache.h
6522 @@ -3,6 +3,7 @@
6523
6524 #ifdef __KERNEL__
6525
6526 +#include <linux/const.h>
6527
6528 /* bytes per L1 cache line */
6529 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6530 @@ -22,7 +23,7 @@
6531 #define L1_CACHE_SHIFT 7
6532 #endif
6533
6534 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6535 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6536
6537 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6538
6539 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6540 index 6abf0a1..459d0f1 100644
6541 --- a/arch/powerpc/include/asm/elf.h
6542 +++ b/arch/powerpc/include/asm/elf.h
6543 @@ -28,8 +28,19 @@
6544 the loader. We need to make sure that it is out of the way of the program
6545 that it will "exec", and that there is sufficient room for the brk. */
6546
6547 -extern unsigned long randomize_et_dyn(unsigned long base);
6548 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6549 +#define ELF_ET_DYN_BASE (0x20000000)
6550 +
6551 +#ifdef CONFIG_PAX_ASLR
6552 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6553 +
6554 +#ifdef __powerpc64__
6555 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6556 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6557 +#else
6558 +#define PAX_DELTA_MMAP_LEN 15
6559 +#define PAX_DELTA_STACK_LEN 15
6560 +#endif
6561 +#endif
6562
6563 /*
6564 * Our registers are always unsigned longs, whether we're a 32 bit
6565 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6566 (0x7ff >> (PAGE_SHIFT - 12)) : \
6567 (0x3ffff >> (PAGE_SHIFT - 12)))
6568
6569 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6570 -#define arch_randomize_brk arch_randomize_brk
6571 -
6572 -
6573 #ifdef CONFIG_SPU_BASE
6574 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6575 #define NT_SPU 1
6576 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6577 index 8196e9c..d83a9f3 100644
6578 --- a/arch/powerpc/include/asm/exec.h
6579 +++ b/arch/powerpc/include/asm/exec.h
6580 @@ -4,6 +4,6 @@
6581 #ifndef _ASM_POWERPC_EXEC_H
6582 #define _ASM_POWERPC_EXEC_H
6583
6584 -extern unsigned long arch_align_stack(unsigned long sp);
6585 +#define arch_align_stack(x) ((x) & ~0xfUL)
6586
6587 #endif /* _ASM_POWERPC_EXEC_H */
6588 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6589 index 5acabbd..7ea14fa 100644
6590 --- a/arch/powerpc/include/asm/kmap_types.h
6591 +++ b/arch/powerpc/include/asm/kmap_types.h
6592 @@ -10,7 +10,7 @@
6593 * 2 of the License, or (at your option) any later version.
6594 */
6595
6596 -#define KM_TYPE_NR 16
6597 +#define KM_TYPE_NR 17
6598
6599 #endif /* __KERNEL__ */
6600 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6601 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6602 index 8565c25..2865190 100644
6603 --- a/arch/powerpc/include/asm/mman.h
6604 +++ b/arch/powerpc/include/asm/mman.h
6605 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6606 }
6607 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6608
6609 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6610 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6611 {
6612 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6613 }
6614 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6615 index f072e97..b436dee 100644
6616 --- a/arch/powerpc/include/asm/page.h
6617 +++ b/arch/powerpc/include/asm/page.h
6618 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6619 * and needs to be executable. This means the whole heap ends
6620 * up being executable.
6621 */
6622 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6623 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6624 +#define VM_DATA_DEFAULT_FLAGS32 \
6625 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6626 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6627
6628 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6629 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6630 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6631 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6632 #endif
6633
6634 +#define ktla_ktva(addr) (addr)
6635 +#define ktva_ktla(addr) (addr)
6636 +
6637 /*
6638 * Use the top bit of the higher-level page table entries to indicate whether
6639 * the entries we point to contain hugepages. This works because we know that
6640 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6641 index cd915d6..c10cee8 100644
6642 --- a/arch/powerpc/include/asm/page_64.h
6643 +++ b/arch/powerpc/include/asm/page_64.h
6644 @@ -154,15 +154,18 @@ do { \
6645 * stack by default, so in the absence of a PT_GNU_STACK program header
6646 * we turn execute permission off.
6647 */
6648 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6649 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6650 +#define VM_STACK_DEFAULT_FLAGS32 \
6651 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6652 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6653
6654 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6655 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6656
6657 +#ifndef CONFIG_PAX_PAGEEXEC
6658 #define VM_STACK_DEFAULT_FLAGS \
6659 (is_32bit_task() ? \
6660 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6661 +#endif
6662
6663 #include <asm-generic/getorder.h>
6664
6665 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6666 index 292725c..f87ae14 100644
6667 --- a/arch/powerpc/include/asm/pgalloc-64.h
6668 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6669 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6670 #ifndef CONFIG_PPC_64K_PAGES
6671
6672 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6673 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6674
6675 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6676 {
6677 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6678 pud_set(pud, (unsigned long)pmd);
6679 }
6680
6681 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6682 +{
6683 + pud_populate(mm, pud, pmd);
6684 +}
6685 +
6686 #define pmd_populate(mm, pmd, pte_page) \
6687 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6688 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6689 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6690 #else /* CONFIG_PPC_64K_PAGES */
6691
6692 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6693 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6694
6695 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6696 pte_t *pte)
6697 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6698 index a9cbd3b..3b67efa 100644
6699 --- a/arch/powerpc/include/asm/pgtable.h
6700 +++ b/arch/powerpc/include/asm/pgtable.h
6701 @@ -2,6 +2,7 @@
6702 #define _ASM_POWERPC_PGTABLE_H
6703 #ifdef __KERNEL__
6704
6705 +#include <linux/const.h>
6706 #ifndef __ASSEMBLY__
6707 #include <asm/processor.h> /* For TASK_SIZE */
6708 #include <asm/mmu.h>
6709 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6710 index 4aad413..85d86bf 100644
6711 --- a/arch/powerpc/include/asm/pte-hash32.h
6712 +++ b/arch/powerpc/include/asm/pte-hash32.h
6713 @@ -21,6 +21,7 @@
6714 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6715 #define _PAGE_USER 0x004 /* usermode access allowed */
6716 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6717 +#define _PAGE_EXEC _PAGE_GUARDED
6718 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6719 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6720 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6721 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6722 index 3d5c9dc..62f8414 100644
6723 --- a/arch/powerpc/include/asm/reg.h
6724 +++ b/arch/powerpc/include/asm/reg.h
6725 @@ -215,6 +215,7 @@
6726 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6727 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6728 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6729 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6730 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6731 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6732 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6733 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6734 index 195ce2a..ab5c614 100644
6735 --- a/arch/powerpc/include/asm/smp.h
6736 +++ b/arch/powerpc/include/asm/smp.h
6737 @@ -50,7 +50,7 @@ struct smp_ops_t {
6738 int (*cpu_disable)(void);
6739 void (*cpu_die)(unsigned int nr);
6740 int (*cpu_bootable)(unsigned int nr);
6741 -};
6742 +} __no_const;
6743
6744 extern void smp_send_debugger_break(void);
6745 extern void start_secondary_resume(void);
6746 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6747 index 406b7b9..af63426 100644
6748 --- a/arch/powerpc/include/asm/thread_info.h
6749 +++ b/arch/powerpc/include/asm/thread_info.h
6750 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6751 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6752 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6753 #define TIF_SINGLESTEP 8 /* singlestepping active */
6754 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6755 #define TIF_SECCOMP 10 /* secure computing */
6756 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6757 #define TIF_NOERROR 12 /* Force successful syscall return */
6758 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6759 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6760 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6761 for stack store? */
6762 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6763 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6764 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6765
6766 /* as above, but as bit values */
6767 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6768 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6769 #define _TIF_UPROBE (1<<TIF_UPROBE)
6770 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6771 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6772 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6773 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6774 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6775 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6776 + _TIF_GRSEC_SETXID)
6777
6778 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6779 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6780 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6781 index 4db4959..aba5c41 100644
6782 --- a/arch/powerpc/include/asm/uaccess.h
6783 +++ b/arch/powerpc/include/asm/uaccess.h
6784 @@ -318,52 +318,6 @@ do { \
6785 extern unsigned long __copy_tofrom_user(void __user *to,
6786 const void __user *from, unsigned long size);
6787
6788 -#ifndef __powerpc64__
6789 -
6790 -static inline unsigned long copy_from_user(void *to,
6791 - const void __user *from, unsigned long n)
6792 -{
6793 - unsigned long over;
6794 -
6795 - if (access_ok(VERIFY_READ, from, n))
6796 - return __copy_tofrom_user((__force void __user *)to, from, n);
6797 - if ((unsigned long)from < TASK_SIZE) {
6798 - over = (unsigned long)from + n - TASK_SIZE;
6799 - return __copy_tofrom_user((__force void __user *)to, from,
6800 - n - over) + over;
6801 - }
6802 - return n;
6803 -}
6804 -
6805 -static inline unsigned long copy_to_user(void __user *to,
6806 - const void *from, unsigned long n)
6807 -{
6808 - unsigned long over;
6809 -
6810 - if (access_ok(VERIFY_WRITE, to, n))
6811 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6812 - if ((unsigned long)to < TASK_SIZE) {
6813 - over = (unsigned long)to + n - TASK_SIZE;
6814 - return __copy_tofrom_user(to, (__force void __user *)from,
6815 - n - over) + over;
6816 - }
6817 - return n;
6818 -}
6819 -
6820 -#else /* __powerpc64__ */
6821 -
6822 -#define __copy_in_user(to, from, size) \
6823 - __copy_tofrom_user((to), (from), (size))
6824 -
6825 -extern unsigned long copy_from_user(void *to, const void __user *from,
6826 - unsigned long n);
6827 -extern unsigned long copy_to_user(void __user *to, const void *from,
6828 - unsigned long n);
6829 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6830 - unsigned long n);
6831 -
6832 -#endif /* __powerpc64__ */
6833 -
6834 static inline unsigned long __copy_from_user_inatomic(void *to,
6835 const void __user *from, unsigned long n)
6836 {
6837 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6838 if (ret == 0)
6839 return 0;
6840 }
6841 +
6842 + if (!__builtin_constant_p(n))
6843 + check_object_size(to, n, false);
6844 +
6845 return __copy_tofrom_user((__force void __user *)to, from, n);
6846 }
6847
6848 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6849 if (ret == 0)
6850 return 0;
6851 }
6852 +
6853 + if (!__builtin_constant_p(n))
6854 + check_object_size(from, n, true);
6855 +
6856 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6857 }
6858
6859 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6860 return __copy_to_user_inatomic(to, from, size);
6861 }
6862
6863 +#ifndef __powerpc64__
6864 +
6865 +static inline unsigned long __must_check copy_from_user(void *to,
6866 + const void __user *from, unsigned long n)
6867 +{
6868 + unsigned long over;
6869 +
6870 + if ((long)n < 0)
6871 + return n;
6872 +
6873 + if (access_ok(VERIFY_READ, from, n)) {
6874 + if (!__builtin_constant_p(n))
6875 + check_object_size(to, n, false);
6876 + return __copy_tofrom_user((__force void __user *)to, from, n);
6877 + }
6878 + if ((unsigned long)from < TASK_SIZE) {
6879 + over = (unsigned long)from + n - TASK_SIZE;
6880 + if (!__builtin_constant_p(n - over))
6881 + check_object_size(to, n - over, false);
6882 + return __copy_tofrom_user((__force void __user *)to, from,
6883 + n - over) + over;
6884 + }
6885 + return n;
6886 +}
6887 +
6888 +static inline unsigned long __must_check copy_to_user(void __user *to,
6889 + const void *from, unsigned long n)
6890 +{
6891 + unsigned long over;
6892 +
6893 + if ((long)n < 0)
6894 + return n;
6895 +
6896 + if (access_ok(VERIFY_WRITE, to, n)) {
6897 + if (!__builtin_constant_p(n))
6898 + check_object_size(from, n, true);
6899 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6900 + }
6901 + if ((unsigned long)to < TASK_SIZE) {
6902 + over = (unsigned long)to + n - TASK_SIZE;
6903 + if (!__builtin_constant_p(n))
6904 + check_object_size(from, n - over, true);
6905 + return __copy_tofrom_user(to, (__force void __user *)from,
6906 + n - over) + over;
6907 + }
6908 + return n;
6909 +}
6910 +
6911 +#else /* __powerpc64__ */
6912 +
6913 +#define __copy_in_user(to, from, size) \
6914 + __copy_tofrom_user((to), (from), (size))
6915 +
6916 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6917 +{
6918 + if ((long)n < 0 || n > INT_MAX)
6919 + return n;
6920 +
6921 + if (!__builtin_constant_p(n))
6922 + check_object_size(to, n, false);
6923 +
6924 + if (likely(access_ok(VERIFY_READ, from, n)))
6925 + n = __copy_from_user(to, from, n);
6926 + else
6927 + memset(to, 0, n);
6928 + return n;
6929 +}
6930 +
6931 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6932 +{
6933 + if ((long)n < 0 || n > INT_MAX)
6934 + return n;
6935 +
6936 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6937 + if (!__builtin_constant_p(n))
6938 + check_object_size(from, n, true);
6939 + n = __copy_to_user(to, from, n);
6940 + }
6941 + return n;
6942 +}
6943 +
6944 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6945 + unsigned long n);
6946 +
6947 +#endif /* __powerpc64__ */
6948 +
6949 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6950
6951 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6952 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6953 index 4684e33..acc4d19e 100644
6954 --- a/arch/powerpc/kernel/exceptions-64e.S
6955 +++ b/arch/powerpc/kernel/exceptions-64e.S
6956 @@ -715,6 +715,7 @@ storage_fault_common:
6957 std r14,_DAR(r1)
6958 std r15,_DSISR(r1)
6959 addi r3,r1,STACK_FRAME_OVERHEAD
6960 + bl .save_nvgprs
6961 mr r4,r14
6962 mr r5,r15
6963 ld r14,PACA_EXGEN+EX_R14(r13)
6964 @@ -723,8 +724,7 @@ storage_fault_common:
6965 cmpdi r3,0
6966 bne- 1f
6967 b .ret_from_except_lite
6968 -1: bl .save_nvgprs
6969 - mr r5,r3
6970 +1: mr r5,r3
6971 addi r3,r1,STACK_FRAME_OVERHEAD
6972 ld r4,_DAR(r1)
6973 bl .bad_page_fault
6974 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6975 index bb11075..2d00a2a 100644
6976 --- a/arch/powerpc/kernel/exceptions-64s.S
6977 +++ b/arch/powerpc/kernel/exceptions-64s.S
6978 @@ -1206,10 +1206,10 @@ handle_page_fault:
6979 11: ld r4,_DAR(r1)
6980 ld r5,_DSISR(r1)
6981 addi r3,r1,STACK_FRAME_OVERHEAD
6982 + bl .save_nvgprs
6983 bl .do_page_fault
6984 cmpdi r3,0
6985 beq+ 12f
6986 - bl .save_nvgprs
6987 mr r5,r3
6988 addi r3,r1,STACK_FRAME_OVERHEAD
6989 lwz r4,_DAR(r1)
6990 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6991 index 2e3200c..72095ce 100644
6992 --- a/arch/powerpc/kernel/module_32.c
6993 +++ b/arch/powerpc/kernel/module_32.c
6994 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6995 me->arch.core_plt_section = i;
6996 }
6997 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6998 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6999 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7000 return -ENOEXEC;
7001 }
7002
7003 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7004
7005 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7006 /* Init, or core PLT? */
7007 - if (location >= mod->module_core
7008 - && location < mod->module_core + mod->core_size)
7009 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7010 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7011 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7012 - else
7013 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7014 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7015 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7016 + else {
7017 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7018 + return ~0UL;
7019 + }
7020
7021 /* Find this entry, or if that fails, the next avail. entry */
7022 while (entry->jump[0]) {
7023 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7024 index 8143067..21ae55b 100644
7025 --- a/arch/powerpc/kernel/process.c
7026 +++ b/arch/powerpc/kernel/process.c
7027 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
7028 * Lookup NIP late so we have the best change of getting the
7029 * above info out without failing
7030 */
7031 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
7032 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
7033 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
7034 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
7035 #endif
7036 show_stack(current, (unsigned long *) regs->gpr[1]);
7037 if (!user_mode(regs))
7038 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7039 newsp = stack[0];
7040 ip = stack[STACK_FRAME_LR_SAVE];
7041 if (!firstframe || ip != lr) {
7042 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
7043 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
7044 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7045 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
7046 - printk(" (%pS)",
7047 + printk(" (%pA)",
7048 (void *)current->ret_stack[curr_frame].ret);
7049 curr_frame--;
7050 }
7051 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
7052 struct pt_regs *regs = (struct pt_regs *)
7053 (sp + STACK_FRAME_OVERHEAD);
7054 lr = regs->link;
7055 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
7056 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
7057 regs->trap, (void *)regs->nip, (void *)lr);
7058 firstframe = 1;
7059 }
7060 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
7061 mtspr(SPRN_CTRLT, ctrl);
7062 }
7063 #endif /* CONFIG_PPC64 */
7064 -
7065 -unsigned long arch_align_stack(unsigned long sp)
7066 -{
7067 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7068 - sp -= get_random_int() & ~PAGE_MASK;
7069 - return sp & ~0xf;
7070 -}
7071 -
7072 -static inline unsigned long brk_rnd(void)
7073 -{
7074 - unsigned long rnd = 0;
7075 -
7076 - /* 8MB for 32bit, 1GB for 64bit */
7077 - if (is_32bit_task())
7078 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7079 - else
7080 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7081 -
7082 - return rnd << PAGE_SHIFT;
7083 -}
7084 -
7085 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7086 -{
7087 - unsigned long base = mm->brk;
7088 - unsigned long ret;
7089 -
7090 -#ifdef CONFIG_PPC_STD_MMU_64
7091 - /*
7092 - * If we are using 1TB segments and we are allowed to randomise
7093 - * the heap, we can put it above 1TB so it is backed by a 1TB
7094 - * segment. Otherwise the heap will be in the bottom 1TB
7095 - * which always uses 256MB segments and this may result in a
7096 - * performance penalty.
7097 - */
7098 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7099 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7100 -#endif
7101 -
7102 - ret = PAGE_ALIGN(base + brk_rnd());
7103 -
7104 - if (ret < mm->brk)
7105 - return mm->brk;
7106 -
7107 - return ret;
7108 -}
7109 -
7110 -unsigned long randomize_et_dyn(unsigned long base)
7111 -{
7112 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7113 -
7114 - if (ret < base)
7115 - return base;
7116 -
7117 - return ret;
7118 -}
7119 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7120 index c497000..8fde506 100644
7121 --- a/arch/powerpc/kernel/ptrace.c
7122 +++ b/arch/powerpc/kernel/ptrace.c
7123 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7124 return ret;
7125 }
7126
7127 +#ifdef CONFIG_GRKERNSEC_SETXID
7128 +extern void gr_delayed_cred_worker(void);
7129 +#endif
7130 +
7131 /*
7132 * We must return the syscall number to actually look up in the table.
7133 * This can be -1L to skip running any syscall at all.
7134 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7135
7136 secure_computing_strict(regs->gpr[0]);
7137
7138 +#ifdef CONFIG_GRKERNSEC_SETXID
7139 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7140 + gr_delayed_cred_worker();
7141 +#endif
7142 +
7143 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7144 tracehook_report_syscall_entry(regs))
7145 /*
7146 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7147 {
7148 int step;
7149
7150 +#ifdef CONFIG_GRKERNSEC_SETXID
7151 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7152 + gr_delayed_cred_worker();
7153 +#endif
7154 +
7155 audit_syscall_exit(regs);
7156
7157 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7158 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7159 index 804e323..79181c1 100644
7160 --- a/arch/powerpc/kernel/signal_32.c
7161 +++ b/arch/powerpc/kernel/signal_32.c
7162 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7163 /* Save user registers on the stack */
7164 frame = &rt_sf->uc.uc_mcontext;
7165 addr = frame;
7166 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7167 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7168 if (save_user_regs(regs, frame, 0, 1))
7169 goto badframe;
7170 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7171 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7172 index 1ca045d..139c3f7 100644
7173 --- a/arch/powerpc/kernel/signal_64.c
7174 +++ b/arch/powerpc/kernel/signal_64.c
7175 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7176 current->thread.fpscr.val = 0;
7177
7178 /* Set up to return from userspace. */
7179 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7180 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7181 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7182 } else {
7183 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7184 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7185 index 3ce1f86..c30e629 100644
7186 --- a/arch/powerpc/kernel/sysfs.c
7187 +++ b/arch/powerpc/kernel/sysfs.c
7188 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7189 return NOTIFY_OK;
7190 }
7191
7192 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7193 +static struct notifier_block sysfs_cpu_nb = {
7194 .notifier_call = sysfs_cpu_notify,
7195 };
7196
7197 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7198 index 3251840..3f7c77a 100644
7199 --- a/arch/powerpc/kernel/traps.c
7200 +++ b/arch/powerpc/kernel/traps.c
7201 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7202 return flags;
7203 }
7204
7205 +extern void gr_handle_kernel_exploit(void);
7206 +
7207 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7208 int signr)
7209 {
7210 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7211 panic("Fatal exception in interrupt");
7212 if (panic_on_oops)
7213 panic("Fatal exception");
7214 +
7215 + gr_handle_kernel_exploit();
7216 +
7217 do_exit(signr);
7218 }
7219
7220 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7221 index 1b2076f..835e4be 100644
7222 --- a/arch/powerpc/kernel/vdso.c
7223 +++ b/arch/powerpc/kernel/vdso.c
7224 @@ -34,6 +34,7 @@
7225 #include <asm/firmware.h>
7226 #include <asm/vdso.h>
7227 #include <asm/vdso_datapage.h>
7228 +#include <asm/mman.h>
7229
7230 #include "setup.h"
7231
7232 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7233 vdso_base = VDSO32_MBASE;
7234 #endif
7235
7236 - current->mm->context.vdso_base = 0;
7237 + current->mm->context.vdso_base = ~0UL;
7238
7239 /* vDSO has a problem and was disabled, just don't "enable" it for the
7240 * process
7241 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7242 vdso_base = get_unmapped_area(NULL, vdso_base,
7243 (vdso_pages << PAGE_SHIFT) +
7244 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7245 - 0, 0);
7246 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7247 if (IS_ERR_VALUE(vdso_base)) {
7248 rc = vdso_base;
7249 goto fail_mmapsem;
7250 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7251 index 5eea6f3..5d10396 100644
7252 --- a/arch/powerpc/lib/usercopy_64.c
7253 +++ b/arch/powerpc/lib/usercopy_64.c
7254 @@ -9,22 +9,6 @@
7255 #include <linux/module.h>
7256 #include <asm/uaccess.h>
7257
7258 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7259 -{
7260 - if (likely(access_ok(VERIFY_READ, from, n)))
7261 - n = __copy_from_user(to, from, n);
7262 - else
7263 - memset(to, 0, n);
7264 - return n;
7265 -}
7266 -
7267 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7268 -{
7269 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7270 - n = __copy_to_user(to, from, n);
7271 - return n;
7272 -}
7273 -
7274 unsigned long copy_in_user(void __user *to, const void __user *from,
7275 unsigned long n)
7276 {
7277 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7278 return n;
7279 }
7280
7281 -EXPORT_SYMBOL(copy_from_user);
7282 -EXPORT_SYMBOL(copy_to_user);
7283 EXPORT_SYMBOL(copy_in_user);
7284
7285 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7286 index 3a8489a..6a63b3b 100644
7287 --- a/arch/powerpc/mm/fault.c
7288 +++ b/arch/powerpc/mm/fault.c
7289 @@ -32,6 +32,10 @@
7290 #include <linux/perf_event.h>
7291 #include <linux/magic.h>
7292 #include <linux/ratelimit.h>
7293 +#include <linux/slab.h>
7294 +#include <linux/pagemap.h>
7295 +#include <linux/compiler.h>
7296 +#include <linux/unistd.h>
7297
7298 #include <asm/firmware.h>
7299 #include <asm/page.h>
7300 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7301 }
7302 #endif
7303
7304 +#ifdef CONFIG_PAX_PAGEEXEC
7305 +/*
7306 + * PaX: decide what to do with offenders (regs->nip = fault address)
7307 + *
7308 + * returns 1 when task should be killed
7309 + */
7310 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7311 +{
7312 + return 1;
7313 +}
7314 +
7315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7316 +{
7317 + unsigned long i;
7318 +
7319 + printk(KERN_ERR "PAX: bytes at PC: ");
7320 + for (i = 0; i < 5; i++) {
7321 + unsigned int c;
7322 + if (get_user(c, (unsigned int __user *)pc+i))
7323 + printk(KERN_CONT "???????? ");
7324 + else
7325 + printk(KERN_CONT "%08x ", c);
7326 + }
7327 + printk("\n");
7328 +}
7329 +#endif
7330 +
7331 /*
7332 * Check whether the instruction at regs->nip is a store using
7333 * an update addressing form which will update r1.
7334 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7335 * indicate errors in DSISR but can validly be set in SRR1.
7336 */
7337 if (trap == 0x400)
7338 - error_code &= 0x48200000;
7339 + error_code &= 0x58200000;
7340 else
7341 is_write = error_code & DSISR_ISSTORE;
7342 #else
7343 @@ -364,7 +395,7 @@ good_area:
7344 * "undefined". Of those that can be set, this is the only
7345 * one which seems bad.
7346 */
7347 - if (error_code & 0x10000000)
7348 + if (error_code & DSISR_GUARDED)
7349 /* Guarded storage error. */
7350 goto bad_area;
7351 #endif /* CONFIG_8xx */
7352 @@ -379,7 +410,7 @@ good_area:
7353 * processors use the same I/D cache coherency mechanism
7354 * as embedded.
7355 */
7356 - if (error_code & DSISR_PROTFAULT)
7357 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7358 goto bad_area;
7359 #endif /* CONFIG_PPC_STD_MMU */
7360
7361 @@ -462,6 +493,23 @@ bad_area:
7362 bad_area_nosemaphore:
7363 /* User mode accesses cause a SIGSEGV */
7364 if (user_mode(regs)) {
7365 +
7366 +#ifdef CONFIG_PAX_PAGEEXEC
7367 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7368 +#ifdef CONFIG_PPC_STD_MMU
7369 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7370 +#else
7371 + if (is_exec && regs->nip == address) {
7372 +#endif
7373 + switch (pax_handle_fetch_fault(regs)) {
7374 + }
7375 +
7376 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7377 + do_group_exit(SIGKILL);
7378 + }
7379 + }
7380 +#endif
7381 +
7382 _exception(SIGSEGV, regs, code, address);
7383 return 0;
7384 }
7385 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7386 index 67a42ed..cd463e0 100644
7387 --- a/arch/powerpc/mm/mmap_64.c
7388 +++ b/arch/powerpc/mm/mmap_64.c
7389 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7390 {
7391 unsigned long rnd = 0;
7392
7393 +#ifdef CONFIG_PAX_RANDMMAP
7394 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7395 +#endif
7396 +
7397 if (current->flags & PF_RANDOMIZE) {
7398 /* 8MB for 32bit, 1GB for 64bit */
7399 if (is_32bit_task())
7400 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7401 */
7402 if (mmap_is_legacy()) {
7403 mm->mmap_base = TASK_UNMAPPED_BASE;
7404 +
7405 +#ifdef CONFIG_PAX_RANDMMAP
7406 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7407 + mm->mmap_base += mm->delta_mmap;
7408 +#endif
7409 +
7410 mm->get_unmapped_area = arch_get_unmapped_area;
7411 mm->unmap_area = arch_unmap_area;
7412 } else {
7413 mm->mmap_base = mmap_base();
7414 +
7415 +#ifdef CONFIG_PAX_RANDMMAP
7416 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7417 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7418 +#endif
7419 +
7420 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7421 mm->unmap_area = arch_unmap_area_topdown;
7422 }
7423 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7424 index e779642..e5bb889 100644
7425 --- a/arch/powerpc/mm/mmu_context_nohash.c
7426 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7427 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7428 return NOTIFY_OK;
7429 }
7430
7431 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7432 +static struct notifier_block mmu_context_cpu_nb = {
7433 .notifier_call = mmu_context_cpu_notify,
7434 };
7435
7436 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7437 index bba87ca..c346a33 100644
7438 --- a/arch/powerpc/mm/numa.c
7439 +++ b/arch/powerpc/mm/numa.c
7440 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7441 return ret;
7442 }
7443
7444 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7445 +static struct notifier_block ppc64_numa_nb = {
7446 .notifier_call = cpu_numa_callback,
7447 .priority = 1 /* Must run before sched domains notifier. */
7448 };
7449 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7450 index cf9dada..241529f 100644
7451 --- a/arch/powerpc/mm/slice.c
7452 +++ b/arch/powerpc/mm/slice.c
7453 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7454 if ((mm->task_size - len) < addr)
7455 return 0;
7456 vma = find_vma(mm, addr);
7457 - return (!vma || (addr + len) <= vma->vm_start);
7458 + return check_heap_stack_gap(vma, addr, len, 0);
7459 }
7460
7461 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7462 @@ -272,7 +272,7 @@ full_search:
7463 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7464 continue;
7465 }
7466 - if (!vma || addr + len <= vma->vm_start) {
7467 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7468 /*
7469 * Remember the place where we stopped the search:
7470 */
7471 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7472 }
7473 }
7474
7475 - addr = mm->mmap_base;
7476 - while (addr > len) {
7477 + if (mm->mmap_base < len)
7478 + addr = -ENOMEM;
7479 + else
7480 + addr = mm->mmap_base - len;
7481 +
7482 + while (!IS_ERR_VALUE(addr)) {
7483 /* Go down by chunk size */
7484 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7485 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7486
7487 /* Check for hit with different page size */
7488 mask = slice_range_to_mask(addr, len);
7489 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7490 * return with success:
7491 */
7492 vma = find_vma(mm, addr);
7493 - if (!vma || (addr + len) <= vma->vm_start) {
7494 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7495 /* remember the address as a hint for next time */
7496 if (use_cache)
7497 mm->free_area_cache = addr;
7498 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7499 mm->cached_hole_size = vma->vm_start - addr;
7500
7501 /* try just below the current vma->vm_start */
7502 - addr = vma->vm_start;
7503 + addr = skip_heap_stack_gap(vma, len, 0);
7504 }
7505
7506 /*
7507 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7508 if (fixed && addr > (mm->task_size - len))
7509 return -EINVAL;
7510
7511 +#ifdef CONFIG_PAX_RANDMMAP
7512 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7513 + addr = 0;
7514 +#endif
7515 +
7516 /* If hint, make sure it matches our alignment restrictions */
7517 if (!fixed && addr) {
7518 addr = _ALIGN_UP(addr, 1ul << pshift);
7519 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7520 index 0cfece4..2f1a0e5 100644
7521 --- a/arch/powerpc/platforms/cell/spufs/file.c
7522 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7523 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7524 return VM_FAULT_NOPAGE;
7525 }
7526
7527 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7528 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7529 unsigned long address,
7530 - void *buf, int len, int write)
7531 + void *buf, size_t len, int write)
7532 {
7533 struct spu_context *ctx = vma->vm_file->private_data;
7534 unsigned long offset = address - vma->vm_start;
7535 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7536 index bdb738a..49c9f95 100644
7537 --- a/arch/powerpc/platforms/powermac/smp.c
7538 +++ b/arch/powerpc/platforms/powermac/smp.c
7539 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7540 return NOTIFY_OK;
7541 }
7542
7543 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7544 +static struct notifier_block smp_core99_cpu_nb = {
7545 .notifier_call = smp_core99_cpu_notify,
7546 };
7547 #endif /* CONFIG_HOTPLUG_CPU */
7548 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7549 index c797832..ce575c8 100644
7550 --- a/arch/s390/include/asm/atomic.h
7551 +++ b/arch/s390/include/asm/atomic.h
7552 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7553 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7554 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7555
7556 +#define atomic64_read_unchecked(v) atomic64_read(v)
7557 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7558 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7559 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7560 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7561 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7562 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7563 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7564 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7565 +
7566 #define smp_mb__before_atomic_dec() smp_mb()
7567 #define smp_mb__after_atomic_dec() smp_mb()
7568 #define smp_mb__before_atomic_inc() smp_mb()
7569 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7570 index 4d7ccac..d03d0ad 100644
7571 --- a/arch/s390/include/asm/cache.h
7572 +++ b/arch/s390/include/asm/cache.h
7573 @@ -9,8 +9,10 @@
7574 #ifndef __ARCH_S390_CACHE_H
7575 #define __ARCH_S390_CACHE_H
7576
7577 -#define L1_CACHE_BYTES 256
7578 +#include <linux/const.h>
7579 +
7580 #define L1_CACHE_SHIFT 8
7581 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7582 #define NET_SKB_PAD 32
7583
7584 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7585 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7586 index 178ff96..8c93bd1 100644
7587 --- a/arch/s390/include/asm/elf.h
7588 +++ b/arch/s390/include/asm/elf.h
7589 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7590 the loader. We need to make sure that it is out of the way of the program
7591 that it will "exec", and that there is sufficient room for the brk. */
7592
7593 -extern unsigned long randomize_et_dyn(unsigned long base);
7594 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7595 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7596 +
7597 +#ifdef CONFIG_PAX_ASLR
7598 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7599 +
7600 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7601 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7602 +#endif
7603
7604 /* This yields a mask that user programs can use to figure out what
7605 instruction set this CPU supports. */
7606 @@ -210,9 +216,6 @@ struct linux_binprm;
7607 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7608 int arch_setup_additional_pages(struct linux_binprm *, int);
7609
7610 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7611 -#define arch_randomize_brk arch_randomize_brk
7612 -
7613 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7614
7615 #endif
7616 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7617 index c4a93d6..4d2a9b4 100644
7618 --- a/arch/s390/include/asm/exec.h
7619 +++ b/arch/s390/include/asm/exec.h
7620 @@ -7,6 +7,6 @@
7621 #ifndef __ASM_EXEC_H
7622 #define __ASM_EXEC_H
7623
7624 -extern unsigned long arch_align_stack(unsigned long sp);
7625 +#define arch_align_stack(x) ((x) & ~0xfUL)
7626
7627 #endif /* __ASM_EXEC_H */
7628 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7629 index 34268df..ea97318 100644
7630 --- a/arch/s390/include/asm/uaccess.h
7631 +++ b/arch/s390/include/asm/uaccess.h
7632 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7633 copy_to_user(void __user *to, const void *from, unsigned long n)
7634 {
7635 might_fault();
7636 +
7637 + if ((long)n < 0)
7638 + return n;
7639 +
7640 if (access_ok(VERIFY_WRITE, to, n))
7641 n = __copy_to_user(to, from, n);
7642 return n;
7643 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7644 static inline unsigned long __must_check
7645 __copy_from_user(void *to, const void __user *from, unsigned long n)
7646 {
7647 + if ((long)n < 0)
7648 + return n;
7649 +
7650 if (__builtin_constant_p(n) && (n <= 256))
7651 return uaccess.copy_from_user_small(n, from, to);
7652 else
7653 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7654 static inline unsigned long __must_check
7655 copy_from_user(void *to, const void __user *from, unsigned long n)
7656 {
7657 - unsigned int sz = __compiletime_object_size(to);
7658 + size_t sz = __compiletime_object_size(to);
7659
7660 might_fault();
7661 - if (unlikely(sz != -1 && sz < n)) {
7662 +
7663 + if ((long)n < 0)
7664 + return n;
7665 +
7666 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7667 copy_from_user_overflow();
7668 return n;
7669 }
7670 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7671 index 4610dea..cf0af21 100644
7672 --- a/arch/s390/kernel/module.c
7673 +++ b/arch/s390/kernel/module.c
7674 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7675
7676 /* Increase core size by size of got & plt and set start
7677 offsets for got and plt. */
7678 - me->core_size = ALIGN(me->core_size, 4);
7679 - me->arch.got_offset = me->core_size;
7680 - me->core_size += me->arch.got_size;
7681 - me->arch.plt_offset = me->core_size;
7682 - me->core_size += me->arch.plt_size;
7683 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7684 + me->arch.got_offset = me->core_size_rw;
7685 + me->core_size_rw += me->arch.got_size;
7686 + me->arch.plt_offset = me->core_size_rx;
7687 + me->core_size_rx += me->arch.plt_size;
7688 return 0;
7689 }
7690
7691 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7692 if (info->got_initialized == 0) {
7693 Elf_Addr *gotent;
7694
7695 - gotent = me->module_core + me->arch.got_offset +
7696 + gotent = me->module_core_rw + me->arch.got_offset +
7697 info->got_offset;
7698 *gotent = val;
7699 info->got_initialized = 1;
7700 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7701 else if (r_type == R_390_GOTENT ||
7702 r_type == R_390_GOTPLTENT)
7703 *(unsigned int *) loc =
7704 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7705 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7706 else if (r_type == R_390_GOT64 ||
7707 r_type == R_390_GOTPLT64)
7708 *(unsigned long *) loc = val;
7709 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7710 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7711 if (info->plt_initialized == 0) {
7712 unsigned int *ip;
7713 - ip = me->module_core + me->arch.plt_offset +
7714 + ip = me->module_core_rx + me->arch.plt_offset +
7715 info->plt_offset;
7716 #ifndef CONFIG_64BIT
7717 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7718 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7719 val - loc + 0xffffUL < 0x1ffffeUL) ||
7720 (r_type == R_390_PLT32DBL &&
7721 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7722 - val = (Elf_Addr) me->module_core +
7723 + val = (Elf_Addr) me->module_core_rx +
7724 me->arch.plt_offset +
7725 info->plt_offset;
7726 val += rela->r_addend - loc;
7727 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7728 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7729 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7730 val = val + rela->r_addend -
7731 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7732 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7733 if (r_type == R_390_GOTOFF16)
7734 *(unsigned short *) loc = val;
7735 else if (r_type == R_390_GOTOFF32)
7736 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7737 break;
7738 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7739 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7740 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7741 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7742 rela->r_addend - loc;
7743 if (r_type == R_390_GOTPC)
7744 *(unsigned int *) loc = val;
7745 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7746 index 536d645..4a5bd9e 100644
7747 --- a/arch/s390/kernel/process.c
7748 +++ b/arch/s390/kernel/process.c
7749 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7750 }
7751 return 0;
7752 }
7753 -
7754 -unsigned long arch_align_stack(unsigned long sp)
7755 -{
7756 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7757 - sp -= get_random_int() & ~PAGE_MASK;
7758 - return sp & ~0xf;
7759 -}
7760 -
7761 -static inline unsigned long brk_rnd(void)
7762 -{
7763 - /* 8MB for 32bit, 1GB for 64bit */
7764 - if (is_32bit_task())
7765 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7766 - else
7767 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7768 -}
7769 -
7770 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7771 -{
7772 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7773 -
7774 - if (ret < mm->brk)
7775 - return mm->brk;
7776 - return ret;
7777 -}
7778 -
7779 -unsigned long randomize_et_dyn(unsigned long base)
7780 -{
7781 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7782 -
7783 - if (!(current->flags & PF_RANDOMIZE))
7784 - return base;
7785 - if (ret < base)
7786 - return base;
7787 - return ret;
7788 -}
7789 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7790 index c59a5ef..3fae59c 100644
7791 --- a/arch/s390/mm/mmap.c
7792 +++ b/arch/s390/mm/mmap.c
7793 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7794 */
7795 if (mmap_is_legacy()) {
7796 mm->mmap_base = TASK_UNMAPPED_BASE;
7797 +
7798 +#ifdef CONFIG_PAX_RANDMMAP
7799 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7800 + mm->mmap_base += mm->delta_mmap;
7801 +#endif
7802 +
7803 mm->get_unmapped_area = arch_get_unmapped_area;
7804 mm->unmap_area = arch_unmap_area;
7805 } else {
7806 mm->mmap_base = mmap_base();
7807 +
7808 +#ifdef CONFIG_PAX_RANDMMAP
7809 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7810 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7811 +#endif
7812 +
7813 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7814 mm->unmap_area = arch_unmap_area_topdown;
7815 }
7816 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7817 */
7818 if (mmap_is_legacy()) {
7819 mm->mmap_base = TASK_UNMAPPED_BASE;
7820 +
7821 +#ifdef CONFIG_PAX_RANDMMAP
7822 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7823 + mm->mmap_base += mm->delta_mmap;
7824 +#endif
7825 +
7826 mm->get_unmapped_area = s390_get_unmapped_area;
7827 mm->unmap_area = arch_unmap_area;
7828 } else {
7829 mm->mmap_base = mmap_base();
7830 +
7831 +#ifdef CONFIG_PAX_RANDMMAP
7832 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7833 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7834 +#endif
7835 +
7836 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7837 mm->unmap_area = arch_unmap_area_topdown;
7838 }
7839 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7840 index ae3d59f..f65f075 100644
7841 --- a/arch/score/include/asm/cache.h
7842 +++ b/arch/score/include/asm/cache.h
7843 @@ -1,7 +1,9 @@
7844 #ifndef _ASM_SCORE_CACHE_H
7845 #define _ASM_SCORE_CACHE_H
7846
7847 +#include <linux/const.h>
7848 +
7849 #define L1_CACHE_SHIFT 4
7850 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7851 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7852
7853 #endif /* _ASM_SCORE_CACHE_H */
7854 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7855 index f9f3cd5..58ff438 100644
7856 --- a/arch/score/include/asm/exec.h
7857 +++ b/arch/score/include/asm/exec.h
7858 @@ -1,6 +1,6 @@
7859 #ifndef _ASM_SCORE_EXEC_H
7860 #define _ASM_SCORE_EXEC_H
7861
7862 -extern unsigned long arch_align_stack(unsigned long sp);
7863 +#define arch_align_stack(x) (x)
7864
7865 #endif /* _ASM_SCORE_EXEC_H */
7866 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7867 index 7956846..5f37677 100644
7868 --- a/arch/score/kernel/process.c
7869 +++ b/arch/score/kernel/process.c
7870 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7871
7872 return task_pt_regs(task)->cp0_epc;
7873 }
7874 -
7875 -unsigned long arch_align_stack(unsigned long sp)
7876 -{
7877 - return sp;
7878 -}
7879 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7880 index ef9e555..331bd29 100644
7881 --- a/arch/sh/include/asm/cache.h
7882 +++ b/arch/sh/include/asm/cache.h
7883 @@ -9,10 +9,11 @@
7884 #define __ASM_SH_CACHE_H
7885 #ifdef __KERNEL__
7886
7887 +#include <linux/const.h>
7888 #include <linux/init.h>
7889 #include <cpu/cache.h>
7890
7891 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7892 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7893
7894 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7895
7896 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7897 index 03f2b55..b0270327 100644
7898 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7899 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7900 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7901 return NOTIFY_OK;
7902 }
7903
7904 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7905 +static struct notifier_block shx3_cpu_notifier = {
7906 .notifier_call = shx3_cpu_callback,
7907 };
7908
7909 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7910 index 6777177..cb5e44f 100644
7911 --- a/arch/sh/mm/mmap.c
7912 +++ b/arch/sh/mm/mmap.c
7913 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7914 struct mm_struct *mm = current->mm;
7915 struct vm_area_struct *vma;
7916 int do_colour_align;
7917 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7918 struct vm_unmapped_area_info info;
7919
7920 if (flags & MAP_FIXED) {
7921 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7922 if (filp || (flags & MAP_SHARED))
7923 do_colour_align = 1;
7924
7925 +#ifdef CONFIG_PAX_RANDMMAP
7926 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7927 +#endif
7928 +
7929 if (addr) {
7930 if (do_colour_align)
7931 addr = COLOUR_ALIGN(addr, pgoff);
7932 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7933 addr = PAGE_ALIGN(addr);
7934
7935 vma = find_vma(mm, addr);
7936 - if (TASK_SIZE - len >= addr &&
7937 - (!vma || addr + len <= vma->vm_start))
7938 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7939 return addr;
7940 }
7941
7942 info.flags = 0;
7943 info.length = len;
7944 - info.low_limit = TASK_UNMAPPED_BASE;
7945 + info.low_limit = mm->mmap_base;
7946 info.high_limit = TASK_SIZE;
7947 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7948 info.align_offset = pgoff << PAGE_SHIFT;
7949 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7950 struct mm_struct *mm = current->mm;
7951 unsigned long addr = addr0;
7952 int do_colour_align;
7953 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7954 struct vm_unmapped_area_info info;
7955
7956 if (flags & MAP_FIXED) {
7957 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7958 if (filp || (flags & MAP_SHARED))
7959 do_colour_align = 1;
7960
7961 +#ifdef CONFIG_PAX_RANDMMAP
7962 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7963 +#endif
7964 +
7965 /* requesting a specific address */
7966 if (addr) {
7967 if (do_colour_align)
7968 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7969 addr = PAGE_ALIGN(addr);
7970
7971 vma = find_vma(mm, addr);
7972 - if (TASK_SIZE - len >= addr &&
7973 - (!vma || addr + len <= vma->vm_start))
7974 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7975 return addr;
7976 }
7977
7978 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7979 VM_BUG_ON(addr != -ENOMEM);
7980 info.flags = 0;
7981 info.low_limit = TASK_UNMAPPED_BASE;
7982 +
7983 +#ifdef CONFIG_PAX_RANDMMAP
7984 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7985 + info.low_limit += mm->delta_mmap;
7986 +#endif
7987 +
7988 info.high_limit = TASK_SIZE;
7989 addr = vm_unmapped_area(&info);
7990 }
7991 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7992 index be56a24..443328f 100644
7993 --- a/arch/sparc/include/asm/atomic_64.h
7994 +++ b/arch/sparc/include/asm/atomic_64.h
7995 @@ -14,18 +14,40 @@
7996 #define ATOMIC64_INIT(i) { (i) }
7997
7998 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7999 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8000 +{
8001 + return v->counter;
8002 +}
8003 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8004 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8005 +{
8006 + return v->counter;
8007 +}
8008
8009 #define atomic_set(v, i) (((v)->counter) = i)
8010 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8011 +{
8012 + v->counter = i;
8013 +}
8014 #define atomic64_set(v, i) (((v)->counter) = i)
8015 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8016 +{
8017 + v->counter = i;
8018 +}
8019
8020 extern void atomic_add(int, atomic_t *);
8021 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8022 extern void atomic64_add(long, atomic64_t *);
8023 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8024 extern void atomic_sub(int, atomic_t *);
8025 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8026 extern void atomic64_sub(long, atomic64_t *);
8027 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8028
8029 extern int atomic_add_ret(int, atomic_t *);
8030 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8031 extern long atomic64_add_ret(long, atomic64_t *);
8032 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8033 extern int atomic_sub_ret(int, atomic_t *);
8034 extern long atomic64_sub_ret(long, atomic64_t *);
8035
8036 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8037 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8038
8039 #define atomic_inc_return(v) atomic_add_ret(1, v)
8040 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8041 +{
8042 + return atomic_add_ret_unchecked(1, v);
8043 +}
8044 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8045 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8046 +{
8047 + return atomic64_add_ret_unchecked(1, v);
8048 +}
8049
8050 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8051 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8052
8053 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8054 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8055 +{
8056 + return atomic_add_ret_unchecked(i, v);
8057 +}
8058 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8059 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8060 +{
8061 + return atomic64_add_ret_unchecked(i, v);
8062 +}
8063
8064 /*
8065 * atomic_inc_and_test - increment and test
8066 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8067 * other cases.
8068 */
8069 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8070 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8071 +{
8072 + return atomic_inc_return_unchecked(v) == 0;
8073 +}
8074 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8075
8076 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8077 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8078 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8079
8080 #define atomic_inc(v) atomic_add(1, v)
8081 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8082 +{
8083 + atomic_add_unchecked(1, v);
8084 +}
8085 #define atomic64_inc(v) atomic64_add(1, v)
8086 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8087 +{
8088 + atomic64_add_unchecked(1, v);
8089 +}
8090
8091 #define atomic_dec(v) atomic_sub(1, v)
8092 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8093 +{
8094 + atomic_sub_unchecked(1, v);
8095 +}
8096 #define atomic64_dec(v) atomic64_sub(1, v)
8097 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8098 +{
8099 + atomic64_sub_unchecked(1, v);
8100 +}
8101
8102 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8103 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8104
8105 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8106 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8107 +{
8108 + return cmpxchg(&v->counter, old, new);
8109 +}
8110 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8111 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8112 +{
8113 + return xchg(&v->counter, new);
8114 +}
8115
8116 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8117 {
8118 - int c, old;
8119 + int c, old, new;
8120 c = atomic_read(v);
8121 for (;;) {
8122 - if (unlikely(c == (u)))
8123 + if (unlikely(c == u))
8124 break;
8125 - old = atomic_cmpxchg((v), c, c + (a));
8126 +
8127 + asm volatile("addcc %2, %0, %0\n"
8128 +
8129 +#ifdef CONFIG_PAX_REFCOUNT
8130 + "tvs %%icc, 6\n"
8131 +#endif
8132 +
8133 + : "=r" (new)
8134 + : "0" (c), "ir" (a)
8135 + : "cc");
8136 +
8137 + old = atomic_cmpxchg(v, c, new);
8138 if (likely(old == c))
8139 break;
8140 c = old;
8141 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8142 #define atomic64_cmpxchg(v, o, n) \
8143 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8144 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8145 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8146 +{
8147 + return xchg(&v->counter, new);
8148 +}
8149
8150 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8151 {
8152 - long c, old;
8153 + long c, old, new;
8154 c = atomic64_read(v);
8155 for (;;) {
8156 - if (unlikely(c == (u)))
8157 + if (unlikely(c == u))
8158 break;
8159 - old = atomic64_cmpxchg((v), c, c + (a));
8160 +
8161 + asm volatile("addcc %2, %0, %0\n"
8162 +
8163 +#ifdef CONFIG_PAX_REFCOUNT
8164 + "tvs %%xcc, 6\n"
8165 +#endif
8166 +
8167 + : "=r" (new)
8168 + : "0" (c), "ir" (a)
8169 + : "cc");
8170 +
8171 + old = atomic64_cmpxchg(v, c, new);
8172 if (likely(old == c))
8173 break;
8174 c = old;
8175 }
8176 - return c != (u);
8177 + return c != u;
8178 }
8179
8180 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8181 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8182 index 5bb6991..5c2132e 100644
8183 --- a/arch/sparc/include/asm/cache.h
8184 +++ b/arch/sparc/include/asm/cache.h
8185 @@ -7,10 +7,12 @@
8186 #ifndef _SPARC_CACHE_H
8187 #define _SPARC_CACHE_H
8188
8189 +#include <linux/const.h>
8190 +
8191 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8192
8193 #define L1_CACHE_SHIFT 5
8194 -#define L1_CACHE_BYTES 32
8195 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8196
8197 #ifdef CONFIG_SPARC32
8198 #define SMP_CACHE_BYTES_SHIFT 5
8199 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8200 index ac74a2c..a9e58af 100644
8201 --- a/arch/sparc/include/asm/elf_32.h
8202 +++ b/arch/sparc/include/asm/elf_32.h
8203 @@ -114,6 +114,13 @@ typedef struct {
8204
8205 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8206
8207 +#ifdef CONFIG_PAX_ASLR
8208 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8209 +
8210 +#define PAX_DELTA_MMAP_LEN 16
8211 +#define PAX_DELTA_STACK_LEN 16
8212 +#endif
8213 +
8214 /* This yields a mask that user programs can use to figure out what
8215 instruction set this cpu supports. This can NOT be done in userspace
8216 on Sparc. */
8217 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8218 index 370ca1e..d4f4a98 100644
8219 --- a/arch/sparc/include/asm/elf_64.h
8220 +++ b/arch/sparc/include/asm/elf_64.h
8221 @@ -189,6 +189,13 @@ typedef struct {
8222 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8223 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8224
8225 +#ifdef CONFIG_PAX_ASLR
8226 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8227 +
8228 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8229 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8230 +#endif
8231 +
8232 extern unsigned long sparc64_elf_hwcap;
8233 #define ELF_HWCAP sparc64_elf_hwcap
8234
8235 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8236 index 9b1c36d..209298b 100644
8237 --- a/arch/sparc/include/asm/pgalloc_32.h
8238 +++ b/arch/sparc/include/asm/pgalloc_32.h
8239 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8240 }
8241
8242 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8243 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8244
8245 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8246 unsigned long address)
8247 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8248 index bcfe063..b333142 100644
8249 --- a/arch/sparc/include/asm/pgalloc_64.h
8250 +++ b/arch/sparc/include/asm/pgalloc_64.h
8251 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8252 }
8253
8254 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8255 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8256
8257 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8258 {
8259 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8260 index 6fc1348..390c50a 100644
8261 --- a/arch/sparc/include/asm/pgtable_32.h
8262 +++ b/arch/sparc/include/asm/pgtable_32.h
8263 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8264 #define PAGE_SHARED SRMMU_PAGE_SHARED
8265 #define PAGE_COPY SRMMU_PAGE_COPY
8266 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8267 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8268 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8269 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8270 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8271
8272 /* Top-level page directory - dummy used by init-mm.
8273 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8274
8275 /* xwr */
8276 #define __P000 PAGE_NONE
8277 -#define __P001 PAGE_READONLY
8278 -#define __P010 PAGE_COPY
8279 -#define __P011 PAGE_COPY
8280 +#define __P001 PAGE_READONLY_NOEXEC
8281 +#define __P010 PAGE_COPY_NOEXEC
8282 +#define __P011 PAGE_COPY_NOEXEC
8283 #define __P100 PAGE_READONLY
8284 #define __P101 PAGE_READONLY
8285 #define __P110 PAGE_COPY
8286 #define __P111 PAGE_COPY
8287
8288 #define __S000 PAGE_NONE
8289 -#define __S001 PAGE_READONLY
8290 -#define __S010 PAGE_SHARED
8291 -#define __S011 PAGE_SHARED
8292 +#define __S001 PAGE_READONLY_NOEXEC
8293 +#define __S010 PAGE_SHARED_NOEXEC
8294 +#define __S011 PAGE_SHARED_NOEXEC
8295 #define __S100 PAGE_READONLY
8296 #define __S101 PAGE_READONLY
8297 #define __S110 PAGE_SHARED
8298 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8299 index 79da178..c2eede8 100644
8300 --- a/arch/sparc/include/asm/pgtsrmmu.h
8301 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8302 @@ -115,6 +115,11 @@
8303 SRMMU_EXEC | SRMMU_REF)
8304 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8305 SRMMU_EXEC | SRMMU_REF)
8306 +
8307 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8308 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8309 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8310 +
8311 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8312 SRMMU_DIRTY | SRMMU_REF)
8313
8314 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8315 index 9689176..63c18ea 100644
8316 --- a/arch/sparc/include/asm/spinlock_64.h
8317 +++ b/arch/sparc/include/asm/spinlock_64.h
8318 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8319
8320 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8321
8322 -static void inline arch_read_lock(arch_rwlock_t *lock)
8323 +static inline void arch_read_lock(arch_rwlock_t *lock)
8324 {
8325 unsigned long tmp1, tmp2;
8326
8327 __asm__ __volatile__ (
8328 "1: ldsw [%2], %0\n"
8329 " brlz,pn %0, 2f\n"
8330 -"4: add %0, 1, %1\n"
8331 +"4: addcc %0, 1, %1\n"
8332 +
8333 +#ifdef CONFIG_PAX_REFCOUNT
8334 +" tvs %%icc, 6\n"
8335 +#endif
8336 +
8337 " cas [%2], %0, %1\n"
8338 " cmp %0, %1\n"
8339 " bne,pn %%icc, 1b\n"
8340 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8341 " .previous"
8342 : "=&r" (tmp1), "=&r" (tmp2)
8343 : "r" (lock)
8344 - : "memory");
8345 + : "memory", "cc");
8346 }
8347
8348 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8349 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8350 {
8351 int tmp1, tmp2;
8352
8353 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8354 "1: ldsw [%2], %0\n"
8355 " brlz,a,pn %0, 2f\n"
8356 " mov 0, %0\n"
8357 -" add %0, 1, %1\n"
8358 +" addcc %0, 1, %1\n"
8359 +
8360 +#ifdef CONFIG_PAX_REFCOUNT
8361 +" tvs %%icc, 6\n"
8362 +#endif
8363 +
8364 " cas [%2], %0, %1\n"
8365 " cmp %0, %1\n"
8366 " bne,pn %%icc, 1b\n"
8367 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8368 return tmp1;
8369 }
8370
8371 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8372 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8373 {
8374 unsigned long tmp1, tmp2;
8375
8376 __asm__ __volatile__(
8377 "1: lduw [%2], %0\n"
8378 -" sub %0, 1, %1\n"
8379 +" subcc %0, 1, %1\n"
8380 +
8381 +#ifdef CONFIG_PAX_REFCOUNT
8382 +" tvs %%icc, 6\n"
8383 +#endif
8384 +
8385 " cas [%2], %0, %1\n"
8386 " cmp %0, %1\n"
8387 " bne,pn %%xcc, 1b\n"
8388 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8389 : "memory");
8390 }
8391
8392 -static void inline arch_write_lock(arch_rwlock_t *lock)
8393 +static inline void arch_write_lock(arch_rwlock_t *lock)
8394 {
8395 unsigned long mask, tmp1, tmp2;
8396
8397 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8398 : "memory");
8399 }
8400
8401 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8402 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8403 {
8404 __asm__ __volatile__(
8405 " stw %%g0, [%0]"
8406 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8407 : "memory");
8408 }
8409
8410 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8411 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8412 {
8413 unsigned long mask, tmp1, tmp2, result;
8414
8415 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8416 index 25849ae..924c54b 100644
8417 --- a/arch/sparc/include/asm/thread_info_32.h
8418 +++ b/arch/sparc/include/asm/thread_info_32.h
8419 @@ -49,6 +49,8 @@ struct thread_info {
8420 unsigned long w_saved;
8421
8422 struct restart_block restart_block;
8423 +
8424 + unsigned long lowest_stack;
8425 };
8426
8427 /*
8428 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8429 index 269bd92..e46a9b8 100644
8430 --- a/arch/sparc/include/asm/thread_info_64.h
8431 +++ b/arch/sparc/include/asm/thread_info_64.h
8432 @@ -63,6 +63,8 @@ struct thread_info {
8433 struct pt_regs *kern_una_regs;
8434 unsigned int kern_una_insn;
8435
8436 + unsigned long lowest_stack;
8437 +
8438 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8439 };
8440
8441 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8442 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8443 /* flag bit 6 is available */
8444 #define TIF_32BIT 7 /* 32-bit binary */
8445 -/* flag bit 8 is available */
8446 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8447 #define TIF_SECCOMP 9 /* secure computing */
8448 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8449 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8450 +
8451 /* NOTE: Thread flags >= 12 should be ones we have no interest
8452 * in using in assembly, else we can't use the mask as
8453 * an immediate value in instructions such as andcc.
8454 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8455 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8456 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8457 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8458 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8459
8460 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8461 _TIF_DO_NOTIFY_RESUME_MASK | \
8462 _TIF_NEED_RESCHED)
8463 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8464
8465 +#define _TIF_WORK_SYSCALL \
8466 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8467 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8468 +
8469 +
8470 /*
8471 * Thread-synchronous status.
8472 *
8473 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8474 index 0167d26..767bb0c 100644
8475 --- a/arch/sparc/include/asm/uaccess.h
8476 +++ b/arch/sparc/include/asm/uaccess.h
8477 @@ -1,5 +1,6 @@
8478 #ifndef ___ASM_SPARC_UACCESS_H
8479 #define ___ASM_SPARC_UACCESS_H
8480 +
8481 #if defined(__sparc__) && defined(__arch64__)
8482 #include <asm/uaccess_64.h>
8483 #else
8484 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8485 index 53a28dd..50c38c3 100644
8486 --- a/arch/sparc/include/asm/uaccess_32.h
8487 +++ b/arch/sparc/include/asm/uaccess_32.h
8488 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8489
8490 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8491 {
8492 - if (n && __access_ok((unsigned long) to, n))
8493 + if ((long)n < 0)
8494 + return n;
8495 +
8496 + if (n && __access_ok((unsigned long) to, n)) {
8497 + if (!__builtin_constant_p(n))
8498 + check_object_size(from, n, true);
8499 return __copy_user(to, (__force void __user *) from, n);
8500 - else
8501 + } else
8502 return n;
8503 }
8504
8505 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8506 {
8507 + if ((long)n < 0)
8508 + return n;
8509 +
8510 + if (!__builtin_constant_p(n))
8511 + check_object_size(from, n, true);
8512 +
8513 return __copy_user(to, (__force void __user *) from, n);
8514 }
8515
8516 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8517 {
8518 - if (n && __access_ok((unsigned long) from, n))
8519 + if ((long)n < 0)
8520 + return n;
8521 +
8522 + if (n && __access_ok((unsigned long) from, n)) {
8523 + if (!__builtin_constant_p(n))
8524 + check_object_size(to, n, false);
8525 return __copy_user((__force void __user *) to, from, n);
8526 - else
8527 + } else
8528 return n;
8529 }
8530
8531 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8532 {
8533 + if ((long)n < 0)
8534 + return n;
8535 +
8536 return __copy_user((__force void __user *) to, from, n);
8537 }
8538
8539 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8540 index e562d3c..191f176 100644
8541 --- a/arch/sparc/include/asm/uaccess_64.h
8542 +++ b/arch/sparc/include/asm/uaccess_64.h
8543 @@ -10,6 +10,7 @@
8544 #include <linux/compiler.h>
8545 #include <linux/string.h>
8546 #include <linux/thread_info.h>
8547 +#include <linux/kernel.h>
8548 #include <asm/asi.h>
8549 #include <asm/spitfire.h>
8550 #include <asm-generic/uaccess-unaligned.h>
8551 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8552 static inline unsigned long __must_check
8553 copy_from_user(void *to, const void __user *from, unsigned long size)
8554 {
8555 - unsigned long ret = ___copy_from_user(to, from, size);
8556 + unsigned long ret;
8557
8558 + if ((long)size < 0 || size > INT_MAX)
8559 + return size;
8560 +
8561 + if (!__builtin_constant_p(size))
8562 + check_object_size(to, size, false);
8563 +
8564 + ret = ___copy_from_user(to, from, size);
8565 if (unlikely(ret))
8566 ret = copy_from_user_fixup(to, from, size);
8567
8568 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8569 static inline unsigned long __must_check
8570 copy_to_user(void __user *to, const void *from, unsigned long size)
8571 {
8572 - unsigned long ret = ___copy_to_user(to, from, size);
8573 + unsigned long ret;
8574
8575 + if ((long)size < 0 || size > INT_MAX)
8576 + return size;
8577 +
8578 + if (!__builtin_constant_p(size))
8579 + check_object_size(from, size, true);
8580 +
8581 + ret = ___copy_to_user(to, from, size);
8582 if (unlikely(ret))
8583 ret = copy_to_user_fixup(to, from, size);
8584 return ret;
8585 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8586 index 6cf591b..b49e65a 100644
8587 --- a/arch/sparc/kernel/Makefile
8588 +++ b/arch/sparc/kernel/Makefile
8589 @@ -3,7 +3,7 @@
8590 #
8591
8592 asflags-y := -ansi
8593 -ccflags-y := -Werror
8594 +#ccflags-y := -Werror
8595
8596 extra-y := head_$(BITS).o
8597
8598 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8599 index be8e862..5b50b12 100644
8600 --- a/arch/sparc/kernel/process_32.c
8601 +++ b/arch/sparc/kernel/process_32.c
8602 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8603
8604 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8605 r->psr, r->pc, r->npc, r->y, print_tainted());
8606 - printk("PC: <%pS>\n", (void *) r->pc);
8607 + printk("PC: <%pA>\n", (void *) r->pc);
8608 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8609 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8610 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8611 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8612 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8613 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8614 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8615 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8616
8617 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8618 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8619 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8620 rw = (struct reg_window32 *) fp;
8621 pc = rw->ins[7];
8622 printk("[%08lx : ", pc);
8623 - printk("%pS ] ", (void *) pc);
8624 + printk("%pA ] ", (void *) pc);
8625 fp = rw->ins[6];
8626 } while (++count < 16);
8627 printk("\n");
8628 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8629 index cdb80b2..5ca141d 100644
8630 --- a/arch/sparc/kernel/process_64.c
8631 +++ b/arch/sparc/kernel/process_64.c
8632 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8633 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8634 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8635 if (regs->tstate & TSTATE_PRIV)
8636 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8637 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8638 }
8639
8640 void show_regs(struct pt_regs *regs)
8641 {
8642 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8643 regs->tpc, regs->tnpc, regs->y, print_tainted());
8644 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8645 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8646 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8647 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8648 regs->u_regs[3]);
8649 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8650 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8651 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8652 regs->u_regs[15]);
8653 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8654 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8655 show_regwindow(regs);
8656 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8657 }
8658 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8659 ((tp && tp->task) ? tp->task->pid : -1));
8660
8661 if (gp->tstate & TSTATE_PRIV) {
8662 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8663 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8664 (void *) gp->tpc,
8665 (void *) gp->o7,
8666 (void *) gp->i7,
8667 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8668 index 1303021..c2a6321 100644
8669 --- a/arch/sparc/kernel/prom_common.c
8670 +++ b/arch/sparc/kernel/prom_common.c
8671 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8672
8673 unsigned int prom_early_allocated __initdata;
8674
8675 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8676 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8677 .nextprop = prom_common_nextprop,
8678 .getproplen = prom_getproplen,
8679 .getproperty = prom_getproperty,
8680 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8681 index 7ff45e4..a58f271 100644
8682 --- a/arch/sparc/kernel/ptrace_64.c
8683 +++ b/arch/sparc/kernel/ptrace_64.c
8684 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8685 return ret;
8686 }
8687
8688 +#ifdef CONFIG_GRKERNSEC_SETXID
8689 +extern void gr_delayed_cred_worker(void);
8690 +#endif
8691 +
8692 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8693 {
8694 int ret = 0;
8695 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8696 /* do the secure computing check first */
8697 secure_computing_strict(regs->u_regs[UREG_G1]);
8698
8699 +#ifdef CONFIG_GRKERNSEC_SETXID
8700 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8701 + gr_delayed_cred_worker();
8702 +#endif
8703 +
8704 if (test_thread_flag(TIF_SYSCALL_TRACE))
8705 ret = tracehook_report_syscall_entry(regs);
8706
8707 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8708
8709 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8710 {
8711 +#ifdef CONFIG_GRKERNSEC_SETXID
8712 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8713 + gr_delayed_cred_worker();
8714 +#endif
8715 +
8716 audit_syscall_exit(regs);
8717
8718 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8719 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8720 index 2da0bdc..79128d2 100644
8721 --- a/arch/sparc/kernel/sys_sparc_32.c
8722 +++ b/arch/sparc/kernel/sys_sparc_32.c
8723 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8724 if (len > TASK_SIZE - PAGE_SIZE)
8725 return -ENOMEM;
8726 if (!addr)
8727 - addr = TASK_UNMAPPED_BASE;
8728 + addr = current->mm->mmap_base;
8729
8730 info.flags = 0;
8731 info.length = len;
8732 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8733 index 708bc29..f0129cb 100644
8734 --- a/arch/sparc/kernel/sys_sparc_64.c
8735 +++ b/arch/sparc/kernel/sys_sparc_64.c
8736 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8737 struct vm_area_struct * vma;
8738 unsigned long task_size = TASK_SIZE;
8739 int do_color_align;
8740 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8741 struct vm_unmapped_area_info info;
8742
8743 if (flags & MAP_FIXED) {
8744 /* We do not accept a shared mapping if it would violate
8745 * cache aliasing constraints.
8746 */
8747 - if ((flags & MAP_SHARED) &&
8748 + if ((filp || (flags & MAP_SHARED)) &&
8749 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8750 return -EINVAL;
8751 return addr;
8752 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8753 if (filp || (flags & MAP_SHARED))
8754 do_color_align = 1;
8755
8756 +#ifdef CONFIG_PAX_RANDMMAP
8757 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8758 +#endif
8759 +
8760 if (addr) {
8761 if (do_color_align)
8762 addr = COLOR_ALIGN(addr, pgoff);
8763 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8764 addr = PAGE_ALIGN(addr);
8765
8766 vma = find_vma(mm, addr);
8767 - if (task_size - len >= addr &&
8768 - (!vma || addr + len <= vma->vm_start))
8769 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8770 return addr;
8771 }
8772
8773 info.flags = 0;
8774 info.length = len;
8775 - info.low_limit = TASK_UNMAPPED_BASE;
8776 + info.low_limit = mm->mmap_base;
8777 info.high_limit = min(task_size, VA_EXCLUDE_START);
8778 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8779 info.align_offset = pgoff << PAGE_SHIFT;
8780 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8781 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8782 VM_BUG_ON(addr != -ENOMEM);
8783 info.low_limit = VA_EXCLUDE_END;
8784 +
8785 +#ifdef CONFIG_PAX_RANDMMAP
8786 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8787 + info.low_limit += mm->delta_mmap;
8788 +#endif
8789 +
8790 info.high_limit = task_size;
8791 addr = vm_unmapped_area(&info);
8792 }
8793 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8794 unsigned long task_size = STACK_TOP32;
8795 unsigned long addr = addr0;
8796 int do_color_align;
8797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8798 struct vm_unmapped_area_info info;
8799
8800 /* This should only ever run for 32-bit processes. */
8801 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8802 /* We do not accept a shared mapping if it would violate
8803 * cache aliasing constraints.
8804 */
8805 - if ((flags & MAP_SHARED) &&
8806 + if ((filp || (flags & MAP_SHARED)) &&
8807 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8808 return -EINVAL;
8809 return addr;
8810 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8811 if (filp || (flags & MAP_SHARED))
8812 do_color_align = 1;
8813
8814 +#ifdef CONFIG_PAX_RANDMMAP
8815 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8816 +#endif
8817 +
8818 /* requesting a specific address */
8819 if (addr) {
8820 if (do_color_align)
8821 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8822 addr = PAGE_ALIGN(addr);
8823
8824 vma = find_vma(mm, addr);
8825 - if (task_size - len >= addr &&
8826 - (!vma || addr + len <= vma->vm_start))
8827 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8828 return addr;
8829 }
8830
8831 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8832 VM_BUG_ON(addr != -ENOMEM);
8833 info.flags = 0;
8834 info.low_limit = TASK_UNMAPPED_BASE;
8835 +
8836 +#ifdef CONFIG_PAX_RANDMMAP
8837 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8838 + info.low_limit += mm->delta_mmap;
8839 +#endif
8840 +
8841 info.high_limit = STACK_TOP32;
8842 addr = vm_unmapped_area(&info);
8843 }
8844 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8845 {
8846 unsigned long rnd = 0UL;
8847
8848 +#ifdef CONFIG_PAX_RANDMMAP
8849 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8850 +#endif
8851 +
8852 if (current->flags & PF_RANDOMIZE) {
8853 unsigned long val = get_random_int();
8854 if (test_thread_flag(TIF_32BIT))
8855 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8856 gap == RLIM_INFINITY ||
8857 sysctl_legacy_va_layout) {
8858 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8859 +
8860 +#ifdef CONFIG_PAX_RANDMMAP
8861 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8862 + mm->mmap_base += mm->delta_mmap;
8863 +#endif
8864 +
8865 mm->get_unmapped_area = arch_get_unmapped_area;
8866 mm->unmap_area = arch_unmap_area;
8867 } else {
8868 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8869 gap = (task_size / 6 * 5);
8870
8871 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8872 +
8873 +#ifdef CONFIG_PAX_RANDMMAP
8874 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8875 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8876 +#endif
8877 +
8878 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8879 mm->unmap_area = arch_unmap_area_topdown;
8880 }
8881 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8882 index e0fed77..604a7e5 100644
8883 --- a/arch/sparc/kernel/syscalls.S
8884 +++ b/arch/sparc/kernel/syscalls.S
8885 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8886 #endif
8887 .align 32
8888 1: ldx [%g6 + TI_FLAGS], %l5
8889 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8890 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8891 be,pt %icc, rtrap
8892 nop
8893 call syscall_trace_leave
8894 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8895
8896 srl %i5, 0, %o5 ! IEU1
8897 srl %i2, 0, %o2 ! IEU0 Group
8898 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8899 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8900 bne,pn %icc, linux_syscall_trace32 ! CTI
8901 mov %i0, %l5 ! IEU1
8902 call %l7 ! CTI Group brk forced
8903 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8904
8905 mov %i3, %o3 ! IEU1
8906 mov %i4, %o4 ! IEU0 Group
8907 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8908 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8909 bne,pn %icc, linux_syscall_trace ! CTI Group
8910 mov %i0, %l5 ! IEU0
8911 2: call %l7 ! CTI Group brk forced
8912 @@ -229,7 +229,7 @@ ret_sys_call:
8913
8914 cmp %o0, -ERESTART_RESTARTBLOCK
8915 bgeu,pn %xcc, 1f
8916 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8917 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8918 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8919
8920 2:
8921 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8922 index 654e8aa..45f431b 100644
8923 --- a/arch/sparc/kernel/sysfs.c
8924 +++ b/arch/sparc/kernel/sysfs.c
8925 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8926 return NOTIFY_OK;
8927 }
8928
8929 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8930 +static struct notifier_block sysfs_cpu_nb = {
8931 .notifier_call = sysfs_cpu_notify,
8932 };
8933
8934 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8935 index a5785ea..405c5f7 100644
8936 --- a/arch/sparc/kernel/traps_32.c
8937 +++ b/arch/sparc/kernel/traps_32.c
8938 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8939 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8940 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8941
8942 +extern void gr_handle_kernel_exploit(void);
8943 +
8944 void die_if_kernel(char *str, struct pt_regs *regs)
8945 {
8946 static int die_counter;
8947 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8948 count++ < 30 &&
8949 (((unsigned long) rw) >= PAGE_OFFSET) &&
8950 !(((unsigned long) rw) & 0x7)) {
8951 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8952 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8953 (void *) rw->ins[7]);
8954 rw = (struct reg_window32 *)rw->ins[6];
8955 }
8956 }
8957 printk("Instruction DUMP:");
8958 instruction_dump ((unsigned long *) regs->pc);
8959 - if(regs->psr & PSR_PS)
8960 + if(regs->psr & PSR_PS) {
8961 + gr_handle_kernel_exploit();
8962 do_exit(SIGKILL);
8963 + }
8964 do_exit(SIGSEGV);
8965 }
8966
8967 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8968 index e7ecf15..6520e65 100644
8969 --- a/arch/sparc/kernel/traps_64.c
8970 +++ b/arch/sparc/kernel/traps_64.c
8971 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8972 i + 1,
8973 p->trapstack[i].tstate, p->trapstack[i].tpc,
8974 p->trapstack[i].tnpc, p->trapstack[i].tt);
8975 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8976 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8977 }
8978 }
8979
8980 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8981
8982 lvl -= 0x100;
8983 if (regs->tstate & TSTATE_PRIV) {
8984 +
8985 +#ifdef CONFIG_PAX_REFCOUNT
8986 + if (lvl == 6)
8987 + pax_report_refcount_overflow(regs);
8988 +#endif
8989 +
8990 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8991 die_if_kernel(buffer, regs);
8992 }
8993 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8994 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8995 {
8996 char buffer[32];
8997 -
8998 +
8999 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9000 0, lvl, SIGTRAP) == NOTIFY_STOP)
9001 return;
9002
9003 +#ifdef CONFIG_PAX_REFCOUNT
9004 + if (lvl == 6)
9005 + pax_report_refcount_overflow(regs);
9006 +#endif
9007 +
9008 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9009
9010 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9011 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9012 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9013 printk("%s" "ERROR(%d): ",
9014 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9015 - printk("TPC<%pS>\n", (void *) regs->tpc);
9016 + printk("TPC<%pA>\n", (void *) regs->tpc);
9017 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9018 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9019 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9020 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9021 smp_processor_id(),
9022 (type & 0x1) ? 'I' : 'D',
9023 regs->tpc);
9024 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9025 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9026 panic("Irrecoverable Cheetah+ parity error.");
9027 }
9028
9029 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9030 smp_processor_id(),
9031 (type & 0x1) ? 'I' : 'D',
9032 regs->tpc);
9033 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9034 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9035 }
9036
9037 struct sun4v_error_entry {
9038 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
9039
9040 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
9041 regs->tpc, tl);
9042 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
9043 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
9044 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9045 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
9046 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
9047 (void *) regs->u_regs[UREG_I7]);
9048 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
9049 "pte[%lx] error[%lx]\n",
9050 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
9051
9052 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
9053 regs->tpc, tl);
9054 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9055 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9056 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9057 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9058 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9059 (void *) regs->u_regs[UREG_I7]);
9060 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9061 "pte[%lx] error[%lx]\n",
9062 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9063 fp = (unsigned long)sf->fp + STACK_BIAS;
9064 }
9065
9066 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9067 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9068 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9069 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9070 int index = tsk->curr_ret_stack;
9071 if (tsk->ret_stack && index >= graph) {
9072 pc = tsk->ret_stack[index - graph].ret;
9073 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9074 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9075 graph++;
9076 }
9077 }
9078 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9079 return (struct reg_window *) (fp + STACK_BIAS);
9080 }
9081
9082 +extern void gr_handle_kernel_exploit(void);
9083 +
9084 void die_if_kernel(char *str, struct pt_regs *regs)
9085 {
9086 static int die_counter;
9087 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9088 while (rw &&
9089 count++ < 30 &&
9090 kstack_valid(tp, (unsigned long) rw)) {
9091 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9092 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9093 (void *) rw->ins[7]);
9094
9095 rw = kernel_stack_up(rw);
9096 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9097 }
9098 user_instruction_dump ((unsigned int __user *) regs->tpc);
9099 }
9100 - if (regs->tstate & TSTATE_PRIV)
9101 + if (regs->tstate & TSTATE_PRIV) {
9102 + gr_handle_kernel_exploit();
9103 do_exit(SIGKILL);
9104 + }
9105 do_exit(SIGSEGV);
9106 }
9107 EXPORT_SYMBOL(die_if_kernel);
9108 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9109 index 8201c25e..072a2a7 100644
9110 --- a/arch/sparc/kernel/unaligned_64.c
9111 +++ b/arch/sparc/kernel/unaligned_64.c
9112 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9113 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9114
9115 if (__ratelimit(&ratelimit)) {
9116 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9117 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9118 regs->tpc, (void *) regs->tpc);
9119 }
9120 }
9121 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9122 index eb1624b..f9f4ddb 100644
9123 --- a/arch/sparc/kernel/us3_cpufreq.c
9124 +++ b/arch/sparc/kernel/us3_cpufreq.c
9125 @@ -18,14 +18,12 @@
9126 #include <asm/head.h>
9127 #include <asm/timer.h>
9128
9129 -static struct cpufreq_driver *cpufreq_us3_driver;
9130 -
9131 struct us3_freq_percpu_info {
9132 struct cpufreq_frequency_table table[4];
9133 };
9134
9135 /* Indexed by cpu number. */
9136 -static struct us3_freq_percpu_info *us3_freq_table;
9137 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9138
9139 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9140 * in the Safari config register.
9141 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9142
9143 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9144 {
9145 - if (cpufreq_us3_driver)
9146 - us3_set_cpu_divider_index(policy->cpu, 0);
9147 + us3_set_cpu_divider_index(policy->cpu, 0);
9148
9149 return 0;
9150 }
9151
9152 +static int __init us3_freq_init(void);
9153 +static void __exit us3_freq_exit(void);
9154 +
9155 +static struct cpufreq_driver cpufreq_us3_driver = {
9156 + .init = us3_freq_cpu_init,
9157 + .verify = us3_freq_verify,
9158 + .target = us3_freq_target,
9159 + .get = us3_freq_get,
9160 + .exit = us3_freq_cpu_exit,
9161 + .owner = THIS_MODULE,
9162 + .name = "UltraSPARC-III",
9163 +
9164 +};
9165 +
9166 static int __init us3_freq_init(void)
9167 {
9168 unsigned long manuf, impl, ver;
9169 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9170 (impl == CHEETAH_IMPL ||
9171 impl == CHEETAH_PLUS_IMPL ||
9172 impl == JAGUAR_IMPL ||
9173 - impl == PANTHER_IMPL)) {
9174 - struct cpufreq_driver *driver;
9175 -
9176 - ret = -ENOMEM;
9177 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9178 - if (!driver)
9179 - goto err_out;
9180 -
9181 - us3_freq_table = kzalloc(
9182 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9183 - GFP_KERNEL);
9184 - if (!us3_freq_table)
9185 - goto err_out;
9186 -
9187 - driver->init = us3_freq_cpu_init;
9188 - driver->verify = us3_freq_verify;
9189 - driver->target = us3_freq_target;
9190 - driver->get = us3_freq_get;
9191 - driver->exit = us3_freq_cpu_exit;
9192 - driver->owner = THIS_MODULE,
9193 - strcpy(driver->name, "UltraSPARC-III");
9194 -
9195 - cpufreq_us3_driver = driver;
9196 - ret = cpufreq_register_driver(driver);
9197 - if (ret)
9198 - goto err_out;
9199 -
9200 - return 0;
9201 -
9202 -err_out:
9203 - if (driver) {
9204 - kfree(driver);
9205 - cpufreq_us3_driver = NULL;
9206 - }
9207 - kfree(us3_freq_table);
9208 - us3_freq_table = NULL;
9209 - return ret;
9210 - }
9211 + impl == PANTHER_IMPL))
9212 + return cpufreq_register_driver(cpufreq_us3_driver);
9213
9214 return -ENODEV;
9215 }
9216
9217 static void __exit us3_freq_exit(void)
9218 {
9219 - if (cpufreq_us3_driver) {
9220 - cpufreq_unregister_driver(cpufreq_us3_driver);
9221 - kfree(cpufreq_us3_driver);
9222 - cpufreq_us3_driver = NULL;
9223 - kfree(us3_freq_table);
9224 - us3_freq_table = NULL;
9225 - }
9226 + cpufreq_unregister_driver(cpufreq_us3_driver);
9227 }
9228
9229 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9230 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9231 index 8410065f2..4fd4ca22 100644
9232 --- a/arch/sparc/lib/Makefile
9233 +++ b/arch/sparc/lib/Makefile
9234 @@ -2,7 +2,7 @@
9235 #
9236
9237 asflags-y := -ansi -DST_DIV0=0x02
9238 -ccflags-y := -Werror
9239 +#ccflags-y := -Werror
9240
9241 lib-$(CONFIG_SPARC32) += ashrdi3.o
9242 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9243 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9244 index 85c233d..68500e0 100644
9245 --- a/arch/sparc/lib/atomic_64.S
9246 +++ b/arch/sparc/lib/atomic_64.S
9247 @@ -17,7 +17,12 @@
9248 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9249 BACKOFF_SETUP(%o2)
9250 1: lduw [%o1], %g1
9251 - add %g1, %o0, %g7
9252 + addcc %g1, %o0, %g7
9253 +
9254 +#ifdef CONFIG_PAX_REFCOUNT
9255 + tvs %icc, 6
9256 +#endif
9257 +
9258 cas [%o1], %g1, %g7
9259 cmp %g1, %g7
9260 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9261 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9262 2: BACKOFF_SPIN(%o2, %o3, 1b)
9263 ENDPROC(atomic_add)
9264
9265 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9266 + BACKOFF_SETUP(%o2)
9267 +1: lduw [%o1], %g1
9268 + add %g1, %o0, %g7
9269 + cas [%o1], %g1, %g7
9270 + cmp %g1, %g7
9271 + bne,pn %icc, 2f
9272 + nop
9273 + retl
9274 + nop
9275 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9276 +ENDPROC(atomic_add_unchecked)
9277 +
9278 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9279 BACKOFF_SETUP(%o2)
9280 1: lduw [%o1], %g1
9281 - sub %g1, %o0, %g7
9282 + subcc %g1, %o0, %g7
9283 +
9284 +#ifdef CONFIG_PAX_REFCOUNT
9285 + tvs %icc, 6
9286 +#endif
9287 +
9288 cas [%o1], %g1, %g7
9289 cmp %g1, %g7
9290 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9291 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9292 2: BACKOFF_SPIN(%o2, %o3, 1b)
9293 ENDPROC(atomic_sub)
9294
9295 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9296 + BACKOFF_SETUP(%o2)
9297 +1: lduw [%o1], %g1
9298 + sub %g1, %o0, %g7
9299 + cas [%o1], %g1, %g7
9300 + cmp %g1, %g7
9301 + bne,pn %icc, 2f
9302 + nop
9303 + retl
9304 + nop
9305 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9306 +ENDPROC(atomic_sub_unchecked)
9307 +
9308 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9309 BACKOFF_SETUP(%o2)
9310 1: lduw [%o1], %g1
9311 - add %g1, %o0, %g7
9312 + addcc %g1, %o0, %g7
9313 +
9314 +#ifdef CONFIG_PAX_REFCOUNT
9315 + tvs %icc, 6
9316 +#endif
9317 +
9318 cas [%o1], %g1, %g7
9319 cmp %g1, %g7
9320 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9321 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9322 2: BACKOFF_SPIN(%o2, %o3, 1b)
9323 ENDPROC(atomic_add_ret)
9324
9325 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9326 + BACKOFF_SETUP(%o2)
9327 +1: lduw [%o1], %g1
9328 + addcc %g1, %o0, %g7
9329 + cas [%o1], %g1, %g7
9330 + cmp %g1, %g7
9331 + bne,pn %icc, 2f
9332 + add %g7, %o0, %g7
9333 + sra %g7, 0, %o0
9334 + retl
9335 + nop
9336 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9337 +ENDPROC(atomic_add_ret_unchecked)
9338 +
9339 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9340 BACKOFF_SETUP(%o2)
9341 1: lduw [%o1], %g1
9342 - sub %g1, %o0, %g7
9343 + subcc %g1, %o0, %g7
9344 +
9345 +#ifdef CONFIG_PAX_REFCOUNT
9346 + tvs %icc, 6
9347 +#endif
9348 +
9349 cas [%o1], %g1, %g7
9350 cmp %g1, %g7
9351 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9352 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9353 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9354 BACKOFF_SETUP(%o2)
9355 1: ldx [%o1], %g1
9356 - add %g1, %o0, %g7
9357 + addcc %g1, %o0, %g7
9358 +
9359 +#ifdef CONFIG_PAX_REFCOUNT
9360 + tvs %xcc, 6
9361 +#endif
9362 +
9363 casx [%o1], %g1, %g7
9364 cmp %g1, %g7
9365 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9366 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9367 2: BACKOFF_SPIN(%o2, %o3, 1b)
9368 ENDPROC(atomic64_add)
9369
9370 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9371 + BACKOFF_SETUP(%o2)
9372 +1: ldx [%o1], %g1
9373 + addcc %g1, %o0, %g7
9374 + casx [%o1], %g1, %g7
9375 + cmp %g1, %g7
9376 + bne,pn %xcc, 2f
9377 + nop
9378 + retl
9379 + nop
9380 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9381 +ENDPROC(atomic64_add_unchecked)
9382 +
9383 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9384 BACKOFF_SETUP(%o2)
9385 1: ldx [%o1], %g1
9386 - sub %g1, %o0, %g7
9387 + subcc %g1, %o0, %g7
9388 +
9389 +#ifdef CONFIG_PAX_REFCOUNT
9390 + tvs %xcc, 6
9391 +#endif
9392 +
9393 casx [%o1], %g1, %g7
9394 cmp %g1, %g7
9395 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9396 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9397 2: BACKOFF_SPIN(%o2, %o3, 1b)
9398 ENDPROC(atomic64_sub)
9399
9400 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9401 + BACKOFF_SETUP(%o2)
9402 +1: ldx [%o1], %g1
9403 + subcc %g1, %o0, %g7
9404 + casx [%o1], %g1, %g7
9405 + cmp %g1, %g7
9406 + bne,pn %xcc, 2f
9407 + nop
9408 + retl
9409 + nop
9410 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9411 +ENDPROC(atomic64_sub_unchecked)
9412 +
9413 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9414 BACKOFF_SETUP(%o2)
9415 1: ldx [%o1], %g1
9416 - add %g1, %o0, %g7
9417 + addcc %g1, %o0, %g7
9418 +
9419 +#ifdef CONFIG_PAX_REFCOUNT
9420 + tvs %xcc, 6
9421 +#endif
9422 +
9423 casx [%o1], %g1, %g7
9424 cmp %g1, %g7
9425 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9426 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9427 2: BACKOFF_SPIN(%o2, %o3, 1b)
9428 ENDPROC(atomic64_add_ret)
9429
9430 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9431 + BACKOFF_SETUP(%o2)
9432 +1: ldx [%o1], %g1
9433 + addcc %g1, %o0, %g7
9434 + casx [%o1], %g1, %g7
9435 + cmp %g1, %g7
9436 + bne,pn %xcc, 2f
9437 + add %g7, %o0, %g7
9438 + mov %g7, %o0
9439 + retl
9440 + nop
9441 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9442 +ENDPROC(atomic64_add_ret_unchecked)
9443 +
9444 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9445 BACKOFF_SETUP(%o2)
9446 1: ldx [%o1], %g1
9447 - sub %g1, %o0, %g7
9448 + subcc %g1, %o0, %g7
9449 +
9450 +#ifdef CONFIG_PAX_REFCOUNT
9451 + tvs %xcc, 6
9452 +#endif
9453 +
9454 casx [%o1], %g1, %g7
9455 cmp %g1, %g7
9456 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9457 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9458 index 0c4e35e..745d3e4 100644
9459 --- a/arch/sparc/lib/ksyms.c
9460 +++ b/arch/sparc/lib/ksyms.c
9461 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9462
9463 /* Atomic counter implementation. */
9464 EXPORT_SYMBOL(atomic_add);
9465 +EXPORT_SYMBOL(atomic_add_unchecked);
9466 EXPORT_SYMBOL(atomic_add_ret);
9467 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9468 EXPORT_SYMBOL(atomic_sub);
9469 +EXPORT_SYMBOL(atomic_sub_unchecked);
9470 EXPORT_SYMBOL(atomic_sub_ret);
9471 EXPORT_SYMBOL(atomic64_add);
9472 +EXPORT_SYMBOL(atomic64_add_unchecked);
9473 EXPORT_SYMBOL(atomic64_add_ret);
9474 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9475 EXPORT_SYMBOL(atomic64_sub);
9476 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9477 EXPORT_SYMBOL(atomic64_sub_ret);
9478 EXPORT_SYMBOL(atomic64_dec_if_positive);
9479
9480 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9481 index 30c3ecc..736f015 100644
9482 --- a/arch/sparc/mm/Makefile
9483 +++ b/arch/sparc/mm/Makefile
9484 @@ -2,7 +2,7 @@
9485 #
9486
9487 asflags-y := -ansi
9488 -ccflags-y := -Werror
9489 +#ccflags-y := -Werror
9490
9491 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9492 obj-y += fault_$(BITS).o
9493 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9494 index e98bfda..ea8d221 100644
9495 --- a/arch/sparc/mm/fault_32.c
9496 +++ b/arch/sparc/mm/fault_32.c
9497 @@ -21,6 +21,9 @@
9498 #include <linux/perf_event.h>
9499 #include <linux/interrupt.h>
9500 #include <linux/kdebug.h>
9501 +#include <linux/slab.h>
9502 +#include <linux/pagemap.h>
9503 +#include <linux/compiler.h>
9504
9505 #include <asm/page.h>
9506 #include <asm/pgtable.h>
9507 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9508 return safe_compute_effective_address(regs, insn);
9509 }
9510
9511 +#ifdef CONFIG_PAX_PAGEEXEC
9512 +#ifdef CONFIG_PAX_DLRESOLVE
9513 +static void pax_emuplt_close(struct vm_area_struct *vma)
9514 +{
9515 + vma->vm_mm->call_dl_resolve = 0UL;
9516 +}
9517 +
9518 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9519 +{
9520 + unsigned int *kaddr;
9521 +
9522 + vmf->page = alloc_page(GFP_HIGHUSER);
9523 + if (!vmf->page)
9524 + return VM_FAULT_OOM;
9525 +
9526 + kaddr = kmap(vmf->page);
9527 + memset(kaddr, 0, PAGE_SIZE);
9528 + kaddr[0] = 0x9DE3BFA8U; /* save */
9529 + flush_dcache_page(vmf->page);
9530 + kunmap(vmf->page);
9531 + return VM_FAULT_MAJOR;
9532 +}
9533 +
9534 +static const struct vm_operations_struct pax_vm_ops = {
9535 + .close = pax_emuplt_close,
9536 + .fault = pax_emuplt_fault
9537 +};
9538 +
9539 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9540 +{
9541 + int ret;
9542 +
9543 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9544 + vma->vm_mm = current->mm;
9545 + vma->vm_start = addr;
9546 + vma->vm_end = addr + PAGE_SIZE;
9547 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9548 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9549 + vma->vm_ops = &pax_vm_ops;
9550 +
9551 + ret = insert_vm_struct(current->mm, vma);
9552 + if (ret)
9553 + return ret;
9554 +
9555 + ++current->mm->total_vm;
9556 + return 0;
9557 +}
9558 +#endif
9559 +
9560 +/*
9561 + * PaX: decide what to do with offenders (regs->pc = fault address)
9562 + *
9563 + * returns 1 when task should be killed
9564 + * 2 when patched PLT trampoline was detected
9565 + * 3 when unpatched PLT trampoline was detected
9566 + */
9567 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9568 +{
9569 +
9570 +#ifdef CONFIG_PAX_EMUPLT
9571 + int err;
9572 +
9573 + do { /* PaX: patched PLT emulation #1 */
9574 + unsigned int sethi1, sethi2, jmpl;
9575 +
9576 + err = get_user(sethi1, (unsigned int *)regs->pc);
9577 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9578 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9579 +
9580 + if (err)
9581 + break;
9582 +
9583 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9584 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9585 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9586 + {
9587 + unsigned int addr;
9588 +
9589 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9590 + addr = regs->u_regs[UREG_G1];
9591 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9592 + regs->pc = addr;
9593 + regs->npc = addr+4;
9594 + return 2;
9595 + }
9596 + } while (0);
9597 +
9598 + do { /* PaX: patched PLT emulation #2 */
9599 + unsigned int ba;
9600 +
9601 + err = get_user(ba, (unsigned int *)regs->pc);
9602 +
9603 + if (err)
9604 + break;
9605 +
9606 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9607 + unsigned int addr;
9608 +
9609 + if ((ba & 0xFFC00000U) == 0x30800000U)
9610 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9611 + else
9612 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9613 + regs->pc = addr;
9614 + regs->npc = addr+4;
9615 + return 2;
9616 + }
9617 + } while (0);
9618 +
9619 + do { /* PaX: patched PLT emulation #3 */
9620 + unsigned int sethi, bajmpl, nop;
9621 +
9622 + err = get_user(sethi, (unsigned int *)regs->pc);
9623 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9624 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9625 +
9626 + if (err)
9627 + break;
9628 +
9629 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9630 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9631 + nop == 0x01000000U)
9632 + {
9633 + unsigned int addr;
9634 +
9635 + addr = (sethi & 0x003FFFFFU) << 10;
9636 + regs->u_regs[UREG_G1] = addr;
9637 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9638 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9639 + else
9640 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9641 + regs->pc = addr;
9642 + regs->npc = addr+4;
9643 + return 2;
9644 + }
9645 + } while (0);
9646 +
9647 + do { /* PaX: unpatched PLT emulation step 1 */
9648 + unsigned int sethi, ba, nop;
9649 +
9650 + err = get_user(sethi, (unsigned int *)regs->pc);
9651 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9652 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9653 +
9654 + if (err)
9655 + break;
9656 +
9657 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9658 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9659 + nop == 0x01000000U)
9660 + {
9661 + unsigned int addr, save, call;
9662 +
9663 + if ((ba & 0xFFC00000U) == 0x30800000U)
9664 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9665 + else
9666 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9667 +
9668 + err = get_user(save, (unsigned int *)addr);
9669 + err |= get_user(call, (unsigned int *)(addr+4));
9670 + err |= get_user(nop, (unsigned int *)(addr+8));
9671 + if (err)
9672 + break;
9673 +
9674 +#ifdef CONFIG_PAX_DLRESOLVE
9675 + if (save == 0x9DE3BFA8U &&
9676 + (call & 0xC0000000U) == 0x40000000U &&
9677 + nop == 0x01000000U)
9678 + {
9679 + struct vm_area_struct *vma;
9680 + unsigned long call_dl_resolve;
9681 +
9682 + down_read(&current->mm->mmap_sem);
9683 + call_dl_resolve = current->mm->call_dl_resolve;
9684 + up_read(&current->mm->mmap_sem);
9685 + if (likely(call_dl_resolve))
9686 + goto emulate;
9687 +
9688 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9689 +
9690 + down_write(&current->mm->mmap_sem);
9691 + if (current->mm->call_dl_resolve) {
9692 + call_dl_resolve = current->mm->call_dl_resolve;
9693 + up_write(&current->mm->mmap_sem);
9694 + if (vma)
9695 + kmem_cache_free(vm_area_cachep, vma);
9696 + goto emulate;
9697 + }
9698 +
9699 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9700 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9701 + up_write(&current->mm->mmap_sem);
9702 + if (vma)
9703 + kmem_cache_free(vm_area_cachep, vma);
9704 + return 1;
9705 + }
9706 +
9707 + if (pax_insert_vma(vma, call_dl_resolve)) {
9708 + up_write(&current->mm->mmap_sem);
9709 + kmem_cache_free(vm_area_cachep, vma);
9710 + return 1;
9711 + }
9712 +
9713 + current->mm->call_dl_resolve = call_dl_resolve;
9714 + up_write(&current->mm->mmap_sem);
9715 +
9716 +emulate:
9717 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9718 + regs->pc = call_dl_resolve;
9719 + regs->npc = addr+4;
9720 + return 3;
9721 + }
9722 +#endif
9723 +
9724 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9725 + if ((save & 0xFFC00000U) == 0x05000000U &&
9726 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9727 + nop == 0x01000000U)
9728 + {
9729 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9730 + regs->u_regs[UREG_G2] = addr + 4;
9731 + addr = (save & 0x003FFFFFU) << 10;
9732 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9733 + regs->pc = addr;
9734 + regs->npc = addr+4;
9735 + return 3;
9736 + }
9737 + }
9738 + } while (0);
9739 +
9740 + do { /* PaX: unpatched PLT emulation step 2 */
9741 + unsigned int save, call, nop;
9742 +
9743 + err = get_user(save, (unsigned int *)(regs->pc-4));
9744 + err |= get_user(call, (unsigned int *)regs->pc);
9745 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9746 + if (err)
9747 + break;
9748 +
9749 + if (save == 0x9DE3BFA8U &&
9750 + (call & 0xC0000000U) == 0x40000000U &&
9751 + nop == 0x01000000U)
9752 + {
9753 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9754 +
9755 + regs->u_regs[UREG_RETPC] = regs->pc;
9756 + regs->pc = dl_resolve;
9757 + regs->npc = dl_resolve+4;
9758 + return 3;
9759 + }
9760 + } while (0);
9761 +#endif
9762 +
9763 + return 1;
9764 +}
9765 +
9766 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9767 +{
9768 + unsigned long i;
9769 +
9770 + printk(KERN_ERR "PAX: bytes at PC: ");
9771 + for (i = 0; i < 8; i++) {
9772 + unsigned int c;
9773 + if (get_user(c, (unsigned int *)pc+i))
9774 + printk(KERN_CONT "???????? ");
9775 + else
9776 + printk(KERN_CONT "%08x ", c);
9777 + }
9778 + printk("\n");
9779 +}
9780 +#endif
9781 +
9782 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9783 int text_fault)
9784 {
9785 @@ -230,6 +504,24 @@ good_area:
9786 if (!(vma->vm_flags & VM_WRITE))
9787 goto bad_area;
9788 } else {
9789 +
9790 +#ifdef CONFIG_PAX_PAGEEXEC
9791 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9792 + up_read(&mm->mmap_sem);
9793 + switch (pax_handle_fetch_fault(regs)) {
9794 +
9795 +#ifdef CONFIG_PAX_EMUPLT
9796 + case 2:
9797 + case 3:
9798 + return;
9799 +#endif
9800 +
9801 + }
9802 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9803 + do_group_exit(SIGKILL);
9804 + }
9805 +#endif
9806 +
9807 /* Allow reads even for write-only mappings */
9808 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9809 goto bad_area;
9810 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9811 index 5062ff3..e0b75f3 100644
9812 --- a/arch/sparc/mm/fault_64.c
9813 +++ b/arch/sparc/mm/fault_64.c
9814 @@ -21,6 +21,9 @@
9815 #include <linux/kprobes.h>
9816 #include <linux/kdebug.h>
9817 #include <linux/percpu.h>
9818 +#include <linux/slab.h>
9819 +#include <linux/pagemap.h>
9820 +#include <linux/compiler.h>
9821
9822 #include <asm/page.h>
9823 #include <asm/pgtable.h>
9824 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9825 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9826 regs->tpc);
9827 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9828 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9829 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9830 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9831 dump_stack();
9832 unhandled_fault(regs->tpc, current, regs);
9833 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9834 show_regs(regs);
9835 }
9836
9837 +#ifdef CONFIG_PAX_PAGEEXEC
9838 +#ifdef CONFIG_PAX_DLRESOLVE
9839 +static void pax_emuplt_close(struct vm_area_struct *vma)
9840 +{
9841 + vma->vm_mm->call_dl_resolve = 0UL;
9842 +}
9843 +
9844 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9845 +{
9846 + unsigned int *kaddr;
9847 +
9848 + vmf->page = alloc_page(GFP_HIGHUSER);
9849 + if (!vmf->page)
9850 + return VM_FAULT_OOM;
9851 +
9852 + kaddr = kmap(vmf->page);
9853 + memset(kaddr, 0, PAGE_SIZE);
9854 + kaddr[0] = 0x9DE3BFA8U; /* save */
9855 + flush_dcache_page(vmf->page);
9856 + kunmap(vmf->page);
9857 + return VM_FAULT_MAJOR;
9858 +}
9859 +
9860 +static const struct vm_operations_struct pax_vm_ops = {
9861 + .close = pax_emuplt_close,
9862 + .fault = pax_emuplt_fault
9863 +};
9864 +
9865 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9866 +{
9867 + int ret;
9868 +
9869 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9870 + vma->vm_mm = current->mm;
9871 + vma->vm_start = addr;
9872 + vma->vm_end = addr + PAGE_SIZE;
9873 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9874 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9875 + vma->vm_ops = &pax_vm_ops;
9876 +
9877 + ret = insert_vm_struct(current->mm, vma);
9878 + if (ret)
9879 + return ret;
9880 +
9881 + ++current->mm->total_vm;
9882 + return 0;
9883 +}
9884 +#endif
9885 +
9886 +/*
9887 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9888 + *
9889 + * returns 1 when task should be killed
9890 + * 2 when patched PLT trampoline was detected
9891 + * 3 when unpatched PLT trampoline was detected
9892 + */
9893 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9894 +{
9895 +
9896 +#ifdef CONFIG_PAX_EMUPLT
9897 + int err;
9898 +
9899 + do { /* PaX: patched PLT emulation #1 */
9900 + unsigned int sethi1, sethi2, jmpl;
9901 +
9902 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9903 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9904 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9905 +
9906 + if (err)
9907 + break;
9908 +
9909 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9910 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9911 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9912 + {
9913 + unsigned long addr;
9914 +
9915 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9916 + addr = regs->u_regs[UREG_G1];
9917 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9918 +
9919 + if (test_thread_flag(TIF_32BIT))
9920 + addr &= 0xFFFFFFFFUL;
9921 +
9922 + regs->tpc = addr;
9923 + regs->tnpc = addr+4;
9924 + return 2;
9925 + }
9926 + } while (0);
9927 +
9928 + do { /* PaX: patched PLT emulation #2 */
9929 + unsigned int ba;
9930 +
9931 + err = get_user(ba, (unsigned int *)regs->tpc);
9932 +
9933 + if (err)
9934 + break;
9935 +
9936 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9937 + unsigned long addr;
9938 +
9939 + if ((ba & 0xFFC00000U) == 0x30800000U)
9940 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9941 + else
9942 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9943 +
9944 + if (test_thread_flag(TIF_32BIT))
9945 + addr &= 0xFFFFFFFFUL;
9946 +
9947 + regs->tpc = addr;
9948 + regs->tnpc = addr+4;
9949 + return 2;
9950 + }
9951 + } while (0);
9952 +
9953 + do { /* PaX: patched PLT emulation #3 */
9954 + unsigned int sethi, bajmpl, nop;
9955 +
9956 + err = get_user(sethi, (unsigned int *)regs->tpc);
9957 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9958 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9959 +
9960 + if (err)
9961 + break;
9962 +
9963 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9964 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9965 + nop == 0x01000000U)
9966 + {
9967 + unsigned long addr;
9968 +
9969 + addr = (sethi & 0x003FFFFFU) << 10;
9970 + regs->u_regs[UREG_G1] = addr;
9971 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9972 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9973 + else
9974 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9975 +
9976 + if (test_thread_flag(TIF_32BIT))
9977 + addr &= 0xFFFFFFFFUL;
9978 +
9979 + regs->tpc = addr;
9980 + regs->tnpc = addr+4;
9981 + return 2;
9982 + }
9983 + } while (0);
9984 +
9985 + do { /* PaX: patched PLT emulation #4 */
9986 + unsigned int sethi, mov1, call, mov2;
9987 +
9988 + err = get_user(sethi, (unsigned int *)regs->tpc);
9989 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9990 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9991 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9992 +
9993 + if (err)
9994 + break;
9995 +
9996 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9997 + mov1 == 0x8210000FU &&
9998 + (call & 0xC0000000U) == 0x40000000U &&
9999 + mov2 == 0x9E100001U)
10000 + {
10001 + unsigned long addr;
10002 +
10003 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10004 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10005 +
10006 + if (test_thread_flag(TIF_32BIT))
10007 + addr &= 0xFFFFFFFFUL;
10008 +
10009 + regs->tpc = addr;
10010 + regs->tnpc = addr+4;
10011 + return 2;
10012 + }
10013 + } while (0);
10014 +
10015 + do { /* PaX: patched PLT emulation #5 */
10016 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10017 +
10018 + err = get_user(sethi, (unsigned int *)regs->tpc);
10019 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10020 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10021 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10022 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10023 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10024 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10025 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10026 +
10027 + if (err)
10028 + break;
10029 +
10030 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10031 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10032 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10033 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10034 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10035 + sllx == 0x83287020U &&
10036 + jmpl == 0x81C04005U &&
10037 + nop == 0x01000000U)
10038 + {
10039 + unsigned long addr;
10040 +
10041 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10042 + regs->u_regs[UREG_G1] <<= 32;
10043 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10044 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10045 + regs->tpc = addr;
10046 + regs->tnpc = addr+4;
10047 + return 2;
10048 + }
10049 + } while (0);
10050 +
10051 + do { /* PaX: patched PLT emulation #6 */
10052 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10053 +
10054 + err = get_user(sethi, (unsigned int *)regs->tpc);
10055 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10056 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10057 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10058 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10059 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10060 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10061 +
10062 + if (err)
10063 + break;
10064 +
10065 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10066 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10067 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10068 + sllx == 0x83287020U &&
10069 + (or & 0xFFFFE000U) == 0x8A116000U &&
10070 + jmpl == 0x81C04005U &&
10071 + nop == 0x01000000U)
10072 + {
10073 + unsigned long addr;
10074 +
10075 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10076 + regs->u_regs[UREG_G1] <<= 32;
10077 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10078 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10079 + regs->tpc = addr;
10080 + regs->tnpc = addr+4;
10081 + return 2;
10082 + }
10083 + } while (0);
10084 +
10085 + do { /* PaX: unpatched PLT emulation step 1 */
10086 + unsigned int sethi, ba, nop;
10087 +
10088 + err = get_user(sethi, (unsigned int *)regs->tpc);
10089 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10090 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10091 +
10092 + if (err)
10093 + break;
10094 +
10095 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10096 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10097 + nop == 0x01000000U)
10098 + {
10099 + unsigned long addr;
10100 + unsigned int save, call;
10101 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10102 +
10103 + if ((ba & 0xFFC00000U) == 0x30800000U)
10104 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10105 + else
10106 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10107 +
10108 + if (test_thread_flag(TIF_32BIT))
10109 + addr &= 0xFFFFFFFFUL;
10110 +
10111 + err = get_user(save, (unsigned int *)addr);
10112 + err |= get_user(call, (unsigned int *)(addr+4));
10113 + err |= get_user(nop, (unsigned int *)(addr+8));
10114 + if (err)
10115 + break;
10116 +
10117 +#ifdef CONFIG_PAX_DLRESOLVE
10118 + if (save == 0x9DE3BFA8U &&
10119 + (call & 0xC0000000U) == 0x40000000U &&
10120 + nop == 0x01000000U)
10121 + {
10122 + struct vm_area_struct *vma;
10123 + unsigned long call_dl_resolve;
10124 +
10125 + down_read(&current->mm->mmap_sem);
10126 + call_dl_resolve = current->mm->call_dl_resolve;
10127 + up_read(&current->mm->mmap_sem);
10128 + if (likely(call_dl_resolve))
10129 + goto emulate;
10130 +
10131 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10132 +
10133 + down_write(&current->mm->mmap_sem);
10134 + if (current->mm->call_dl_resolve) {
10135 + call_dl_resolve = current->mm->call_dl_resolve;
10136 + up_write(&current->mm->mmap_sem);
10137 + if (vma)
10138 + kmem_cache_free(vm_area_cachep, vma);
10139 + goto emulate;
10140 + }
10141 +
10142 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10143 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10144 + up_write(&current->mm->mmap_sem);
10145 + if (vma)
10146 + kmem_cache_free(vm_area_cachep, vma);
10147 + return 1;
10148 + }
10149 +
10150 + if (pax_insert_vma(vma, call_dl_resolve)) {
10151 + up_write(&current->mm->mmap_sem);
10152 + kmem_cache_free(vm_area_cachep, vma);
10153 + return 1;
10154 + }
10155 +
10156 + current->mm->call_dl_resolve = call_dl_resolve;
10157 + up_write(&current->mm->mmap_sem);
10158 +
10159 +emulate:
10160 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10161 + regs->tpc = call_dl_resolve;
10162 + regs->tnpc = addr+4;
10163 + return 3;
10164 + }
10165 +#endif
10166 +
10167 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10168 + if ((save & 0xFFC00000U) == 0x05000000U &&
10169 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10170 + nop == 0x01000000U)
10171 + {
10172 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10173 + regs->u_regs[UREG_G2] = addr + 4;
10174 + addr = (save & 0x003FFFFFU) << 10;
10175 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10176 +
10177 + if (test_thread_flag(TIF_32BIT))
10178 + addr &= 0xFFFFFFFFUL;
10179 +
10180 + regs->tpc = addr;
10181 + regs->tnpc = addr+4;
10182 + return 3;
10183 + }
10184 +
10185 + /* PaX: 64-bit PLT stub */
10186 + err = get_user(sethi1, (unsigned int *)addr);
10187 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10188 + err |= get_user(or1, (unsigned int *)(addr+8));
10189 + err |= get_user(or2, (unsigned int *)(addr+12));
10190 + err |= get_user(sllx, (unsigned int *)(addr+16));
10191 + err |= get_user(add, (unsigned int *)(addr+20));
10192 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10193 + err |= get_user(nop, (unsigned int *)(addr+28));
10194 + if (err)
10195 + break;
10196 +
10197 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10198 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10199 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10200 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10201 + sllx == 0x89293020U &&
10202 + add == 0x8A010005U &&
10203 + jmpl == 0x89C14000U &&
10204 + nop == 0x01000000U)
10205 + {
10206 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10207 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10208 + regs->u_regs[UREG_G4] <<= 32;
10209 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10210 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10211 + regs->u_regs[UREG_G4] = addr + 24;
10212 + addr = regs->u_regs[UREG_G5];
10213 + regs->tpc = addr;
10214 + regs->tnpc = addr+4;
10215 + return 3;
10216 + }
10217 + }
10218 + } while (0);
10219 +
10220 +#ifdef CONFIG_PAX_DLRESOLVE
10221 + do { /* PaX: unpatched PLT emulation step 2 */
10222 + unsigned int save, call, nop;
10223 +
10224 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10225 + err |= get_user(call, (unsigned int *)regs->tpc);
10226 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10227 + if (err)
10228 + break;
10229 +
10230 + if (save == 0x9DE3BFA8U &&
10231 + (call & 0xC0000000U) == 0x40000000U &&
10232 + nop == 0x01000000U)
10233 + {
10234 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10235 +
10236 + if (test_thread_flag(TIF_32BIT))
10237 + dl_resolve &= 0xFFFFFFFFUL;
10238 +
10239 + regs->u_regs[UREG_RETPC] = regs->tpc;
10240 + regs->tpc = dl_resolve;
10241 + regs->tnpc = dl_resolve+4;
10242 + return 3;
10243 + }
10244 + } while (0);
10245 +#endif
10246 +
10247 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10248 + unsigned int sethi, ba, nop;
10249 +
10250 + err = get_user(sethi, (unsigned int *)regs->tpc);
10251 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10252 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10253 +
10254 + if (err)
10255 + break;
10256 +
10257 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10258 + (ba & 0xFFF00000U) == 0x30600000U &&
10259 + nop == 0x01000000U)
10260 + {
10261 + unsigned long addr;
10262 +
10263 + addr = (sethi & 0x003FFFFFU) << 10;
10264 + regs->u_regs[UREG_G1] = addr;
10265 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10266 +
10267 + if (test_thread_flag(TIF_32BIT))
10268 + addr &= 0xFFFFFFFFUL;
10269 +
10270 + regs->tpc = addr;
10271 + regs->tnpc = addr+4;
10272 + return 2;
10273 + }
10274 + } while (0);
10275 +
10276 +#endif
10277 +
10278 + return 1;
10279 +}
10280 +
10281 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10282 +{
10283 + unsigned long i;
10284 +
10285 + printk(KERN_ERR "PAX: bytes at PC: ");
10286 + for (i = 0; i < 8; i++) {
10287 + unsigned int c;
10288 + if (get_user(c, (unsigned int *)pc+i))
10289 + printk(KERN_CONT "???????? ");
10290 + else
10291 + printk(KERN_CONT "%08x ", c);
10292 + }
10293 + printk("\n");
10294 +}
10295 +#endif
10296 +
10297 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10298 {
10299 struct mm_struct *mm = current->mm;
10300 @@ -341,6 +804,29 @@ retry:
10301 if (!vma)
10302 goto bad_area;
10303
10304 +#ifdef CONFIG_PAX_PAGEEXEC
10305 + /* PaX: detect ITLB misses on non-exec pages */
10306 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10307 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10308 + {
10309 + if (address != regs->tpc)
10310 + goto good_area;
10311 +
10312 + up_read(&mm->mmap_sem);
10313 + switch (pax_handle_fetch_fault(regs)) {
10314 +
10315 +#ifdef CONFIG_PAX_EMUPLT
10316 + case 2:
10317 + case 3:
10318 + return;
10319 +#endif
10320 +
10321 + }
10322 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10323 + do_group_exit(SIGKILL);
10324 + }
10325 +#endif
10326 +
10327 /* Pure DTLB misses do not tell us whether the fault causing
10328 * load/store/atomic was a write or not, it only says that there
10329 * was no match. So in such a case we (carefully) read the
10330 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10331 index d2b5944..bd813f2 100644
10332 --- a/arch/sparc/mm/hugetlbpage.c
10333 +++ b/arch/sparc/mm/hugetlbpage.c
10334 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10335
10336 info.flags = 0;
10337 info.length = len;
10338 - info.low_limit = TASK_UNMAPPED_BASE;
10339 + info.low_limit = mm->mmap_base;
10340 info.high_limit = min(task_size, VA_EXCLUDE_START);
10341 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10342 info.align_offset = 0;
10343 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10344 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10345 VM_BUG_ON(addr != -ENOMEM);
10346 info.low_limit = VA_EXCLUDE_END;
10347 +
10348 +#ifdef CONFIG_PAX_RANDMMAP
10349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10350 + info.low_limit += mm->delta_mmap;
10351 +#endif
10352 +
10353 info.high_limit = task_size;
10354 addr = vm_unmapped_area(&info);
10355 }
10356 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10357 VM_BUG_ON(addr != -ENOMEM);
10358 info.flags = 0;
10359 info.low_limit = TASK_UNMAPPED_BASE;
10360 +
10361 +#ifdef CONFIG_PAX_RANDMMAP
10362 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10363 + info.low_limit += mm->delta_mmap;
10364 +#endif
10365 +
10366 info.high_limit = STACK_TOP32;
10367 addr = vm_unmapped_area(&info);
10368 }
10369 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10370 struct mm_struct *mm = current->mm;
10371 struct vm_area_struct *vma;
10372 unsigned long task_size = TASK_SIZE;
10373 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10374
10375 if (test_thread_flag(TIF_32BIT))
10376 task_size = STACK_TOP32;
10377 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10378 return addr;
10379 }
10380
10381 +#ifdef CONFIG_PAX_RANDMMAP
10382 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10383 +#endif
10384 +
10385 if (addr) {
10386 addr = ALIGN(addr, HPAGE_SIZE);
10387 vma = find_vma(mm, addr);
10388 - if (task_size - len >= addr &&
10389 - (!vma || addr + len <= vma->vm_start))
10390 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10391 return addr;
10392 }
10393 if (mm->get_unmapped_area == arch_get_unmapped_area)
10394 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10395 index f4500c6..889656c 100644
10396 --- a/arch/tile/include/asm/atomic_64.h
10397 +++ b/arch/tile/include/asm/atomic_64.h
10398 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10399
10400 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10401
10402 +#define atomic64_read_unchecked(v) atomic64_read(v)
10403 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10404 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10405 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10406 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10407 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10408 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10409 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10410 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10411 +
10412 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10413 #define smp_mb__before_atomic_dec() smp_mb()
10414 #define smp_mb__after_atomic_dec() smp_mb()
10415 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10416 index a9a5299..0fce79e 100644
10417 --- a/arch/tile/include/asm/cache.h
10418 +++ b/arch/tile/include/asm/cache.h
10419 @@ -15,11 +15,12 @@
10420 #ifndef _ASM_TILE_CACHE_H
10421 #define _ASM_TILE_CACHE_H
10422
10423 +#include <linux/const.h>
10424 #include <arch/chip.h>
10425
10426 /* bytes per L1 data cache line */
10427 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10428 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10429 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10430
10431 /* bytes per L2 cache line */
10432 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10433 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10434 index 9ab078a..d6635c2 100644
10435 --- a/arch/tile/include/asm/uaccess.h
10436 +++ b/arch/tile/include/asm/uaccess.h
10437 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10438 const void __user *from,
10439 unsigned long n)
10440 {
10441 - int sz = __compiletime_object_size(to);
10442 + size_t sz = __compiletime_object_size(to);
10443
10444 - if (likely(sz == -1 || sz >= n))
10445 + if (likely(sz == (size_t)-1 || sz >= n))
10446 n = _copy_from_user(to, from, n);
10447 else
10448 copy_from_user_overflow();
10449 diff --git a/arch/um/Makefile b/arch/um/Makefile
10450 index 133f7de..1d6f2f1 100644
10451 --- a/arch/um/Makefile
10452 +++ b/arch/um/Makefile
10453 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10454 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10455 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10456
10457 +ifdef CONSTIFY_PLUGIN
10458 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10459 +endif
10460 +
10461 #This will adjust *FLAGS accordingly to the platform.
10462 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10463
10464 diff --git a/arch/um/defconfig b/arch/um/defconfig
10465 index 08107a7..ab22afe 100644
10466 --- a/arch/um/defconfig
10467 +++ b/arch/um/defconfig
10468 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10469 CONFIG_X86_L1_CACHE_SHIFT=5
10470 CONFIG_X86_XADD=y
10471 CONFIG_X86_PPRO_FENCE=y
10472 -CONFIG_X86_WP_WORKS_OK=y
10473 CONFIG_X86_INVLPG=y
10474 CONFIG_X86_BSWAP=y
10475 CONFIG_X86_POPAD_OK=y
10476 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10477 index 19e1bdd..3665b77 100644
10478 --- a/arch/um/include/asm/cache.h
10479 +++ b/arch/um/include/asm/cache.h
10480 @@ -1,6 +1,7 @@
10481 #ifndef __UM_CACHE_H
10482 #define __UM_CACHE_H
10483
10484 +#include <linux/const.h>
10485
10486 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10487 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10488 @@ -12,6 +13,6 @@
10489 # define L1_CACHE_SHIFT 5
10490 #endif
10491
10492 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10493 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10494
10495 #endif
10496 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10497 index 2e0a6b1..a64d0f5 100644
10498 --- a/arch/um/include/asm/kmap_types.h
10499 +++ b/arch/um/include/asm/kmap_types.h
10500 @@ -8,6 +8,6 @@
10501
10502 /* No more #include "asm/arch/kmap_types.h" ! */
10503
10504 -#define KM_TYPE_NR 14
10505 +#define KM_TYPE_NR 15
10506
10507 #endif
10508 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10509 index 5ff53d9..5850cdf 100644
10510 --- a/arch/um/include/asm/page.h
10511 +++ b/arch/um/include/asm/page.h
10512 @@ -14,6 +14,9 @@
10513 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10514 #define PAGE_MASK (~(PAGE_SIZE-1))
10515
10516 +#define ktla_ktva(addr) (addr)
10517 +#define ktva_ktla(addr) (addr)
10518 +
10519 #ifndef __ASSEMBLY__
10520
10521 struct page;
10522 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10523 index 0032f92..cd151e0 100644
10524 --- a/arch/um/include/asm/pgtable-3level.h
10525 +++ b/arch/um/include/asm/pgtable-3level.h
10526 @@ -58,6 +58,7 @@
10527 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10528 #define pud_populate(mm, pud, pmd) \
10529 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10530 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10531
10532 #ifdef CONFIG_64BIT
10533 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10534 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10535 index b462b13..e7a19aa 100644
10536 --- a/arch/um/kernel/process.c
10537 +++ b/arch/um/kernel/process.c
10538 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10539 return 2;
10540 }
10541
10542 -/*
10543 - * Only x86 and x86_64 have an arch_align_stack().
10544 - * All other arches have "#define arch_align_stack(x) (x)"
10545 - * in their asm/system.h
10546 - * As this is included in UML from asm-um/system-generic.h,
10547 - * we can use it to behave as the subarch does.
10548 - */
10549 -#ifndef arch_align_stack
10550 -unsigned long arch_align_stack(unsigned long sp)
10551 -{
10552 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10553 - sp -= get_random_int() % 8192;
10554 - return sp & ~0xf;
10555 -}
10556 -#endif
10557 -
10558 unsigned long get_wchan(struct task_struct *p)
10559 {
10560 unsigned long stack_page, sp, ip;
10561 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10562 index ad8f795..2c7eec6 100644
10563 --- a/arch/unicore32/include/asm/cache.h
10564 +++ b/arch/unicore32/include/asm/cache.h
10565 @@ -12,8 +12,10 @@
10566 #ifndef __UNICORE_CACHE_H__
10567 #define __UNICORE_CACHE_H__
10568
10569 -#define L1_CACHE_SHIFT (5)
10570 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10571 +#include <linux/const.h>
10572 +
10573 +#define L1_CACHE_SHIFT 5
10574 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10575
10576 /*
10577 * Memory returned by kmalloc() may be used for DMA, so we must make
10578 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10579 index 0694d09..58ea1a1 100644
10580 --- a/arch/x86/Kconfig
10581 +++ b/arch/x86/Kconfig
10582 @@ -238,7 +238,7 @@ config X86_HT
10583
10584 config X86_32_LAZY_GS
10585 def_bool y
10586 - depends on X86_32 && !CC_STACKPROTECTOR
10587 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10588
10589 config ARCH_HWEIGHT_CFLAGS
10590 string
10591 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10592
10593 config X86_MSR
10594 tristate "/dev/cpu/*/msr - Model-specific register support"
10595 + depends on !GRKERNSEC_KMEM
10596 ---help---
10597 This device gives privileged processes access to the x86
10598 Model-Specific Registers (MSRs). It is a character device with
10599 @@ -1054,7 +1055,7 @@ choice
10600
10601 config NOHIGHMEM
10602 bool "off"
10603 - depends on !X86_NUMAQ
10604 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10605 ---help---
10606 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10607 However, the address space of 32-bit x86 processors is only 4
10608 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10609
10610 config HIGHMEM4G
10611 bool "4GB"
10612 - depends on !X86_NUMAQ
10613 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10614 ---help---
10615 Select this if you have a 32-bit processor and between 1 and 4
10616 gigabytes of physical RAM.
10617 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10618 hex
10619 default 0xB0000000 if VMSPLIT_3G_OPT
10620 default 0x80000000 if VMSPLIT_2G
10621 - default 0x78000000 if VMSPLIT_2G_OPT
10622 + default 0x70000000 if VMSPLIT_2G_OPT
10623 default 0x40000000 if VMSPLIT_1G
10624 default 0xC0000000
10625 depends on X86_32
10626 @@ -1542,6 +1543,7 @@ config SECCOMP
10627
10628 config CC_STACKPROTECTOR
10629 bool "Enable -fstack-protector buffer overflow detection"
10630 + depends on X86_64 || !PAX_MEMORY_UDEREF
10631 ---help---
10632 This option turns on the -fstack-protector GCC feature. This
10633 feature puts, at the beginning of functions, a canary value on
10634 @@ -1662,6 +1664,8 @@ config X86_NEED_RELOCS
10635 config PHYSICAL_ALIGN
10636 hex "Alignment value to which kernel should be aligned" if X86_32
10637 default "0x1000000"
10638 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10639 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10640 range 0x2000 0x1000000
10641 ---help---
10642 This value puts the alignment restrictions on physical address
10643 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10644 If unsure, say N.
10645
10646 config COMPAT_VDSO
10647 - def_bool y
10648 + def_bool n
10649 prompt "Compat VDSO support"
10650 depends on X86_32 || IA32_EMULATION
10651 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10652 ---help---
10653 Map the 32-bit VDSO to the predictable old-style address too.
10654
10655 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10656 index c026cca..14657ae 100644
10657 --- a/arch/x86/Kconfig.cpu
10658 +++ b/arch/x86/Kconfig.cpu
10659 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10660
10661 config X86_F00F_BUG
10662 def_bool y
10663 - depends on M586MMX || M586TSC || M586 || M486
10664 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10665
10666 config X86_INVD_BUG
10667 def_bool y
10668 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10669
10670 config X86_ALIGNMENT_16
10671 def_bool y
10672 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10673 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10674
10675 config X86_INTEL_USERCOPY
10676 def_bool y
10677 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10678 # generates cmov.
10679 config X86_CMOV
10680 def_bool y
10681 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10682 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10683
10684 config X86_MINIMUM_CPU_FAMILY
10685 int
10686 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10687 index b322f12..652d0d9 100644
10688 --- a/arch/x86/Kconfig.debug
10689 +++ b/arch/x86/Kconfig.debug
10690 @@ -84,7 +84,7 @@ config X86_PTDUMP
10691 config DEBUG_RODATA
10692 bool "Write protect kernel read-only data structures"
10693 default y
10694 - depends on DEBUG_KERNEL
10695 + depends on DEBUG_KERNEL && BROKEN
10696 ---help---
10697 Mark the kernel read-only data as write-protected in the pagetables,
10698 in order to catch accidental (and incorrect) writes to such const
10699 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10700
10701 config DEBUG_SET_MODULE_RONX
10702 bool "Set loadable kernel module data as NX and text as RO"
10703 - depends on MODULES
10704 + depends on MODULES && BROKEN
10705 ---help---
10706 This option helps catch unintended modifications to loadable
10707 kernel module's text and read-only data. It also prevents execution
10708 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10709
10710 config DEBUG_STRICT_USER_COPY_CHECKS
10711 bool "Strict copy size checks"
10712 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10713 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10714 ---help---
10715 Enabling this option turns a certain set of sanity checks for user
10716 copy operations into compile time failures.
10717 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10718 index e71fc42..7829607 100644
10719 --- a/arch/x86/Makefile
10720 +++ b/arch/x86/Makefile
10721 @@ -50,6 +50,7 @@ else
10722 UTS_MACHINE := x86_64
10723 CHECKFLAGS += -D__x86_64__ -m64
10724
10725 + biarch := $(call cc-option,-m64)
10726 KBUILD_AFLAGS += -m64
10727 KBUILD_CFLAGS += -m64
10728
10729 @@ -230,3 +231,12 @@ define archhelp
10730 echo ' FDARGS="..." arguments for the booted kernel'
10731 echo ' FDINITRD=file initrd for the booted kernel'
10732 endef
10733 +
10734 +define OLD_LD
10735 +
10736 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10737 +*** Please upgrade your binutils to 2.18 or newer
10738 +endef
10739 +
10740 +archprepare:
10741 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10742 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10743 index 379814b..add62ce 100644
10744 --- a/arch/x86/boot/Makefile
10745 +++ b/arch/x86/boot/Makefile
10746 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10747 $(call cc-option, -fno-stack-protector) \
10748 $(call cc-option, -mpreferred-stack-boundary=2)
10749 KBUILD_CFLAGS += $(call cc-option, -m32)
10750 +ifdef CONSTIFY_PLUGIN
10751 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10752 +endif
10753 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10754 GCOV_PROFILE := n
10755
10756 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10757 index 878e4b9..20537ab 100644
10758 --- a/arch/x86/boot/bitops.h
10759 +++ b/arch/x86/boot/bitops.h
10760 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10761 u8 v;
10762 const u32 *p = (const u32 *)addr;
10763
10764 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10765 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10766 return v;
10767 }
10768
10769 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10770
10771 static inline void set_bit(int nr, void *addr)
10772 {
10773 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10774 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10775 }
10776
10777 #endif /* BOOT_BITOPS_H */
10778 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10779 index 18997e5..83d9c67 100644
10780 --- a/arch/x86/boot/boot.h
10781 +++ b/arch/x86/boot/boot.h
10782 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10783 static inline u16 ds(void)
10784 {
10785 u16 seg;
10786 - asm("movw %%ds,%0" : "=rm" (seg));
10787 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10788 return seg;
10789 }
10790
10791 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10792 static inline int memcmp(const void *s1, const void *s2, size_t len)
10793 {
10794 u8 diff;
10795 - asm("repe; cmpsb; setnz %0"
10796 + asm volatile("repe; cmpsb; setnz %0"
10797 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10798 return diff;
10799 }
10800 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10801 index 5ef205c..342191d 100644
10802 --- a/arch/x86/boot/compressed/Makefile
10803 +++ b/arch/x86/boot/compressed/Makefile
10804 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10805 KBUILD_CFLAGS += $(cflags-y)
10806 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10807 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10808 +ifdef CONSTIFY_PLUGIN
10809 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10810 +endif
10811
10812 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10813 GCOV_PROFILE := n
10814 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10815 index c205035..5853587 100644
10816 --- a/arch/x86/boot/compressed/eboot.c
10817 +++ b/arch/x86/boot/compressed/eboot.c
10818 @@ -150,7 +150,6 @@ again:
10819 *addr = max_addr;
10820 }
10821
10822 -free_pool:
10823 efi_call_phys1(sys_table->boottime->free_pool, map);
10824
10825 fail:
10826 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10827 if (i == map_size / desc_size)
10828 status = EFI_NOT_FOUND;
10829
10830 -free_pool:
10831 efi_call_phys1(sys_table->boottime->free_pool, map);
10832 fail:
10833 return status;
10834 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10835 index 1e3184f..0d11e2e 100644
10836 --- a/arch/x86/boot/compressed/head_32.S
10837 +++ b/arch/x86/boot/compressed/head_32.S
10838 @@ -118,7 +118,7 @@ preferred_addr:
10839 notl %eax
10840 andl %eax, %ebx
10841 #else
10842 - movl $LOAD_PHYSICAL_ADDR, %ebx
10843 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10844 #endif
10845
10846 /* Target address to relocate to for decompression */
10847 @@ -204,7 +204,7 @@ relocated:
10848 * and where it was actually loaded.
10849 */
10850 movl %ebp, %ebx
10851 - subl $LOAD_PHYSICAL_ADDR, %ebx
10852 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10853 jz 2f /* Nothing to be done if loaded at compiled addr. */
10854 /*
10855 * Process relocations.
10856 @@ -212,8 +212,7 @@ relocated:
10857
10858 1: subl $4, %edi
10859 movl (%edi), %ecx
10860 - testl %ecx, %ecx
10861 - jz 2f
10862 + jecxz 2f
10863 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10864 jmp 1b
10865 2:
10866 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10867 index f5d1aaa..cce11dc 100644
10868 --- a/arch/x86/boot/compressed/head_64.S
10869 +++ b/arch/x86/boot/compressed/head_64.S
10870 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10871 notl %eax
10872 andl %eax, %ebx
10873 #else
10874 - movl $LOAD_PHYSICAL_ADDR, %ebx
10875 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10876 #endif
10877
10878 /* Target address to relocate to for decompression */
10879 @@ -273,7 +273,7 @@ preferred_addr:
10880 notq %rax
10881 andq %rax, %rbp
10882 #else
10883 - movq $LOAD_PHYSICAL_ADDR, %rbp
10884 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10885 #endif
10886
10887 /* Target address to relocate to for decompression */
10888 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10889 index 88f7ff6..ed695dd 100644
10890 --- a/arch/x86/boot/compressed/misc.c
10891 +++ b/arch/x86/boot/compressed/misc.c
10892 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10893 case PT_LOAD:
10894 #ifdef CONFIG_RELOCATABLE
10895 dest = output;
10896 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10897 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10898 #else
10899 dest = (void *)(phdr->p_paddr);
10900 #endif
10901 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10902 error("Destination address too large");
10903 #endif
10904 #ifndef CONFIG_RELOCATABLE
10905 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10906 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10907 error("Wrong destination address");
10908 #endif
10909
10910 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10911 index 4d3ff03..e4972ff 100644
10912 --- a/arch/x86/boot/cpucheck.c
10913 +++ b/arch/x86/boot/cpucheck.c
10914 @@ -74,7 +74,7 @@ static int has_fpu(void)
10915 u16 fcw = -1, fsw = -1;
10916 u32 cr0;
10917
10918 - asm("movl %%cr0,%0" : "=r" (cr0));
10919 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10920 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10921 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10922 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10923 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10924 {
10925 u32 f0, f1;
10926
10927 - asm("pushfl ; "
10928 + asm volatile("pushfl ; "
10929 "pushfl ; "
10930 "popl %0 ; "
10931 "movl %0,%1 ; "
10932 @@ -115,7 +115,7 @@ static void get_flags(void)
10933 set_bit(X86_FEATURE_FPU, cpu.flags);
10934
10935 if (has_eflag(X86_EFLAGS_ID)) {
10936 - asm("cpuid"
10937 + asm volatile("cpuid"
10938 : "=a" (max_intel_level),
10939 "=b" (cpu_vendor[0]),
10940 "=d" (cpu_vendor[1]),
10941 @@ -124,7 +124,7 @@ static void get_flags(void)
10942
10943 if (max_intel_level >= 0x00000001 &&
10944 max_intel_level <= 0x0000ffff) {
10945 - asm("cpuid"
10946 + asm volatile("cpuid"
10947 : "=a" (tfms),
10948 "=c" (cpu.flags[4]),
10949 "=d" (cpu.flags[0])
10950 @@ -136,7 +136,7 @@ static void get_flags(void)
10951 cpu.model += ((tfms >> 16) & 0xf) << 4;
10952 }
10953
10954 - asm("cpuid"
10955 + asm volatile("cpuid"
10956 : "=a" (max_amd_level)
10957 : "a" (0x80000000)
10958 : "ebx", "ecx", "edx");
10959 @@ -144,7 +144,7 @@ static void get_flags(void)
10960 if (max_amd_level >= 0x80000001 &&
10961 max_amd_level <= 0x8000ffff) {
10962 u32 eax = 0x80000001;
10963 - asm("cpuid"
10964 + asm volatile("cpuid"
10965 : "+a" (eax),
10966 "=c" (cpu.flags[6]),
10967 "=d" (cpu.flags[1])
10968 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10969 u32 ecx = MSR_K7_HWCR;
10970 u32 eax, edx;
10971
10972 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10973 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10974 eax &= ~(1 << 15);
10975 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10976 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10977
10978 get_flags(); /* Make sure it really did something */
10979 err = check_flags();
10980 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10981 u32 ecx = MSR_VIA_FCR;
10982 u32 eax, edx;
10983
10984 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10985 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10986 eax |= (1<<1)|(1<<7);
10987 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10988 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10989
10990 set_bit(X86_FEATURE_CX8, cpu.flags);
10991 err = check_flags();
10992 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10993 u32 eax, edx;
10994 u32 level = 1;
10995
10996 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10997 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10998 - asm("cpuid"
10999 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11000 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
11001 + asm volatile("cpuid"
11002 : "+a" (level), "=d" (cpu.flags[0])
11003 : : "ecx", "ebx");
11004 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11005 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11006
11007 err = check_flags();
11008 }
11009 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
11010 index 944ce59..87ee37a 100644
11011 --- a/arch/x86/boot/header.S
11012 +++ b/arch/x86/boot/header.S
11013 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
11014 # single linked list of
11015 # struct setup_data
11016
11017 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
11018 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
11019
11020 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
11021 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
11022 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
11023 +#else
11024 #define VO_INIT_SIZE (VO__end - VO__text)
11025 +#endif
11026 #if ZO_INIT_SIZE > VO_INIT_SIZE
11027 #define INIT_SIZE ZO_INIT_SIZE
11028 #else
11029 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
11030 index db75d07..8e6d0af 100644
11031 --- a/arch/x86/boot/memory.c
11032 +++ b/arch/x86/boot/memory.c
11033 @@ -19,7 +19,7 @@
11034
11035 static int detect_memory_e820(void)
11036 {
11037 - int count = 0;
11038 + unsigned int count = 0;
11039 struct biosregs ireg, oreg;
11040 struct e820entry *desc = boot_params.e820_map;
11041 static struct e820entry buf; /* static so it is zeroed */
11042 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
11043 index 11e8c6e..fdbb1ed 100644
11044 --- a/arch/x86/boot/video-vesa.c
11045 +++ b/arch/x86/boot/video-vesa.c
11046 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
11047
11048 boot_params.screen_info.vesapm_seg = oreg.es;
11049 boot_params.screen_info.vesapm_off = oreg.di;
11050 + boot_params.screen_info.vesapm_size = oreg.cx;
11051 }
11052
11053 /*
11054 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
11055 index 43eda28..5ab5fdb 100644
11056 --- a/arch/x86/boot/video.c
11057 +++ b/arch/x86/boot/video.c
11058 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11059 static unsigned int get_entry(void)
11060 {
11061 char entry_buf[4];
11062 - int i, len = 0;
11063 + unsigned int i, len = 0;
11064 int key;
11065 unsigned int v;
11066
11067 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11068 index 5b577d5..3c1fed4 100644
11069 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11070 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11071 @@ -8,6 +8,8 @@
11072 * including this sentence is retained in full.
11073 */
11074
11075 +#include <asm/alternative-asm.h>
11076 +
11077 .extern crypto_ft_tab
11078 .extern crypto_it_tab
11079 .extern crypto_fl_tab
11080 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11081 je B192; \
11082 leaq 32(r9),r9;
11083
11084 +#define ret pax_force_retaddr 0, 1; ret
11085 +
11086 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11087 movq r1,r2; \
11088 movq r3,r4; \
11089 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11090 index 3470624..201259d 100644
11091 --- a/arch/x86/crypto/aesni-intel_asm.S
11092 +++ b/arch/x86/crypto/aesni-intel_asm.S
11093 @@ -31,6 +31,7 @@
11094
11095 #include <linux/linkage.h>
11096 #include <asm/inst.h>
11097 +#include <asm/alternative-asm.h>
11098
11099 #ifdef __x86_64__
11100 .data
11101 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11102 pop %r14
11103 pop %r13
11104 pop %r12
11105 + pax_force_retaddr 0, 1
11106 ret
11107 +ENDPROC(aesni_gcm_dec)
11108
11109
11110 /*****************************************************************************
11111 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11112 pop %r14
11113 pop %r13
11114 pop %r12
11115 + pax_force_retaddr 0, 1
11116 ret
11117 +ENDPROC(aesni_gcm_enc)
11118
11119 #endif
11120
11121 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11122 pxor %xmm1, %xmm0
11123 movaps %xmm0, (TKEYP)
11124 add $0x10, TKEYP
11125 + pax_force_retaddr_bts
11126 ret
11127
11128 .align 4
11129 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11130 shufps $0b01001110, %xmm2, %xmm1
11131 movaps %xmm1, 0x10(TKEYP)
11132 add $0x20, TKEYP
11133 + pax_force_retaddr_bts
11134 ret
11135
11136 .align 4
11137 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11138
11139 movaps %xmm0, (TKEYP)
11140 add $0x10, TKEYP
11141 + pax_force_retaddr_bts
11142 ret
11143
11144 .align 4
11145 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11146 pxor %xmm1, %xmm2
11147 movaps %xmm2, (TKEYP)
11148 add $0x10, TKEYP
11149 + pax_force_retaddr_bts
11150 ret
11151
11152 /*
11153 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11154 #ifndef __x86_64__
11155 popl KEYP
11156 #endif
11157 + pax_force_retaddr 0, 1
11158 ret
11159 +ENDPROC(aesni_set_key)
11160
11161 /*
11162 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11163 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11164 popl KLEN
11165 popl KEYP
11166 #endif
11167 + pax_force_retaddr 0, 1
11168 ret
11169 +ENDPROC(aesni_enc)
11170
11171 /*
11172 * _aesni_enc1: internal ABI
11173 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11174 AESENC KEY STATE
11175 movaps 0x70(TKEYP), KEY
11176 AESENCLAST KEY STATE
11177 + pax_force_retaddr_bts
11178 ret
11179
11180 /*
11181 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11182 AESENCLAST KEY STATE2
11183 AESENCLAST KEY STATE3
11184 AESENCLAST KEY STATE4
11185 + pax_force_retaddr_bts
11186 ret
11187
11188 /*
11189 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11190 popl KLEN
11191 popl KEYP
11192 #endif
11193 + pax_force_retaddr 0, 1
11194 ret
11195 +ENDPROC(aesni_dec)
11196
11197 /*
11198 * _aesni_dec1: internal ABI
11199 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11200 AESDEC KEY STATE
11201 movaps 0x70(TKEYP), KEY
11202 AESDECLAST KEY STATE
11203 + pax_force_retaddr_bts
11204 ret
11205
11206 /*
11207 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11208 AESDECLAST KEY STATE2
11209 AESDECLAST KEY STATE3
11210 AESDECLAST KEY STATE4
11211 + pax_force_retaddr_bts
11212 ret
11213
11214 /*
11215 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11216 popl KEYP
11217 popl LEN
11218 #endif
11219 + pax_force_retaddr 0, 1
11220 ret
11221 +ENDPROC(aesni_ecb_enc)
11222
11223 /*
11224 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11225 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11226 popl KEYP
11227 popl LEN
11228 #endif
11229 + pax_force_retaddr 0, 1
11230 ret
11231 +ENDPROC(aesni_ecb_dec)
11232
11233 /*
11234 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11235 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11236 popl LEN
11237 popl IVP
11238 #endif
11239 + pax_force_retaddr 0, 1
11240 ret
11241 +ENDPROC(aesni_cbc_enc)
11242
11243 /*
11244 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11245 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11246 popl LEN
11247 popl IVP
11248 #endif
11249 + pax_force_retaddr 0, 1
11250 ret
11251 +ENDPROC(aesni_cbc_dec)
11252
11253 #ifdef __x86_64__
11254 .align 16
11255 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11256 mov $1, TCTR_LOW
11257 MOVQ_R64_XMM TCTR_LOW INC
11258 MOVQ_R64_XMM CTR TCTR_LOW
11259 + pax_force_retaddr_bts
11260 ret
11261
11262 /*
11263 @@ -2554,6 +2582,7 @@ _aesni_inc:
11264 .Linc_low:
11265 movaps CTR, IV
11266 PSHUFB_XMM BSWAP_MASK IV
11267 + pax_force_retaddr_bts
11268 ret
11269
11270 /*
11271 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11272 .Lctr_enc_ret:
11273 movups IV, (IVP)
11274 .Lctr_enc_just_ret:
11275 + pax_force_retaddr 0, 1
11276 ret
11277 +ENDPROC(aesni_ctr_enc)
11278 #endif
11279 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11280 index 391d245..67f35c2 100644
11281 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11282 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11283 @@ -20,6 +20,8 @@
11284 *
11285 */
11286
11287 +#include <asm/alternative-asm.h>
11288 +
11289 .file "blowfish-x86_64-asm.S"
11290 .text
11291
11292 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11293 jnz __enc_xor;
11294
11295 write_block();
11296 + pax_force_retaddr 0, 1
11297 ret;
11298 __enc_xor:
11299 xor_block();
11300 + pax_force_retaddr 0, 1
11301 ret;
11302
11303 .align 8
11304 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11305
11306 movq %r11, %rbp;
11307
11308 + pax_force_retaddr 0, 1
11309 ret;
11310
11311 /**********************************************************************
11312 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11313
11314 popq %rbx;
11315 popq %rbp;
11316 + pax_force_retaddr 0, 1
11317 ret;
11318
11319 __enc_xor4:
11320 @@ -349,6 +355,7 @@ __enc_xor4:
11321
11322 popq %rbx;
11323 popq %rbp;
11324 + pax_force_retaddr 0, 1
11325 ret;
11326
11327 .align 8
11328 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11329 popq %rbx;
11330 popq %rbp;
11331
11332 + pax_force_retaddr 0, 1
11333 ret;
11334
11335 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11336 index 0b33743..7a56206 100644
11337 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11338 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11339 @@ -20,6 +20,8 @@
11340 *
11341 */
11342
11343 +#include <asm/alternative-asm.h>
11344 +
11345 .file "camellia-x86_64-asm_64.S"
11346 .text
11347
11348 @@ -229,12 +231,14 @@ __enc_done:
11349 enc_outunpack(mov, RT1);
11350
11351 movq RRBP, %rbp;
11352 + pax_force_retaddr 0, 1
11353 ret;
11354
11355 __enc_xor:
11356 enc_outunpack(xor, RT1);
11357
11358 movq RRBP, %rbp;
11359 + pax_force_retaddr 0, 1
11360 ret;
11361
11362 .global camellia_dec_blk;
11363 @@ -275,6 +279,7 @@ __dec_rounds16:
11364 dec_outunpack();
11365
11366 movq RRBP, %rbp;
11367 + pax_force_retaddr 0, 1
11368 ret;
11369
11370 /**********************************************************************
11371 @@ -468,6 +473,7 @@ __enc2_done:
11372
11373 movq RRBP, %rbp;
11374 popq %rbx;
11375 + pax_force_retaddr 0, 1
11376 ret;
11377
11378 __enc2_xor:
11379 @@ -475,6 +481,7 @@ __enc2_xor:
11380
11381 movq RRBP, %rbp;
11382 popq %rbx;
11383 + pax_force_retaddr 0, 1
11384 ret;
11385
11386 .global camellia_dec_blk_2way;
11387 @@ -517,4 +524,5 @@ __dec2_rounds16:
11388
11389 movq RRBP, %rbp;
11390 movq RXOR, %rbx;
11391 + pax_force_retaddr 0, 1
11392 ret;
11393 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11394 index 15b00ac..2071784 100644
11395 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11396 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11397 @@ -23,6 +23,8 @@
11398 *
11399 */
11400
11401 +#include <asm/alternative-asm.h>
11402 +
11403 .file "cast5-avx-x86_64-asm_64.S"
11404
11405 .extern cast_s1
11406 @@ -281,6 +283,7 @@ __skip_enc:
11407 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11408 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11409
11410 + pax_force_retaddr 0, 1
11411 ret;
11412
11413 .align 16
11414 @@ -353,6 +356,7 @@ __dec_tail:
11415 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11416 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11417
11418 + pax_force_retaddr 0, 1
11419 ret;
11420
11421 __skip_dec:
11422 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11423 vmovdqu RR4, (6*4*4)(%r11);
11424 vmovdqu RL4, (7*4*4)(%r11);
11425
11426 + pax_force_retaddr
11427 ret;
11428
11429 .align 16
11430 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11431 vmovdqu RR4, (6*4*4)(%r11);
11432 vmovdqu RL4, (7*4*4)(%r11);
11433
11434 + pax_force_retaddr
11435 ret;
11436
11437 .align 16
11438 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11439
11440 popq %r12;
11441
11442 + pax_force_retaddr
11443 ret;
11444
11445 .align 16
11446 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11447
11448 popq %r12;
11449
11450 + pax_force_retaddr
11451 ret;
11452 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11453 index 2569d0d..637c289 100644
11454 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11455 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11456 @@ -23,6 +23,8 @@
11457 *
11458 */
11459
11460 +#include <asm/alternative-asm.h>
11461 +
11462 #include "glue_helper-asm-avx.S"
11463
11464 .file "cast6-avx-x86_64-asm_64.S"
11465 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11466 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11467 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11468
11469 + pax_force_retaddr 0, 1
11470 ret;
11471
11472 .align 8
11473 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11474 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11475 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11476
11477 + pax_force_retaddr 0, 1
11478 ret;
11479
11480 .align 8
11481 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11482
11483 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11484
11485 + pax_force_retaddr
11486 ret;
11487
11488 .align 8
11489 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11490
11491 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11492
11493 + pax_force_retaddr
11494 ret;
11495
11496 .align 8
11497 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11498
11499 popq %r12;
11500
11501 + pax_force_retaddr
11502 ret;
11503
11504 .align 8
11505 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11506
11507 popq %r12;
11508
11509 + pax_force_retaddr
11510 ret;
11511 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11512 index 6214a9b..1f4fc9a 100644
11513 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11514 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11515 @@ -1,3 +1,5 @@
11516 +#include <asm/alternative-asm.h>
11517 +
11518 # enter ECRYPT_encrypt_bytes
11519 .text
11520 .p2align 5
11521 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11522 add %r11,%rsp
11523 mov %rdi,%rax
11524 mov %rsi,%rdx
11525 + pax_force_retaddr 0, 1
11526 ret
11527 # bytesatleast65:
11528 ._bytesatleast65:
11529 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11530 add %r11,%rsp
11531 mov %rdi,%rax
11532 mov %rsi,%rdx
11533 + pax_force_retaddr
11534 ret
11535 # enter ECRYPT_ivsetup
11536 .text
11537 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11538 add %r11,%rsp
11539 mov %rdi,%rax
11540 mov %rsi,%rdx
11541 + pax_force_retaddr
11542 ret
11543 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11544 index 02b0e9f..cf4cf5c 100644
11545 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11546 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11547 @@ -24,6 +24,8 @@
11548 *
11549 */
11550
11551 +#include <asm/alternative-asm.h>
11552 +
11553 #include "glue_helper-asm-avx.S"
11554
11555 .file "serpent-avx-x86_64-asm_64.S"
11556 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11557 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11558 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11559
11560 + pax_force_retaddr
11561 ret;
11562
11563 .align 8
11564 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11565 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11566 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11567
11568 + pax_force_retaddr
11569 ret;
11570
11571 .align 8
11572 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11573
11574 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11575
11576 + pax_force_retaddr
11577 ret;
11578
11579 .align 8
11580 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11581
11582 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11583
11584 + pax_force_retaddr
11585 ret;
11586
11587 .align 8
11588 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11589
11590 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11591
11592 + pax_force_retaddr
11593 ret;
11594
11595 .align 8
11596 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11597
11598 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11599
11600 + pax_force_retaddr
11601 ret;
11602 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11603 index 3ee1ff0..cbc568b 100644
11604 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11605 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11606 @@ -24,6 +24,8 @@
11607 *
11608 */
11609
11610 +#include <asm/alternative-asm.h>
11611 +
11612 .file "serpent-sse2-x86_64-asm_64.S"
11613 .text
11614
11615 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11616 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11617 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11618
11619 + pax_force_retaddr
11620 ret;
11621
11622 __enc_xor8:
11623 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11624 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11625
11626 + pax_force_retaddr
11627 ret;
11628
11629 .align 8
11630 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11631 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11632 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11633
11634 + pax_force_retaddr
11635 ret;
11636 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11637 index 49d6987..df66bd4 100644
11638 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11639 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11640 @@ -28,6 +28,8 @@
11641 * (at your option) any later version.
11642 */
11643
11644 +#include <asm/alternative-asm.h>
11645 +
11646 #define CTX %rdi // arg1
11647 #define BUF %rsi // arg2
11648 #define CNT %rdx // arg3
11649 @@ -104,6 +106,7 @@
11650 pop %r12
11651 pop %rbp
11652 pop %rbx
11653 + pax_force_retaddr 0, 1
11654 ret
11655
11656 .size \name, .-\name
11657 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11658 index ebac16b..8092eb9 100644
11659 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11660 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11661 @@ -23,6 +23,8 @@
11662 *
11663 */
11664
11665 +#include <asm/alternative-asm.h>
11666 +
11667 #include "glue_helper-asm-avx.S"
11668
11669 .file "twofish-avx-x86_64-asm_64.S"
11670 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11671 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11672 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11673
11674 + pax_force_retaddr 0, 1
11675 ret;
11676
11677 .align 8
11678 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11679 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11680 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11681
11682 + pax_force_retaddr 0, 1
11683 ret;
11684
11685 .align 8
11686 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11687
11688 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11689
11690 + pax_force_retaddr 0, 1
11691 ret;
11692
11693 .align 8
11694 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11695
11696 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11697
11698 + pax_force_retaddr 0, 1
11699 ret;
11700
11701 .align 8
11702 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11703
11704 popq %r12;
11705
11706 + pax_force_retaddr 0, 1
11707 ret;
11708
11709 .align 8
11710 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11711
11712 popq %r12;
11713
11714 + pax_force_retaddr 0, 1
11715 ret;
11716 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11717 index 5b012a2..36d5364 100644
11718 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11719 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11720 @@ -20,6 +20,8 @@
11721 *
11722 */
11723
11724 +#include <asm/alternative-asm.h>
11725 +
11726 .file "twofish-x86_64-asm-3way.S"
11727 .text
11728
11729 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11730 popq %r13;
11731 popq %r14;
11732 popq %r15;
11733 + pax_force_retaddr 0, 1
11734 ret;
11735
11736 __enc_xor3:
11737 @@ -271,6 +274,7 @@ __enc_xor3:
11738 popq %r13;
11739 popq %r14;
11740 popq %r15;
11741 + pax_force_retaddr 0, 1
11742 ret;
11743
11744 .global twofish_dec_blk_3way
11745 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11746 popq %r13;
11747 popq %r14;
11748 popq %r15;
11749 + pax_force_retaddr 0, 1
11750 ret;
11751
11752 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11753 index 7bcf3fc..f53832f 100644
11754 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11755 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11756 @@ -21,6 +21,7 @@
11757 .text
11758
11759 #include <asm/asm-offsets.h>
11760 +#include <asm/alternative-asm.h>
11761
11762 #define a_offset 0
11763 #define b_offset 4
11764 @@ -268,6 +269,7 @@ twofish_enc_blk:
11765
11766 popq R1
11767 movq $1,%rax
11768 + pax_force_retaddr 0, 1
11769 ret
11770
11771 twofish_dec_blk:
11772 @@ -319,4 +321,5 @@ twofish_dec_blk:
11773
11774 popq R1
11775 movq $1,%rax
11776 + pax_force_retaddr 0, 1
11777 ret
11778 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11779 index a703af1..f5b9c36 100644
11780 --- a/arch/x86/ia32/ia32_aout.c
11781 +++ b/arch/x86/ia32/ia32_aout.c
11782 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11783 unsigned long dump_start, dump_size;
11784 struct user32 dump;
11785
11786 + memset(&dump, 0, sizeof(dump));
11787 +
11788 fs = get_fs();
11789 set_fs(KERNEL_DS);
11790 has_dumped = 1;
11791 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11792 index a1daf4a..f8c4537 100644
11793 --- a/arch/x86/ia32/ia32_signal.c
11794 +++ b/arch/x86/ia32/ia32_signal.c
11795 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11796 sp -= frame_size;
11797 /* Align the stack pointer according to the i386 ABI,
11798 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11799 - sp = ((sp + 4) & -16ul) - 4;
11800 + sp = ((sp - 12) & -16ul) - 4;
11801 return (void __user *) sp;
11802 }
11803
11804 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11805 * These are actually not used anymore, but left because some
11806 * gdb versions depend on them as a marker.
11807 */
11808 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11809 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11810 } put_user_catch(err);
11811
11812 if (err)
11813 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11814 0xb8,
11815 __NR_ia32_rt_sigreturn,
11816 0x80cd,
11817 - 0,
11818 + 0
11819 };
11820
11821 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11822 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11823
11824 if (ka->sa.sa_flags & SA_RESTORER)
11825 restorer = ka->sa.sa_restorer;
11826 + else if (current->mm->context.vdso)
11827 + /* Return stub is in 32bit vsyscall page */
11828 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11829 else
11830 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11831 - rt_sigreturn);
11832 + restorer = &frame->retcode;
11833 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11834
11835 /*
11836 * Not actually used anymore, but left because some gdb
11837 * versions need it.
11838 */
11839 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11840 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11841 } put_user_catch(err);
11842
11843 err |= copy_siginfo_to_user32(&frame->info, info);
11844 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11845 index 142c4ce..19b683f 100644
11846 --- a/arch/x86/ia32/ia32entry.S
11847 +++ b/arch/x86/ia32/ia32entry.S
11848 @@ -15,8 +15,10 @@
11849 #include <asm/irqflags.h>
11850 #include <asm/asm.h>
11851 #include <asm/smap.h>
11852 +#include <asm/pgtable.h>
11853 #include <linux/linkage.h>
11854 #include <linux/err.h>
11855 +#include <asm/alternative-asm.h>
11856
11857 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11858 #include <linux/elf-em.h>
11859 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11860 ENDPROC(native_irq_enable_sysexit)
11861 #endif
11862
11863 + .macro pax_enter_kernel_user
11864 + pax_set_fptr_mask
11865 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11866 + call pax_enter_kernel_user
11867 +#endif
11868 + .endm
11869 +
11870 + .macro pax_exit_kernel_user
11871 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11872 + call pax_exit_kernel_user
11873 +#endif
11874 +#ifdef CONFIG_PAX_RANDKSTACK
11875 + pushq %rax
11876 + pushq %r11
11877 + call pax_randomize_kstack
11878 + popq %r11
11879 + popq %rax
11880 +#endif
11881 + .endm
11882 +
11883 +.macro pax_erase_kstack
11884 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11885 + call pax_erase_kstack
11886 +#endif
11887 +.endm
11888 +
11889 /*
11890 * 32bit SYSENTER instruction entry.
11891 *
11892 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11893 CFI_REGISTER rsp,rbp
11894 SWAPGS_UNSAFE_STACK
11895 movq PER_CPU_VAR(kernel_stack), %rsp
11896 - addq $(KERNEL_STACK_OFFSET),%rsp
11897 - /*
11898 - * No need to follow this irqs on/off section: the syscall
11899 - * disabled irqs, here we enable it straight after entry:
11900 - */
11901 - ENABLE_INTERRUPTS(CLBR_NONE)
11902 movl %ebp,%ebp /* zero extension */
11903 pushq_cfi $__USER32_DS
11904 /*CFI_REL_OFFSET ss,0*/
11905 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11906 CFI_REL_OFFSET rsp,0
11907 pushfq_cfi
11908 /*CFI_REL_OFFSET rflags,0*/
11909 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11910 - CFI_REGISTER rip,r10
11911 + orl $X86_EFLAGS_IF,(%rsp)
11912 + GET_THREAD_INFO(%r11)
11913 + movl TI_sysenter_return(%r11), %r11d
11914 + CFI_REGISTER rip,r11
11915 pushq_cfi $__USER32_CS
11916 /*CFI_REL_OFFSET cs,0*/
11917 movl %eax, %eax
11918 - pushq_cfi %r10
11919 + pushq_cfi %r11
11920 CFI_REL_OFFSET rip,0
11921 pushq_cfi %rax
11922 cld
11923 SAVE_ARGS 0,1,0
11924 + pax_enter_kernel_user
11925 +
11926 +#ifdef CONFIG_PAX_RANDKSTACK
11927 + pax_erase_kstack
11928 +#endif
11929 +
11930 + /*
11931 + * No need to follow this irqs on/off section: the syscall
11932 + * disabled irqs, here we enable it straight after entry:
11933 + */
11934 + ENABLE_INTERRUPTS(CLBR_NONE)
11935 /* no need to do an access_ok check here because rbp has been
11936 32bit zero extended */
11937 +
11938 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11939 + mov $PAX_USER_SHADOW_BASE,%r11
11940 + add %r11,%rbp
11941 +#endif
11942 +
11943 ASM_STAC
11944 1: movl (%rbp),%ebp
11945 _ASM_EXTABLE(1b,ia32_badarg)
11946 ASM_CLAC
11947 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11948 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11949 + GET_THREAD_INFO(%r11)
11950 + orl $TS_COMPAT,TI_status(%r11)
11951 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11952 CFI_REMEMBER_STATE
11953 jnz sysenter_tracesys
11954 cmpq $(IA32_NR_syscalls-1),%rax
11955 @@ -162,12 +204,15 @@ sysenter_do_call:
11956 sysenter_dispatch:
11957 call *ia32_sys_call_table(,%rax,8)
11958 movq %rax,RAX-ARGOFFSET(%rsp)
11959 + GET_THREAD_INFO(%r11)
11960 DISABLE_INTERRUPTS(CLBR_NONE)
11961 TRACE_IRQS_OFF
11962 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11963 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11964 jnz sysexit_audit
11965 sysexit_from_sys_call:
11966 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11967 + pax_exit_kernel_user
11968 + pax_erase_kstack
11969 + andl $~TS_COMPAT,TI_status(%r11)
11970 /* clear IF, that popfq doesn't enable interrupts early */
11971 andl $~0x200,EFLAGS-R11(%rsp)
11972 movl RIP-R11(%rsp),%edx /* User %eip */
11973 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11974 movl %eax,%esi /* 2nd arg: syscall number */
11975 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11976 call __audit_syscall_entry
11977 +
11978 + pax_erase_kstack
11979 +
11980 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11981 cmpq $(IA32_NR_syscalls-1),%rax
11982 ja ia32_badsys
11983 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11984 .endm
11985
11986 .macro auditsys_exit exit
11987 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11988 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11989 jnz ia32_ret_from_sys_call
11990 TRACE_IRQS_ON
11991 ENABLE_INTERRUPTS(CLBR_NONE)
11992 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11993 1: setbe %al /* 1 if error, 0 if not */
11994 movzbl %al,%edi /* zero-extend that into %edi */
11995 call __audit_syscall_exit
11996 + GET_THREAD_INFO(%r11)
11997 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11998 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11999 DISABLE_INTERRUPTS(CLBR_NONE)
12000 TRACE_IRQS_OFF
12001 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12002 + testl %edi,TI_flags(%r11)
12003 jz \exit
12004 CLEAR_RREGS -ARGOFFSET
12005 jmp int_with_check
12006 @@ -237,7 +286,7 @@ sysexit_audit:
12007
12008 sysenter_tracesys:
12009 #ifdef CONFIG_AUDITSYSCALL
12010 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12011 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12012 jz sysenter_auditsys
12013 #endif
12014 SAVE_REST
12015 @@ -249,6 +298,9 @@ sysenter_tracesys:
12016 RESTORE_REST
12017 cmpq $(IA32_NR_syscalls-1),%rax
12018 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12019 +
12020 + pax_erase_kstack
12021 +
12022 jmp sysenter_do_call
12023 CFI_ENDPROC
12024 ENDPROC(ia32_sysenter_target)
12025 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
12026 ENTRY(ia32_cstar_target)
12027 CFI_STARTPROC32 simple
12028 CFI_SIGNAL_FRAME
12029 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12030 + CFI_DEF_CFA rsp,0
12031 CFI_REGISTER rip,rcx
12032 /*CFI_REGISTER rflags,r11*/
12033 SWAPGS_UNSAFE_STACK
12034 movl %esp,%r8d
12035 CFI_REGISTER rsp,r8
12036 movq PER_CPU_VAR(kernel_stack),%rsp
12037 + SAVE_ARGS 8*6,0,0
12038 + pax_enter_kernel_user
12039 +
12040 +#ifdef CONFIG_PAX_RANDKSTACK
12041 + pax_erase_kstack
12042 +#endif
12043 +
12044 /*
12045 * No need to follow this irqs on/off section: the syscall
12046 * disabled irqs and here we enable it straight after entry:
12047 */
12048 ENABLE_INTERRUPTS(CLBR_NONE)
12049 - SAVE_ARGS 8,0,0
12050 movl %eax,%eax /* zero extension */
12051 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12052 movq %rcx,RIP-ARGOFFSET(%rsp)
12053 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
12054 /* no need to do an access_ok check here because r8 has been
12055 32bit zero extended */
12056 /* hardware stack frame is complete now */
12057 +
12058 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12059 + mov $PAX_USER_SHADOW_BASE,%r11
12060 + add %r11,%r8
12061 +#endif
12062 +
12063 ASM_STAC
12064 1: movl (%r8),%r9d
12065 _ASM_EXTABLE(1b,ia32_badarg)
12066 ASM_CLAC
12067 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12068 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12069 + GET_THREAD_INFO(%r11)
12070 + orl $TS_COMPAT,TI_status(%r11)
12071 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12072 CFI_REMEMBER_STATE
12073 jnz cstar_tracesys
12074 cmpq $IA32_NR_syscalls-1,%rax
12075 @@ -319,12 +384,15 @@ cstar_do_call:
12076 cstar_dispatch:
12077 call *ia32_sys_call_table(,%rax,8)
12078 movq %rax,RAX-ARGOFFSET(%rsp)
12079 + GET_THREAD_INFO(%r11)
12080 DISABLE_INTERRUPTS(CLBR_NONE)
12081 TRACE_IRQS_OFF
12082 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12083 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12084 jnz sysretl_audit
12085 sysretl_from_sys_call:
12086 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12087 + pax_exit_kernel_user
12088 + pax_erase_kstack
12089 + andl $~TS_COMPAT,TI_status(%r11)
12090 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12091 movl RIP-ARGOFFSET(%rsp),%ecx
12092 CFI_REGISTER rip,rcx
12093 @@ -352,7 +420,7 @@ sysretl_audit:
12094
12095 cstar_tracesys:
12096 #ifdef CONFIG_AUDITSYSCALL
12097 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12098 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12099 jz cstar_auditsys
12100 #endif
12101 xchgl %r9d,%ebp
12102 @@ -366,6 +434,9 @@ cstar_tracesys:
12103 xchgl %ebp,%r9d
12104 cmpq $(IA32_NR_syscalls-1),%rax
12105 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12106 +
12107 + pax_erase_kstack
12108 +
12109 jmp cstar_do_call
12110 END(ia32_cstar_target)
12111
12112 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12113 CFI_REL_OFFSET rip,RIP-RIP
12114 PARAVIRT_ADJUST_EXCEPTION_FRAME
12115 SWAPGS
12116 - /*
12117 - * No need to follow this irqs on/off section: the syscall
12118 - * disabled irqs and here we enable it straight after entry:
12119 - */
12120 - ENABLE_INTERRUPTS(CLBR_NONE)
12121 movl %eax,%eax
12122 pushq_cfi %rax
12123 cld
12124 /* note the registers are not zero extended to the sf.
12125 this could be a problem. */
12126 SAVE_ARGS 0,1,0
12127 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12128 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12129 + pax_enter_kernel_user
12130 +
12131 +#ifdef CONFIG_PAX_RANDKSTACK
12132 + pax_erase_kstack
12133 +#endif
12134 +
12135 + /*
12136 + * No need to follow this irqs on/off section: the syscall
12137 + * disabled irqs and here we enable it straight after entry:
12138 + */
12139 + ENABLE_INTERRUPTS(CLBR_NONE)
12140 + GET_THREAD_INFO(%r11)
12141 + orl $TS_COMPAT,TI_status(%r11)
12142 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12143 jnz ia32_tracesys
12144 cmpq $(IA32_NR_syscalls-1),%rax
12145 ja ia32_badsys
12146 @@ -442,6 +520,9 @@ ia32_tracesys:
12147 RESTORE_REST
12148 cmpq $(IA32_NR_syscalls-1),%rax
12149 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12150 +
12151 + pax_erase_kstack
12152 +
12153 jmp ia32_do_call
12154 END(ia32_syscall)
12155
12156 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12157 index d0b689b..6811ddc 100644
12158 --- a/arch/x86/ia32/sys_ia32.c
12159 +++ b/arch/x86/ia32/sys_ia32.c
12160 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12161 */
12162 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12163 {
12164 - typeof(ubuf->st_uid) uid = 0;
12165 - typeof(ubuf->st_gid) gid = 0;
12166 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12167 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12168 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12169 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12170 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12171 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12172 mm_segment_t old_fs = get_fs();
12173
12174 set_fs(KERNEL_DS);
12175 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12176 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12177 set_fs(old_fs);
12178 if (put_compat_timespec(&t, interval))
12179 return -EFAULT;
12180 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12181 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12182 compat_size_t sigsetsize)
12183 {
12184 - sigset_t s;
12185 + sigset_t s = { };
12186 compat_sigset_t s32;
12187 int ret;
12188 mm_segment_t old_fs = get_fs();
12189
12190 set_fs(KERNEL_DS);
12191 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12192 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12193 set_fs(old_fs);
12194 if (!ret) {
12195 switch (_NSIG_WORDS) {
12196 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12197 if (copy_siginfo_from_user32(&info, uinfo))
12198 return -EFAULT;
12199 set_fs(KERNEL_DS);
12200 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12201 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12202 set_fs(old_fs);
12203 return ret;
12204 }
12205 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12206 return -EFAULT;
12207
12208 set_fs(KERNEL_DS);
12209 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12210 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12211 count);
12212 set_fs(old_fs);
12213
12214 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12215 index 372231c..a5aa1a1 100644
12216 --- a/arch/x86/include/asm/alternative-asm.h
12217 +++ b/arch/x86/include/asm/alternative-asm.h
12218 @@ -18,6 +18,45 @@
12219 .endm
12220 #endif
12221
12222 +#ifdef KERNEXEC_PLUGIN
12223 + .macro pax_force_retaddr_bts rip=0
12224 + btsq $63,\rip(%rsp)
12225 + .endm
12226 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12227 + .macro pax_force_retaddr rip=0, reload=0
12228 + btsq $63,\rip(%rsp)
12229 + .endm
12230 + .macro pax_force_fptr ptr
12231 + btsq $63,\ptr
12232 + .endm
12233 + .macro pax_set_fptr_mask
12234 + .endm
12235 +#endif
12236 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12237 + .macro pax_force_retaddr rip=0, reload=0
12238 + .if \reload
12239 + pax_set_fptr_mask
12240 + .endif
12241 + orq %r10,\rip(%rsp)
12242 + .endm
12243 + .macro pax_force_fptr ptr
12244 + orq %r10,\ptr
12245 + .endm
12246 + .macro pax_set_fptr_mask
12247 + movabs $0x8000000000000000,%r10
12248 + .endm
12249 +#endif
12250 +#else
12251 + .macro pax_force_retaddr rip=0, reload=0
12252 + .endm
12253 + .macro pax_force_fptr ptr
12254 + .endm
12255 + .macro pax_force_retaddr_bts rip=0
12256 + .endm
12257 + .macro pax_set_fptr_mask
12258 + .endm
12259 +#endif
12260 +
12261 .macro altinstruction_entry orig alt feature orig_len alt_len
12262 .long \orig - .
12263 .long \alt - .
12264 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12265 index 58ed6d9..f1cbe58 100644
12266 --- a/arch/x86/include/asm/alternative.h
12267 +++ b/arch/x86/include/asm/alternative.h
12268 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12269 ".pushsection .discard,\"aw\",@progbits\n" \
12270 DISCARD_ENTRY(1) \
12271 ".popsection\n" \
12272 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12273 + ".pushsection .altinstr_replacement, \"a\"\n" \
12274 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12275 ".popsection"
12276
12277 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12278 DISCARD_ENTRY(1) \
12279 DISCARD_ENTRY(2) \
12280 ".popsection\n" \
12281 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12282 + ".pushsection .altinstr_replacement, \"a\"\n" \
12283 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12284 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12285 ".popsection"
12286 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12287 index 3388034..050f0b9 100644
12288 --- a/arch/x86/include/asm/apic.h
12289 +++ b/arch/x86/include/asm/apic.h
12290 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12291
12292 #ifdef CONFIG_X86_LOCAL_APIC
12293
12294 -extern unsigned int apic_verbosity;
12295 +extern int apic_verbosity;
12296 extern int local_apic_timer_c2_ok;
12297
12298 extern int disable_apic;
12299 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12300 index 20370c6..a2eb9b0 100644
12301 --- a/arch/x86/include/asm/apm.h
12302 +++ b/arch/x86/include/asm/apm.h
12303 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12304 __asm__ __volatile__(APM_DO_ZERO_SEGS
12305 "pushl %%edi\n\t"
12306 "pushl %%ebp\n\t"
12307 - "lcall *%%cs:apm_bios_entry\n\t"
12308 + "lcall *%%ss:apm_bios_entry\n\t"
12309 "setc %%al\n\t"
12310 "popl %%ebp\n\t"
12311 "popl %%edi\n\t"
12312 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12313 __asm__ __volatile__(APM_DO_ZERO_SEGS
12314 "pushl %%edi\n\t"
12315 "pushl %%ebp\n\t"
12316 - "lcall *%%cs:apm_bios_entry\n\t"
12317 + "lcall *%%ss:apm_bios_entry\n\t"
12318 "setc %%bl\n\t"
12319 "popl %%ebp\n\t"
12320 "popl %%edi\n\t"
12321 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12322 index 722aa3b..3a0bb27 100644
12323 --- a/arch/x86/include/asm/atomic.h
12324 +++ b/arch/x86/include/asm/atomic.h
12325 @@ -22,7 +22,18 @@
12326 */
12327 static inline int atomic_read(const atomic_t *v)
12328 {
12329 - return (*(volatile int *)&(v)->counter);
12330 + return (*(volatile const int *)&(v)->counter);
12331 +}
12332 +
12333 +/**
12334 + * atomic_read_unchecked - read atomic variable
12335 + * @v: pointer of type atomic_unchecked_t
12336 + *
12337 + * Atomically reads the value of @v.
12338 + */
12339 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12340 +{
12341 + return (*(volatile const int *)&(v)->counter);
12342 }
12343
12344 /**
12345 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12346 }
12347
12348 /**
12349 + * atomic_set_unchecked - set atomic variable
12350 + * @v: pointer of type atomic_unchecked_t
12351 + * @i: required value
12352 + *
12353 + * Atomically sets the value of @v to @i.
12354 + */
12355 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12356 +{
12357 + v->counter = i;
12358 +}
12359 +
12360 +/**
12361 * atomic_add - add integer to atomic variable
12362 * @i: integer value to add
12363 * @v: pointer of type atomic_t
12364 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12365 */
12366 static inline void atomic_add(int i, atomic_t *v)
12367 {
12368 - asm volatile(LOCK_PREFIX "addl %1,%0"
12369 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12370 +
12371 +#ifdef CONFIG_PAX_REFCOUNT
12372 + "jno 0f\n"
12373 + LOCK_PREFIX "subl %1,%0\n"
12374 + "int $4\n0:\n"
12375 + _ASM_EXTABLE(0b, 0b)
12376 +#endif
12377 +
12378 + : "+m" (v->counter)
12379 + : "ir" (i));
12380 +}
12381 +
12382 +/**
12383 + * atomic_add_unchecked - add integer to atomic variable
12384 + * @i: integer value to add
12385 + * @v: pointer of type atomic_unchecked_t
12386 + *
12387 + * Atomically adds @i to @v.
12388 + */
12389 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12390 +{
12391 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12392 : "+m" (v->counter)
12393 : "ir" (i));
12394 }
12395 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12396 */
12397 static inline void atomic_sub(int i, atomic_t *v)
12398 {
12399 - asm volatile(LOCK_PREFIX "subl %1,%0"
12400 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12401 +
12402 +#ifdef CONFIG_PAX_REFCOUNT
12403 + "jno 0f\n"
12404 + LOCK_PREFIX "addl %1,%0\n"
12405 + "int $4\n0:\n"
12406 + _ASM_EXTABLE(0b, 0b)
12407 +#endif
12408 +
12409 + : "+m" (v->counter)
12410 + : "ir" (i));
12411 +}
12412 +
12413 +/**
12414 + * atomic_sub_unchecked - subtract integer from atomic variable
12415 + * @i: integer value to subtract
12416 + * @v: pointer of type atomic_unchecked_t
12417 + *
12418 + * Atomically subtracts @i from @v.
12419 + */
12420 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12421 +{
12422 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12423 : "+m" (v->counter)
12424 : "ir" (i));
12425 }
12426 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12427 {
12428 unsigned char c;
12429
12430 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12431 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX "addl %2,%0\n"
12436 + "int $4\n0:\n"
12437 + _ASM_EXTABLE(0b, 0b)
12438 +#endif
12439 +
12440 + "sete %1\n"
12441 : "+m" (v->counter), "=qm" (c)
12442 : "ir" (i) : "memory");
12443 return c;
12444 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12445 */
12446 static inline void atomic_inc(atomic_t *v)
12447 {
12448 - asm volatile(LOCK_PREFIX "incl %0"
12449 + asm volatile(LOCK_PREFIX "incl %0\n"
12450 +
12451 +#ifdef CONFIG_PAX_REFCOUNT
12452 + "jno 0f\n"
12453 + LOCK_PREFIX "decl %0\n"
12454 + "int $4\n0:\n"
12455 + _ASM_EXTABLE(0b, 0b)
12456 +#endif
12457 +
12458 + : "+m" (v->counter));
12459 +}
12460 +
12461 +/**
12462 + * atomic_inc_unchecked - increment atomic variable
12463 + * @v: pointer of type atomic_unchecked_t
12464 + *
12465 + * Atomically increments @v by 1.
12466 + */
12467 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12468 +{
12469 + asm volatile(LOCK_PREFIX "incl %0\n"
12470 : "+m" (v->counter));
12471 }
12472
12473 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12474 */
12475 static inline void atomic_dec(atomic_t *v)
12476 {
12477 - asm volatile(LOCK_PREFIX "decl %0"
12478 + asm volatile(LOCK_PREFIX "decl %0\n"
12479 +
12480 +#ifdef CONFIG_PAX_REFCOUNT
12481 + "jno 0f\n"
12482 + LOCK_PREFIX "incl %0\n"
12483 + "int $4\n0:\n"
12484 + _ASM_EXTABLE(0b, 0b)
12485 +#endif
12486 +
12487 + : "+m" (v->counter));
12488 +}
12489 +
12490 +/**
12491 + * atomic_dec_unchecked - decrement atomic variable
12492 + * @v: pointer of type atomic_unchecked_t
12493 + *
12494 + * Atomically decrements @v by 1.
12495 + */
12496 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12497 +{
12498 + asm volatile(LOCK_PREFIX "decl %0\n"
12499 : "+m" (v->counter));
12500 }
12501
12502 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12503 {
12504 unsigned char c;
12505
12506 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12507 + asm volatile(LOCK_PREFIX "decl %0\n"
12508 +
12509 +#ifdef CONFIG_PAX_REFCOUNT
12510 + "jno 0f\n"
12511 + LOCK_PREFIX "incl %0\n"
12512 + "int $4\n0:\n"
12513 + _ASM_EXTABLE(0b, 0b)
12514 +#endif
12515 +
12516 + "sete %1\n"
12517 : "+m" (v->counter), "=qm" (c)
12518 : : "memory");
12519 return c != 0;
12520 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12521 {
12522 unsigned char c;
12523
12524 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12525 + asm volatile(LOCK_PREFIX "incl %0\n"
12526 +
12527 +#ifdef CONFIG_PAX_REFCOUNT
12528 + "jno 0f\n"
12529 + LOCK_PREFIX "decl %0\n"
12530 + "int $4\n0:\n"
12531 + _ASM_EXTABLE(0b, 0b)
12532 +#endif
12533 +
12534 + "sete %1\n"
12535 + : "+m" (v->counter), "=qm" (c)
12536 + : : "memory");
12537 + return c != 0;
12538 +}
12539 +
12540 +/**
12541 + * atomic_inc_and_test_unchecked - increment and test
12542 + * @v: pointer of type atomic_unchecked_t
12543 + *
12544 + * Atomically increments @v by 1
12545 + * and returns true if the result is zero, or false for all
12546 + * other cases.
12547 + */
12548 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12549 +{
12550 + unsigned char c;
12551 +
12552 + asm volatile(LOCK_PREFIX "incl %0\n"
12553 + "sete %1\n"
12554 : "+m" (v->counter), "=qm" (c)
12555 : : "memory");
12556 return c != 0;
12557 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12558 {
12559 unsigned char c;
12560
12561 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12562 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12563 +
12564 +#ifdef CONFIG_PAX_REFCOUNT
12565 + "jno 0f\n"
12566 + LOCK_PREFIX "subl %2,%0\n"
12567 + "int $4\n0:\n"
12568 + _ASM_EXTABLE(0b, 0b)
12569 +#endif
12570 +
12571 + "sets %1\n"
12572 : "+m" (v->counter), "=qm" (c)
12573 : "ir" (i) : "memory");
12574 return c;
12575 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12576 */
12577 static inline int atomic_add_return(int i, atomic_t *v)
12578 {
12579 + return i + xadd_check_overflow(&v->counter, i);
12580 +}
12581 +
12582 +/**
12583 + * atomic_add_return_unchecked - add integer and return
12584 + * @i: integer value to add
12585 + * @v: pointer of type atomic_unchecked_t
12586 + *
12587 + * Atomically adds @i to @v and returns @i + @v
12588 + */
12589 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12590 +{
12591 return i + xadd(&v->counter, i);
12592 }
12593
12594 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12595 }
12596
12597 #define atomic_inc_return(v) (atomic_add_return(1, v))
12598 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12599 +{
12600 + return atomic_add_return_unchecked(1, v);
12601 +}
12602 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12603
12604 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12605 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12606 return cmpxchg(&v->counter, old, new);
12607 }
12608
12609 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12610 +{
12611 + return cmpxchg(&v->counter, old, new);
12612 +}
12613 +
12614 static inline int atomic_xchg(atomic_t *v, int new)
12615 {
12616 return xchg(&v->counter, new);
12617 }
12618
12619 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12620 +{
12621 + return xchg(&v->counter, new);
12622 +}
12623 +
12624 /**
12625 * __atomic_add_unless - add unless the number is already a given value
12626 * @v: pointer of type atomic_t
12627 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12628 */
12629 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12630 {
12631 - int c, old;
12632 + int c, old, new;
12633 c = atomic_read(v);
12634 for (;;) {
12635 - if (unlikely(c == (u)))
12636 + if (unlikely(c == u))
12637 break;
12638 - old = atomic_cmpxchg((v), c, c + (a));
12639 +
12640 + asm volatile("addl %2,%0\n"
12641 +
12642 +#ifdef CONFIG_PAX_REFCOUNT
12643 + "jno 0f\n"
12644 + "subl %2,%0\n"
12645 + "int $4\n0:\n"
12646 + _ASM_EXTABLE(0b, 0b)
12647 +#endif
12648 +
12649 + : "=r" (new)
12650 + : "0" (c), "ir" (a));
12651 +
12652 + old = atomic_cmpxchg(v, c, new);
12653 if (likely(old == c))
12654 break;
12655 c = old;
12656 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12657 }
12658
12659 /**
12660 + * atomic_inc_not_zero_hint - increment if not null
12661 + * @v: pointer of type atomic_t
12662 + * @hint: probable value of the atomic before the increment
12663 + *
12664 + * This version of atomic_inc_not_zero() gives a hint of probable
12665 + * value of the atomic. This helps processor to not read the memory
12666 + * before doing the atomic read/modify/write cycle, lowering
12667 + * number of bus transactions on some arches.
12668 + *
12669 + * Returns: 0 if increment was not done, 1 otherwise.
12670 + */
12671 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12672 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12673 +{
12674 + int val, c = hint, new;
12675 +
12676 + /* sanity test, should be removed by compiler if hint is a constant */
12677 + if (!hint)
12678 + return __atomic_add_unless(v, 1, 0);
12679 +
12680 + do {
12681 + asm volatile("incl %0\n"
12682 +
12683 +#ifdef CONFIG_PAX_REFCOUNT
12684 + "jno 0f\n"
12685 + "decl %0\n"
12686 + "int $4\n0:\n"
12687 + _ASM_EXTABLE(0b, 0b)
12688 +#endif
12689 +
12690 + : "=r" (new)
12691 + : "0" (c));
12692 +
12693 + val = atomic_cmpxchg(v, c, new);
12694 + if (val == c)
12695 + return 1;
12696 + c = val;
12697 + } while (c);
12698 +
12699 + return 0;
12700 +}
12701 +
12702 +/**
12703 * atomic_inc_short - increment of a short integer
12704 * @v: pointer to type int
12705 *
12706 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12707 #endif
12708
12709 /* These are x86-specific, used by some header files */
12710 -#define atomic_clear_mask(mask, addr) \
12711 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12712 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12713 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12714 +{
12715 + asm volatile(LOCK_PREFIX "andl %1,%0"
12716 + : "+m" (v->counter)
12717 + : "r" (~(mask))
12718 + : "memory");
12719 +}
12720
12721 -#define atomic_set_mask(mask, addr) \
12722 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12723 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12724 - : "memory")
12725 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12726 +{
12727 + asm volatile(LOCK_PREFIX "andl %1,%0"
12728 + : "+m" (v->counter)
12729 + : "r" (~(mask))
12730 + : "memory");
12731 +}
12732 +
12733 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12734 +{
12735 + asm volatile(LOCK_PREFIX "orl %1,%0"
12736 + : "+m" (v->counter)
12737 + : "r" (mask)
12738 + : "memory");
12739 +}
12740 +
12741 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12742 +{
12743 + asm volatile(LOCK_PREFIX "orl %1,%0"
12744 + : "+m" (v->counter)
12745 + : "r" (mask)
12746 + : "memory");
12747 +}
12748
12749 /* Atomic operations are already serializing on x86 */
12750 #define smp_mb__before_atomic_dec() barrier()
12751 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12752 index b154de7..aadebd8 100644
12753 --- a/arch/x86/include/asm/atomic64_32.h
12754 +++ b/arch/x86/include/asm/atomic64_32.h
12755 @@ -12,6 +12,14 @@ typedef struct {
12756 u64 __aligned(8) counter;
12757 } atomic64_t;
12758
12759 +#ifdef CONFIG_PAX_REFCOUNT
12760 +typedef struct {
12761 + u64 __aligned(8) counter;
12762 +} atomic64_unchecked_t;
12763 +#else
12764 +typedef atomic64_t atomic64_unchecked_t;
12765 +#endif
12766 +
12767 #define ATOMIC64_INIT(val) { (val) }
12768
12769 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12770 @@ -37,21 +45,31 @@ typedef struct {
12771 ATOMIC64_DECL_ONE(sym##_386)
12772
12773 ATOMIC64_DECL_ONE(add_386);
12774 +ATOMIC64_DECL_ONE(add_unchecked_386);
12775 ATOMIC64_DECL_ONE(sub_386);
12776 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12777 ATOMIC64_DECL_ONE(inc_386);
12778 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12779 ATOMIC64_DECL_ONE(dec_386);
12780 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12781 #endif
12782
12783 #define alternative_atomic64(f, out, in...) \
12784 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12785
12786 ATOMIC64_DECL(read);
12787 +ATOMIC64_DECL(read_unchecked);
12788 ATOMIC64_DECL(set);
12789 +ATOMIC64_DECL(set_unchecked);
12790 ATOMIC64_DECL(xchg);
12791 ATOMIC64_DECL(add_return);
12792 +ATOMIC64_DECL(add_return_unchecked);
12793 ATOMIC64_DECL(sub_return);
12794 +ATOMIC64_DECL(sub_return_unchecked);
12795 ATOMIC64_DECL(inc_return);
12796 +ATOMIC64_DECL(inc_return_unchecked);
12797 ATOMIC64_DECL(dec_return);
12798 +ATOMIC64_DECL(dec_return_unchecked);
12799 ATOMIC64_DECL(dec_if_positive);
12800 ATOMIC64_DECL(inc_not_zero);
12801 ATOMIC64_DECL(add_unless);
12802 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12803 }
12804
12805 /**
12806 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12807 + * @p: pointer to type atomic64_unchecked_t
12808 + * @o: expected value
12809 + * @n: new value
12810 + *
12811 + * Atomically sets @v to @n if it was equal to @o and returns
12812 + * the old value.
12813 + */
12814 +
12815 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12816 +{
12817 + return cmpxchg64(&v->counter, o, n);
12818 +}
12819 +
12820 +/**
12821 * atomic64_xchg - xchg atomic64 variable
12822 * @v: pointer to type atomic64_t
12823 * @n: value to assign
12824 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12825 }
12826
12827 /**
12828 + * atomic64_set_unchecked - set atomic64 variable
12829 + * @v: pointer to type atomic64_unchecked_t
12830 + * @n: value to assign
12831 + *
12832 + * Atomically sets the value of @v to @n.
12833 + */
12834 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12835 +{
12836 + unsigned high = (unsigned)(i >> 32);
12837 + unsigned low = (unsigned)i;
12838 + alternative_atomic64(set, /* no output */,
12839 + "S" (v), "b" (low), "c" (high)
12840 + : "eax", "edx", "memory");
12841 +}
12842 +
12843 +/**
12844 * atomic64_read - read atomic64 variable
12845 * @v: pointer to type atomic64_t
12846 *
12847 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12848 }
12849
12850 /**
12851 + * atomic64_read_unchecked - read atomic64 variable
12852 + * @v: pointer to type atomic64_unchecked_t
12853 + *
12854 + * Atomically reads the value of @v and returns it.
12855 + */
12856 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12857 +{
12858 + long long r;
12859 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12860 + return r;
12861 + }
12862 +
12863 +/**
12864 * atomic64_add_return - add and return
12865 * @i: integer value to add
12866 * @v: pointer to type atomic64_t
12867 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12868 return i;
12869 }
12870
12871 +/**
12872 + * atomic64_add_return_unchecked - add and return
12873 + * @i: integer value to add
12874 + * @v: pointer to type atomic64_unchecked_t
12875 + *
12876 + * Atomically adds @i to @v and returns @i + *@v
12877 + */
12878 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12879 +{
12880 + alternative_atomic64(add_return_unchecked,
12881 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12882 + ASM_NO_INPUT_CLOBBER("memory"));
12883 + return i;
12884 +}
12885 +
12886 /*
12887 * Other variants with different arithmetic operators:
12888 */
12889 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12890 return a;
12891 }
12892
12893 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12894 +{
12895 + long long a;
12896 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12897 + "S" (v) : "memory", "ecx");
12898 + return a;
12899 +}
12900 +
12901 static inline long long atomic64_dec_return(atomic64_t *v)
12902 {
12903 long long a;
12904 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12905 }
12906
12907 /**
12908 + * atomic64_add_unchecked - add integer to atomic64 variable
12909 + * @i: integer value to add
12910 + * @v: pointer to type atomic64_unchecked_t
12911 + *
12912 + * Atomically adds @i to @v.
12913 + */
12914 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12915 +{
12916 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12917 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12918 + ASM_NO_INPUT_CLOBBER("memory"));
12919 + return i;
12920 +}
12921 +
12922 +/**
12923 * atomic64_sub - subtract the atomic64 variable
12924 * @i: integer value to subtract
12925 * @v: pointer to type atomic64_t
12926 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12927 index 0e1cbfc..5623683 100644
12928 --- a/arch/x86/include/asm/atomic64_64.h
12929 +++ b/arch/x86/include/asm/atomic64_64.h
12930 @@ -18,7 +18,19 @@
12931 */
12932 static inline long atomic64_read(const atomic64_t *v)
12933 {
12934 - return (*(volatile long *)&(v)->counter);
12935 + return (*(volatile const long *)&(v)->counter);
12936 +}
12937 +
12938 +/**
12939 + * atomic64_read_unchecked - read atomic64 variable
12940 + * @v: pointer of type atomic64_unchecked_t
12941 + *
12942 + * Atomically reads the value of @v.
12943 + * Doesn't imply a read memory barrier.
12944 + */
12945 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12946 +{
12947 + return (*(volatile const long *)&(v)->counter);
12948 }
12949
12950 /**
12951 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12952 }
12953
12954 /**
12955 + * atomic64_set_unchecked - set atomic64 variable
12956 + * @v: pointer to type atomic64_unchecked_t
12957 + * @i: required value
12958 + *
12959 + * Atomically sets the value of @v to @i.
12960 + */
12961 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12962 +{
12963 + v->counter = i;
12964 +}
12965 +
12966 +/**
12967 * atomic64_add - add integer to atomic64 variable
12968 * @i: integer value to add
12969 * @v: pointer to type atomic64_t
12970 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12971 */
12972 static inline void atomic64_add(long i, atomic64_t *v)
12973 {
12974 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12975 +
12976 +#ifdef CONFIG_PAX_REFCOUNT
12977 + "jno 0f\n"
12978 + LOCK_PREFIX "subq %1,%0\n"
12979 + "int $4\n0:\n"
12980 + _ASM_EXTABLE(0b, 0b)
12981 +#endif
12982 +
12983 + : "=m" (v->counter)
12984 + : "er" (i), "m" (v->counter));
12985 +}
12986 +
12987 +/**
12988 + * atomic64_add_unchecked - add integer to atomic64 variable
12989 + * @i: integer value to add
12990 + * @v: pointer to type atomic64_unchecked_t
12991 + *
12992 + * Atomically adds @i to @v.
12993 + */
12994 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12995 +{
12996 asm volatile(LOCK_PREFIX "addq %1,%0"
12997 : "=m" (v->counter)
12998 : "er" (i), "m" (v->counter));
12999 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13000 */
13001 static inline void atomic64_sub(long i, atomic64_t *v)
13002 {
13003 - asm volatile(LOCK_PREFIX "subq %1,%0"
13004 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13005 +
13006 +#ifdef CONFIG_PAX_REFCOUNT
13007 + "jno 0f\n"
13008 + LOCK_PREFIX "addq %1,%0\n"
13009 + "int $4\n0:\n"
13010 + _ASM_EXTABLE(0b, 0b)
13011 +#endif
13012 +
13013 + : "=m" (v->counter)
13014 + : "er" (i), "m" (v->counter));
13015 +}
13016 +
13017 +/**
13018 + * atomic64_sub_unchecked - subtract the atomic64 variable
13019 + * @i: integer value to subtract
13020 + * @v: pointer to type atomic64_unchecked_t
13021 + *
13022 + * Atomically subtracts @i from @v.
13023 + */
13024 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13025 +{
13026 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13027 : "=m" (v->counter)
13028 : "er" (i), "m" (v->counter));
13029 }
13030 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13031 {
13032 unsigned char c;
13033
13034 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13035 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13036 +
13037 +#ifdef CONFIG_PAX_REFCOUNT
13038 + "jno 0f\n"
13039 + LOCK_PREFIX "addq %2,%0\n"
13040 + "int $4\n0:\n"
13041 + _ASM_EXTABLE(0b, 0b)
13042 +#endif
13043 +
13044 + "sete %1\n"
13045 : "=m" (v->counter), "=qm" (c)
13046 : "er" (i), "m" (v->counter) : "memory");
13047 return c;
13048 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13049 */
13050 static inline void atomic64_inc(atomic64_t *v)
13051 {
13052 + asm volatile(LOCK_PREFIX "incq %0\n"
13053 +
13054 +#ifdef CONFIG_PAX_REFCOUNT
13055 + "jno 0f\n"
13056 + LOCK_PREFIX "decq %0\n"
13057 + "int $4\n0:\n"
13058 + _ASM_EXTABLE(0b, 0b)
13059 +#endif
13060 +
13061 + : "=m" (v->counter)
13062 + : "m" (v->counter));
13063 +}
13064 +
13065 +/**
13066 + * atomic64_inc_unchecked - increment atomic64 variable
13067 + * @v: pointer to type atomic64_unchecked_t
13068 + *
13069 + * Atomically increments @v by 1.
13070 + */
13071 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13072 +{
13073 asm volatile(LOCK_PREFIX "incq %0"
13074 : "=m" (v->counter)
13075 : "m" (v->counter));
13076 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13077 */
13078 static inline void atomic64_dec(atomic64_t *v)
13079 {
13080 - asm volatile(LOCK_PREFIX "decq %0"
13081 + asm volatile(LOCK_PREFIX "decq %0\n"
13082 +
13083 +#ifdef CONFIG_PAX_REFCOUNT
13084 + "jno 0f\n"
13085 + LOCK_PREFIX "incq %0\n"
13086 + "int $4\n0:\n"
13087 + _ASM_EXTABLE(0b, 0b)
13088 +#endif
13089 +
13090 + : "=m" (v->counter)
13091 + : "m" (v->counter));
13092 +}
13093 +
13094 +/**
13095 + * atomic64_dec_unchecked - decrement atomic64 variable
13096 + * @v: pointer to type atomic64_t
13097 + *
13098 + * Atomically decrements @v by 1.
13099 + */
13100 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13101 +{
13102 + asm volatile(LOCK_PREFIX "decq %0\n"
13103 : "=m" (v->counter)
13104 : "m" (v->counter));
13105 }
13106 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13107 {
13108 unsigned char c;
13109
13110 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13111 + asm volatile(LOCK_PREFIX "decq %0\n"
13112 +
13113 +#ifdef CONFIG_PAX_REFCOUNT
13114 + "jno 0f\n"
13115 + LOCK_PREFIX "incq %0\n"
13116 + "int $4\n0:\n"
13117 + _ASM_EXTABLE(0b, 0b)
13118 +#endif
13119 +
13120 + "sete %1\n"
13121 : "=m" (v->counter), "=qm" (c)
13122 : "m" (v->counter) : "memory");
13123 return c != 0;
13124 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13125 {
13126 unsigned char c;
13127
13128 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13129 + asm volatile(LOCK_PREFIX "incq %0\n"
13130 +
13131 +#ifdef CONFIG_PAX_REFCOUNT
13132 + "jno 0f\n"
13133 + LOCK_PREFIX "decq %0\n"
13134 + "int $4\n0:\n"
13135 + _ASM_EXTABLE(0b, 0b)
13136 +#endif
13137 +
13138 + "sete %1\n"
13139 : "=m" (v->counter), "=qm" (c)
13140 : "m" (v->counter) : "memory");
13141 return c != 0;
13142 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13143 {
13144 unsigned char c;
13145
13146 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13147 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13148 +
13149 +#ifdef CONFIG_PAX_REFCOUNT
13150 + "jno 0f\n"
13151 + LOCK_PREFIX "subq %2,%0\n"
13152 + "int $4\n0:\n"
13153 + _ASM_EXTABLE(0b, 0b)
13154 +#endif
13155 +
13156 + "sets %1\n"
13157 : "=m" (v->counter), "=qm" (c)
13158 : "er" (i), "m" (v->counter) : "memory");
13159 return c;
13160 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13161 */
13162 static inline long atomic64_add_return(long i, atomic64_t *v)
13163 {
13164 + return i + xadd_check_overflow(&v->counter, i);
13165 +}
13166 +
13167 +/**
13168 + * atomic64_add_return_unchecked - add and return
13169 + * @i: integer value to add
13170 + * @v: pointer to type atomic64_unchecked_t
13171 + *
13172 + * Atomically adds @i to @v and returns @i + @v
13173 + */
13174 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13175 +{
13176 return i + xadd(&v->counter, i);
13177 }
13178
13179 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13180 }
13181
13182 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13183 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13184 +{
13185 + return atomic64_add_return_unchecked(1, v);
13186 +}
13187 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13188
13189 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13190 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13191 return cmpxchg(&v->counter, old, new);
13192 }
13193
13194 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13195 +{
13196 + return cmpxchg(&v->counter, old, new);
13197 +}
13198 +
13199 static inline long atomic64_xchg(atomic64_t *v, long new)
13200 {
13201 return xchg(&v->counter, new);
13202 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13203 */
13204 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13205 {
13206 - long c, old;
13207 + long c, old, new;
13208 c = atomic64_read(v);
13209 for (;;) {
13210 - if (unlikely(c == (u)))
13211 + if (unlikely(c == u))
13212 break;
13213 - old = atomic64_cmpxchg((v), c, c + (a));
13214 +
13215 + asm volatile("add %2,%0\n"
13216 +
13217 +#ifdef CONFIG_PAX_REFCOUNT
13218 + "jno 0f\n"
13219 + "sub %2,%0\n"
13220 + "int $4\n0:\n"
13221 + _ASM_EXTABLE(0b, 0b)
13222 +#endif
13223 +
13224 + : "=r" (new)
13225 + : "0" (c), "ir" (a));
13226 +
13227 + old = atomic64_cmpxchg(v, c, new);
13228 if (likely(old == c))
13229 break;
13230 c = old;
13231 }
13232 - return c != (u);
13233 + return c != u;
13234 }
13235
13236 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13237 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13238 index 6dfd019..28e188d 100644
13239 --- a/arch/x86/include/asm/bitops.h
13240 +++ b/arch/x86/include/asm/bitops.h
13241 @@ -40,7 +40,7 @@
13242 * a mask operation on a byte.
13243 */
13244 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13245 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13246 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13247 #define CONST_MASK(nr) (1 << ((nr) & 7))
13248
13249 /**
13250 @@ -486,7 +486,7 @@ static inline int fls(int x)
13251 * at position 64.
13252 */
13253 #ifdef CONFIG_X86_64
13254 -static __always_inline int fls64(__u64 x)
13255 +static __always_inline long fls64(__u64 x)
13256 {
13257 int bitpos = -1;
13258 /*
13259 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13260 index 4fa687a..60f2d39 100644
13261 --- a/arch/x86/include/asm/boot.h
13262 +++ b/arch/x86/include/asm/boot.h
13263 @@ -6,10 +6,15 @@
13264 #include <uapi/asm/boot.h>
13265
13266 /* Physical address where kernel should be loaded. */
13267 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13268 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13269 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13270 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13271
13272 +#ifndef __ASSEMBLY__
13273 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13274 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13275 +#endif
13276 +
13277 /* Minimum kernel alignment, as a power of two */
13278 #ifdef CONFIG_X86_64
13279 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13280 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13281 index 48f99f1..d78ebf9 100644
13282 --- a/arch/x86/include/asm/cache.h
13283 +++ b/arch/x86/include/asm/cache.h
13284 @@ -5,12 +5,13 @@
13285
13286 /* L1 cache line size */
13287 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13288 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13289 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13290
13291 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13292 +#define __read_only __attribute__((__section__(".data..read_only")))
13293
13294 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13295 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13296 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13297
13298 #ifdef CONFIG_X86_VSMP
13299 #ifdef CONFIG_SMP
13300 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13301 index 9863ee3..4a1f8e1 100644
13302 --- a/arch/x86/include/asm/cacheflush.h
13303 +++ b/arch/x86/include/asm/cacheflush.h
13304 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13305 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13306
13307 if (pg_flags == _PGMT_DEFAULT)
13308 - return -1;
13309 + return ~0UL;
13310 else if (pg_flags == _PGMT_WC)
13311 return _PAGE_CACHE_WC;
13312 else if (pg_flags == _PGMT_UC_MINUS)
13313 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13314 index 46fc474..b02b0f9 100644
13315 --- a/arch/x86/include/asm/checksum_32.h
13316 +++ b/arch/x86/include/asm/checksum_32.h
13317 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13318 int len, __wsum sum,
13319 int *src_err_ptr, int *dst_err_ptr);
13320
13321 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13322 + int len, __wsum sum,
13323 + int *src_err_ptr, int *dst_err_ptr);
13324 +
13325 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13326 + int len, __wsum sum,
13327 + int *src_err_ptr, int *dst_err_ptr);
13328 +
13329 /*
13330 * Note: when you get a NULL pointer exception here this means someone
13331 * passed in an incorrect kernel address to one of these functions.
13332 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13333 int *err_ptr)
13334 {
13335 might_sleep();
13336 - return csum_partial_copy_generic((__force void *)src, dst,
13337 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13338 len, sum, err_ptr, NULL);
13339 }
13340
13341 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13342 {
13343 might_sleep();
13344 if (access_ok(VERIFY_WRITE, dst, len))
13345 - return csum_partial_copy_generic(src, (__force void *)dst,
13346 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13347 len, sum, NULL, err_ptr);
13348
13349 if (len)
13350 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13351 index 8d871ea..c1a0dc9 100644
13352 --- a/arch/x86/include/asm/cmpxchg.h
13353 +++ b/arch/x86/include/asm/cmpxchg.h
13354 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13355 __compiletime_error("Bad argument size for cmpxchg");
13356 extern void __xadd_wrong_size(void)
13357 __compiletime_error("Bad argument size for xadd");
13358 +extern void __xadd_check_overflow_wrong_size(void)
13359 + __compiletime_error("Bad argument size for xadd_check_overflow");
13360 extern void __add_wrong_size(void)
13361 __compiletime_error("Bad argument size for add");
13362 +extern void __add_check_overflow_wrong_size(void)
13363 + __compiletime_error("Bad argument size for add_check_overflow");
13364
13365 /*
13366 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13367 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13368 __ret; \
13369 })
13370
13371 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13372 + ({ \
13373 + __typeof__ (*(ptr)) __ret = (arg); \
13374 + switch (sizeof(*(ptr))) { \
13375 + case __X86_CASE_L: \
13376 + asm volatile (lock #op "l %0, %1\n" \
13377 + "jno 0f\n" \
13378 + "mov %0,%1\n" \
13379 + "int $4\n0:\n" \
13380 + _ASM_EXTABLE(0b, 0b) \
13381 + : "+r" (__ret), "+m" (*(ptr)) \
13382 + : : "memory", "cc"); \
13383 + break; \
13384 + case __X86_CASE_Q: \
13385 + asm volatile (lock #op "q %q0, %1\n" \
13386 + "jno 0f\n" \
13387 + "mov %0,%1\n" \
13388 + "int $4\n0:\n" \
13389 + _ASM_EXTABLE(0b, 0b) \
13390 + : "+r" (__ret), "+m" (*(ptr)) \
13391 + : : "memory", "cc"); \
13392 + break; \
13393 + default: \
13394 + __ ## op ## _check_overflow_wrong_size(); \
13395 + } \
13396 + __ret; \
13397 + })
13398 +
13399 /*
13400 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13401 * Since this is generally used to protect other memory information, we
13402 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13403 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13404 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13405
13406 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13407 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13408 +
13409 #define __add(ptr, inc, lock) \
13410 ({ \
13411 __typeof__ (*(ptr)) __ret = (inc); \
13412 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13413 index 59c6c40..5e0b22c 100644
13414 --- a/arch/x86/include/asm/compat.h
13415 +++ b/arch/x86/include/asm/compat.h
13416 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13417 typedef u32 compat_uint_t;
13418 typedef u32 compat_ulong_t;
13419 typedef u64 __attribute__((aligned(4))) compat_u64;
13420 -typedef u32 compat_uptr_t;
13421 +typedef u32 __user compat_uptr_t;
13422
13423 struct compat_timespec {
13424 compat_time_t tv_sec;
13425 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13426 index 2d9075e..b75a844 100644
13427 --- a/arch/x86/include/asm/cpufeature.h
13428 +++ b/arch/x86/include/asm/cpufeature.h
13429 @@ -206,7 +206,7 @@
13430 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13431 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13432 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13433 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13434 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13435 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13436 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13437 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13438 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13439 ".section .discard,\"aw\",@progbits\n"
13440 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13441 ".previous\n"
13442 - ".section .altinstr_replacement,\"ax\"\n"
13443 + ".section .altinstr_replacement,\"a\"\n"
13444 "3: movb $1,%0\n"
13445 "4:\n"
13446 ".previous\n"
13447 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13448 index 8bf1c06..b6ae785 100644
13449 --- a/arch/x86/include/asm/desc.h
13450 +++ b/arch/x86/include/asm/desc.h
13451 @@ -4,6 +4,7 @@
13452 #include <asm/desc_defs.h>
13453 #include <asm/ldt.h>
13454 #include <asm/mmu.h>
13455 +#include <asm/pgtable.h>
13456
13457 #include <linux/smp.h>
13458 #include <linux/percpu.h>
13459 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13460
13461 desc->type = (info->read_exec_only ^ 1) << 1;
13462 desc->type |= info->contents << 2;
13463 + desc->type |= info->seg_not_present ^ 1;
13464
13465 desc->s = 1;
13466 desc->dpl = 0x3;
13467 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13468 }
13469
13470 extern struct desc_ptr idt_descr;
13471 -extern gate_desc idt_table[];
13472 extern struct desc_ptr nmi_idt_descr;
13473 -extern gate_desc nmi_idt_table[];
13474 -
13475 -struct gdt_page {
13476 - struct desc_struct gdt[GDT_ENTRIES];
13477 -} __attribute__((aligned(PAGE_SIZE)));
13478 -
13479 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13480 +extern gate_desc idt_table[256];
13481 +extern gate_desc nmi_idt_table[256];
13482
13483 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13484 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13485 {
13486 - return per_cpu(gdt_page, cpu).gdt;
13487 + return cpu_gdt_table[cpu];
13488 }
13489
13490 #ifdef CONFIG_X86_64
13491 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13492 unsigned long base, unsigned dpl, unsigned flags,
13493 unsigned short seg)
13494 {
13495 - gate->a = (seg << 16) | (base & 0xffff);
13496 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13497 + gate->gate.offset_low = base;
13498 + gate->gate.seg = seg;
13499 + gate->gate.reserved = 0;
13500 + gate->gate.type = type;
13501 + gate->gate.s = 0;
13502 + gate->gate.dpl = dpl;
13503 + gate->gate.p = 1;
13504 + gate->gate.offset_high = base >> 16;
13505 }
13506
13507 #endif
13508 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13509
13510 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13511 {
13512 + pax_open_kernel();
13513 memcpy(&idt[entry], gate, sizeof(*gate));
13514 + pax_close_kernel();
13515 }
13516
13517 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13518 {
13519 + pax_open_kernel();
13520 memcpy(&ldt[entry], desc, 8);
13521 + pax_close_kernel();
13522 }
13523
13524 static inline void
13525 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13526 default: size = sizeof(*gdt); break;
13527 }
13528
13529 + pax_open_kernel();
13530 memcpy(&gdt[entry], desc, size);
13531 + pax_close_kernel();
13532 }
13533
13534 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13535 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13536
13537 static inline void native_load_tr_desc(void)
13538 {
13539 + pax_open_kernel();
13540 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13541 + pax_close_kernel();
13542 }
13543
13544 static inline void native_load_gdt(const struct desc_ptr *dtr)
13545 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13546 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13547 unsigned int i;
13548
13549 + pax_open_kernel();
13550 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13551 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13552 + pax_close_kernel();
13553 }
13554
13555 #define _LDT_empty(info) \
13556 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13557 preempt_enable();
13558 }
13559
13560 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13561 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13562 {
13563 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13564 }
13565 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13566 }
13567
13568 #ifdef CONFIG_X86_64
13569 -static inline void set_nmi_gate(int gate, void *addr)
13570 +static inline void set_nmi_gate(int gate, const void *addr)
13571 {
13572 gate_desc s;
13573
13574 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13575 }
13576 #endif
13577
13578 -static inline void _set_gate(int gate, unsigned type, void *addr,
13579 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13580 unsigned dpl, unsigned ist, unsigned seg)
13581 {
13582 gate_desc s;
13583 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13584 * Pentium F0 0F bugfix can have resulted in the mapped
13585 * IDT being write-protected.
13586 */
13587 -static inline void set_intr_gate(unsigned int n, void *addr)
13588 +static inline void set_intr_gate(unsigned int n, const void *addr)
13589 {
13590 BUG_ON((unsigned)n > 0xFF);
13591 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13592 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13593 /*
13594 * This routine sets up an interrupt gate at directory privilege level 3.
13595 */
13596 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13597 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13598 {
13599 BUG_ON((unsigned)n > 0xFF);
13600 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13601 }
13602
13603 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13604 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13605 {
13606 BUG_ON((unsigned)n > 0xFF);
13607 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13608 }
13609
13610 -static inline void set_trap_gate(unsigned int n, void *addr)
13611 +static inline void set_trap_gate(unsigned int n, const void *addr)
13612 {
13613 BUG_ON((unsigned)n > 0xFF);
13614 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13615 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13616 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13617 {
13618 BUG_ON((unsigned)n > 0xFF);
13619 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13620 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13621 }
13622
13623 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13624 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13625 {
13626 BUG_ON((unsigned)n > 0xFF);
13627 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13628 }
13629
13630 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13631 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13632 {
13633 BUG_ON((unsigned)n > 0xFF);
13634 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13635 }
13636
13637 +#ifdef CONFIG_X86_32
13638 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13639 +{
13640 + struct desc_struct d;
13641 +
13642 + if (likely(limit))
13643 + limit = (limit - 1UL) >> PAGE_SHIFT;
13644 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13645 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13646 +}
13647 +#endif
13648 +
13649 #endif /* _ASM_X86_DESC_H */
13650 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13651 index 278441f..b95a174 100644
13652 --- a/arch/x86/include/asm/desc_defs.h
13653 +++ b/arch/x86/include/asm/desc_defs.h
13654 @@ -31,6 +31,12 @@ struct desc_struct {
13655 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13656 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13657 };
13658 + struct {
13659 + u16 offset_low;
13660 + u16 seg;
13661 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13662 + unsigned offset_high: 16;
13663 + } gate;
13664 };
13665 } __attribute__((packed));
13666
13667 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13668 index ced283a..ffe04cc 100644
13669 --- a/arch/x86/include/asm/div64.h
13670 +++ b/arch/x86/include/asm/div64.h
13671 @@ -39,7 +39,7 @@
13672 __mod; \
13673 })
13674
13675 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13676 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13677 {
13678 union {
13679 u64 v64;
13680 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13681 index 9c999c1..3860cb8 100644
13682 --- a/arch/x86/include/asm/elf.h
13683 +++ b/arch/x86/include/asm/elf.h
13684 @@ -243,7 +243,25 @@ extern int force_personality32;
13685 the loader. We need to make sure that it is out of the way of the program
13686 that it will "exec", and that there is sufficient room for the brk. */
13687
13688 +#ifdef CONFIG_PAX_SEGMEXEC
13689 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13690 +#else
13691 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13692 +#endif
13693 +
13694 +#ifdef CONFIG_PAX_ASLR
13695 +#ifdef CONFIG_X86_32
13696 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13697 +
13698 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13699 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13700 +#else
13701 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13702 +
13703 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13704 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13705 +#endif
13706 +#endif
13707
13708 /* This yields a mask that user programs can use to figure out what
13709 instruction set this CPU supports. This could be done in user space,
13710 @@ -296,16 +314,12 @@ do { \
13711
13712 #define ARCH_DLINFO \
13713 do { \
13714 - if (vdso_enabled) \
13715 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13716 - (unsigned long)current->mm->context.vdso); \
13717 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13718 } while (0)
13719
13720 #define ARCH_DLINFO_X32 \
13721 do { \
13722 - if (vdso_enabled) \
13723 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13724 - (unsigned long)current->mm->context.vdso); \
13725 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13726 } while (0)
13727
13728 #define AT_SYSINFO 32
13729 @@ -320,7 +334,7 @@ else \
13730
13731 #endif /* !CONFIG_X86_32 */
13732
13733 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13734 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13735
13736 #define VDSO_ENTRY \
13737 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13738 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13739 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13740 #define compat_arch_setup_additional_pages syscall32_setup_pages
13741
13742 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13743 -#define arch_randomize_brk arch_randomize_brk
13744 -
13745 /*
13746 * True on X86_32 or when emulating IA32 on X86_64
13747 */
13748 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13749 index 75ce3f4..882e801 100644
13750 --- a/arch/x86/include/asm/emergency-restart.h
13751 +++ b/arch/x86/include/asm/emergency-restart.h
13752 @@ -13,6 +13,6 @@ enum reboot_type {
13753
13754 extern enum reboot_type reboot_type;
13755
13756 -extern void machine_emergency_restart(void);
13757 +extern void machine_emergency_restart(void) __noreturn;
13758
13759 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13760 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13761 index 41ab26e..a88c9e6 100644
13762 --- a/arch/x86/include/asm/fpu-internal.h
13763 +++ b/arch/x86/include/asm/fpu-internal.h
13764 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13765 ({ \
13766 int err; \
13767 asm volatile(ASM_STAC "\n" \
13768 - "1:" #insn "\n\t" \
13769 + "1:" \
13770 + __copyuser_seg \
13771 + #insn "\n\t" \
13772 "2: " ASM_CLAC "\n" \
13773 ".section .fixup,\"ax\"\n" \
13774 "3: movl $-1,%[err]\n" \
13775 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13776 "emms\n\t" /* clear stack tags */
13777 "fildl %P[addr]", /* set F?P to defined value */
13778 X86_FEATURE_FXSAVE_LEAK,
13779 - [addr] "m" (tsk->thread.fpu.has_fpu));
13780 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13781
13782 return fpu_restore_checking(&tsk->thread.fpu);
13783 }
13784 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13785 index be27ba1..8f13ff9 100644
13786 --- a/arch/x86/include/asm/futex.h
13787 +++ b/arch/x86/include/asm/futex.h
13788 @@ -12,6 +12,7 @@
13789 #include <asm/smap.h>
13790
13791 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13792 + typecheck(u32 __user *, uaddr); \
13793 asm volatile("\t" ASM_STAC "\n" \
13794 "1:\t" insn "\n" \
13795 "2:\t" ASM_CLAC "\n" \
13796 @@ -20,15 +21,16 @@
13797 "\tjmp\t2b\n" \
13798 "\t.previous\n" \
13799 _ASM_EXTABLE(1b, 3b) \
13800 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13801 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13802 : "i" (-EFAULT), "0" (oparg), "1" (0))
13803
13804 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13805 + typecheck(u32 __user *, uaddr); \
13806 asm volatile("\t" ASM_STAC "\n" \
13807 "1:\tmovl %2, %0\n" \
13808 "\tmovl\t%0, %3\n" \
13809 "\t" insn "\n" \
13810 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13811 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13812 "\tjnz\t1b\n" \
13813 "3:\t" ASM_CLAC "\n" \
13814 "\t.section .fixup,\"ax\"\n" \
13815 @@ -38,7 +40,7 @@
13816 _ASM_EXTABLE(1b, 4b) \
13817 _ASM_EXTABLE(2b, 4b) \
13818 : "=&a" (oldval), "=&r" (ret), \
13819 - "+m" (*uaddr), "=&r" (tem) \
13820 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13821 : "r" (oparg), "i" (-EFAULT), "1" (0))
13822
13823 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13824 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13825
13826 switch (op) {
13827 case FUTEX_OP_SET:
13828 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13829 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13830 break;
13831 case FUTEX_OP_ADD:
13832 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13833 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13834 uaddr, oparg);
13835 break;
13836 case FUTEX_OP_OR:
13837 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13838 return -EFAULT;
13839
13840 asm volatile("\t" ASM_STAC "\n"
13841 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13842 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13843 "2:\t" ASM_CLAC "\n"
13844 "\t.section .fixup, \"ax\"\n"
13845 "3:\tmov %3, %0\n"
13846 "\tjmp 2b\n"
13847 "\t.previous\n"
13848 _ASM_EXTABLE(1b, 3b)
13849 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13850 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13851 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13852 : "memory"
13853 );
13854 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13855 index eb92a6e..b98b2f4 100644
13856 --- a/arch/x86/include/asm/hw_irq.h
13857 +++ b/arch/x86/include/asm/hw_irq.h
13858 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13859 extern void enable_IO_APIC(void);
13860
13861 /* Statistics */
13862 -extern atomic_t irq_err_count;
13863 -extern atomic_t irq_mis_count;
13864 +extern atomic_unchecked_t irq_err_count;
13865 +extern atomic_unchecked_t irq_mis_count;
13866
13867 /* EISA */
13868 extern void eisa_set_level_irq(unsigned int irq);
13869 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13870 index a203659..9889f1c 100644
13871 --- a/arch/x86/include/asm/i8259.h
13872 +++ b/arch/x86/include/asm/i8259.h
13873 @@ -62,7 +62,7 @@ struct legacy_pic {
13874 void (*init)(int auto_eoi);
13875 int (*irq_pending)(unsigned int irq);
13876 void (*make_irq)(unsigned int irq);
13877 -};
13878 +} __do_const;
13879
13880 extern struct legacy_pic *legacy_pic;
13881 extern struct legacy_pic null_legacy_pic;
13882 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13883 index d8e8eef..1765f78 100644
13884 --- a/arch/x86/include/asm/io.h
13885 +++ b/arch/x86/include/asm/io.h
13886 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13887 "m" (*(volatile type __force *)addr) barrier); }
13888
13889 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13890 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13891 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13892 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13893 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13894
13895 build_mmio_read(__readb, "b", unsigned char, "=q", )
13896 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13897 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13898 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13899 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13900
13901 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13902 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13903 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13904 return ioremap_nocache(offset, size);
13905 }
13906
13907 -extern void iounmap(volatile void __iomem *addr);
13908 +extern void iounmap(const volatile void __iomem *addr);
13909
13910 extern void set_iounmap_nonlazy(void);
13911
13912 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13913
13914 #include <linux/vmalloc.h>
13915
13916 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13917 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13918 +{
13919 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13920 +}
13921 +
13922 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13923 +{
13924 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13925 +}
13926 +
13927 /*
13928 * Convert a virtual cached pointer to an uncached pointer
13929 */
13930 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13931 index bba3cf8..06bc8da 100644
13932 --- a/arch/x86/include/asm/irqflags.h
13933 +++ b/arch/x86/include/asm/irqflags.h
13934 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13935 sti; \
13936 sysexit
13937
13938 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13939 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13940 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13941 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13942 +
13943 #else
13944 #define INTERRUPT_RETURN iret
13945 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13946 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13947 index d3ddd17..c9fb0cc 100644
13948 --- a/arch/x86/include/asm/kprobes.h
13949 +++ b/arch/x86/include/asm/kprobes.h
13950 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13951 #define RELATIVEJUMP_SIZE 5
13952 #define RELATIVECALL_OPCODE 0xe8
13953 #define RELATIVE_ADDR_SIZE 4
13954 -#define MAX_STACK_SIZE 64
13955 -#define MIN_STACK_SIZE(ADDR) \
13956 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13957 - THREAD_SIZE - (unsigned long)(ADDR))) \
13958 - ? (MAX_STACK_SIZE) \
13959 - : (((unsigned long)current_thread_info()) + \
13960 - THREAD_SIZE - (unsigned long)(ADDR)))
13961 +#define MAX_STACK_SIZE 64UL
13962 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13963
13964 #define flush_insn_slot(p) do { } while (0)
13965
13966 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13967 index 2d89e39..baee879 100644
13968 --- a/arch/x86/include/asm/local.h
13969 +++ b/arch/x86/include/asm/local.h
13970 @@ -10,33 +10,97 @@ typedef struct {
13971 atomic_long_t a;
13972 } local_t;
13973
13974 +typedef struct {
13975 + atomic_long_unchecked_t a;
13976 +} local_unchecked_t;
13977 +
13978 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13979
13980 #define local_read(l) atomic_long_read(&(l)->a)
13981 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13982 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13983 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13984
13985 static inline void local_inc(local_t *l)
13986 {
13987 - asm volatile(_ASM_INC "%0"
13988 + asm volatile(_ASM_INC "%0\n"
13989 +
13990 +#ifdef CONFIG_PAX_REFCOUNT
13991 + "jno 0f\n"
13992 + _ASM_DEC "%0\n"
13993 + "int $4\n0:\n"
13994 + _ASM_EXTABLE(0b, 0b)
13995 +#endif
13996 +
13997 + : "+m" (l->a.counter));
13998 +}
13999 +
14000 +static inline void local_inc_unchecked(local_unchecked_t *l)
14001 +{
14002 + asm volatile(_ASM_INC "%0\n"
14003 : "+m" (l->a.counter));
14004 }
14005
14006 static inline void local_dec(local_t *l)
14007 {
14008 - asm volatile(_ASM_DEC "%0"
14009 + asm volatile(_ASM_DEC "%0\n"
14010 +
14011 +#ifdef CONFIG_PAX_REFCOUNT
14012 + "jno 0f\n"
14013 + _ASM_INC "%0\n"
14014 + "int $4\n0:\n"
14015 + _ASM_EXTABLE(0b, 0b)
14016 +#endif
14017 +
14018 + : "+m" (l->a.counter));
14019 +}
14020 +
14021 +static inline void local_dec_unchecked(local_unchecked_t *l)
14022 +{
14023 + asm volatile(_ASM_DEC "%0\n"
14024 : "+m" (l->a.counter));
14025 }
14026
14027 static inline void local_add(long i, local_t *l)
14028 {
14029 - asm volatile(_ASM_ADD "%1,%0"
14030 + asm volatile(_ASM_ADD "%1,%0\n"
14031 +
14032 +#ifdef CONFIG_PAX_REFCOUNT
14033 + "jno 0f\n"
14034 + _ASM_SUB "%1,%0\n"
14035 + "int $4\n0:\n"
14036 + _ASM_EXTABLE(0b, 0b)
14037 +#endif
14038 +
14039 + : "+m" (l->a.counter)
14040 + : "ir" (i));
14041 +}
14042 +
14043 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14044 +{
14045 + asm volatile(_ASM_ADD "%1,%0\n"
14046 : "+m" (l->a.counter)
14047 : "ir" (i));
14048 }
14049
14050 static inline void local_sub(long i, local_t *l)
14051 {
14052 - asm volatile(_ASM_SUB "%1,%0"
14053 + asm volatile(_ASM_SUB "%1,%0\n"
14054 +
14055 +#ifdef CONFIG_PAX_REFCOUNT
14056 + "jno 0f\n"
14057 + _ASM_ADD "%1,%0\n"
14058 + "int $4\n0:\n"
14059 + _ASM_EXTABLE(0b, 0b)
14060 +#endif
14061 +
14062 + : "+m" (l->a.counter)
14063 + : "ir" (i));
14064 +}
14065 +
14066 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14067 +{
14068 + asm volatile(_ASM_SUB "%1,%0\n"
14069 : "+m" (l->a.counter)
14070 : "ir" (i));
14071 }
14072 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14073 {
14074 unsigned char c;
14075
14076 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14077 + asm volatile(_ASM_SUB "%2,%0\n"
14078 +
14079 +#ifdef CONFIG_PAX_REFCOUNT
14080 + "jno 0f\n"
14081 + _ASM_ADD "%2,%0\n"
14082 + "int $4\n0:\n"
14083 + _ASM_EXTABLE(0b, 0b)
14084 +#endif
14085 +
14086 + "sete %1\n"
14087 : "+m" (l->a.counter), "=qm" (c)
14088 : "ir" (i) : "memory");
14089 return c;
14090 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14091 {
14092 unsigned char c;
14093
14094 - asm volatile(_ASM_DEC "%0; sete %1"
14095 + asm volatile(_ASM_DEC "%0\n"
14096 +
14097 +#ifdef CONFIG_PAX_REFCOUNT
14098 + "jno 0f\n"
14099 + _ASM_INC "%0\n"
14100 + "int $4\n0:\n"
14101 + _ASM_EXTABLE(0b, 0b)
14102 +#endif
14103 +
14104 + "sete %1\n"
14105 : "+m" (l->a.counter), "=qm" (c)
14106 : : "memory");
14107 return c != 0;
14108 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14109 {
14110 unsigned char c;
14111
14112 - asm volatile(_ASM_INC "%0; sete %1"
14113 + asm volatile(_ASM_INC "%0\n"
14114 +
14115 +#ifdef CONFIG_PAX_REFCOUNT
14116 + "jno 0f\n"
14117 + _ASM_DEC "%0\n"
14118 + "int $4\n0:\n"
14119 + _ASM_EXTABLE(0b, 0b)
14120 +#endif
14121 +
14122 + "sete %1\n"
14123 : "+m" (l->a.counter), "=qm" (c)
14124 : : "memory");
14125 return c != 0;
14126 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14127 {
14128 unsigned char c;
14129
14130 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14131 + asm volatile(_ASM_ADD "%2,%0\n"
14132 +
14133 +#ifdef CONFIG_PAX_REFCOUNT
14134 + "jno 0f\n"
14135 + _ASM_SUB "%2,%0\n"
14136 + "int $4\n0:\n"
14137 + _ASM_EXTABLE(0b, 0b)
14138 +#endif
14139 +
14140 + "sets %1\n"
14141 : "+m" (l->a.counter), "=qm" (c)
14142 : "ir" (i) : "memory");
14143 return c;
14144 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14145 static inline long local_add_return(long i, local_t *l)
14146 {
14147 long __i = i;
14148 + asm volatile(_ASM_XADD "%0, %1\n"
14149 +
14150 +#ifdef CONFIG_PAX_REFCOUNT
14151 + "jno 0f\n"
14152 + _ASM_MOV "%0,%1\n"
14153 + "int $4\n0:\n"
14154 + _ASM_EXTABLE(0b, 0b)
14155 +#endif
14156 +
14157 + : "+r" (i), "+m" (l->a.counter)
14158 + : : "memory");
14159 + return i + __i;
14160 +}
14161 +
14162 +/**
14163 + * local_add_return_unchecked - add and return
14164 + * @i: integer value to add
14165 + * @l: pointer to type local_unchecked_t
14166 + *
14167 + * Atomically adds @i to @l and returns @i + @l
14168 + */
14169 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14170 +{
14171 + long __i = i;
14172 asm volatile(_ASM_XADD "%0, %1;"
14173 : "+r" (i), "+m" (l->a.counter)
14174 : : "memory");
14175 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14176
14177 #define local_cmpxchg(l, o, n) \
14178 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14179 +#define local_cmpxchg_unchecked(l, o, n) \
14180 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14181 /* Always has a lock prefix */
14182 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14183
14184 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14185 new file mode 100644
14186 index 0000000..2bfd3ba
14187 --- /dev/null
14188 +++ b/arch/x86/include/asm/mman.h
14189 @@ -0,0 +1,15 @@
14190 +#ifndef _X86_MMAN_H
14191 +#define _X86_MMAN_H
14192 +
14193 +#include <uapi/asm/mman.h>
14194 +
14195 +#ifdef __KERNEL__
14196 +#ifndef __ASSEMBLY__
14197 +#ifdef CONFIG_X86_32
14198 +#define arch_mmap_check i386_mmap_check
14199 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14200 +#endif
14201 +#endif
14202 +#endif
14203 +
14204 +#endif /* X86_MMAN_H */
14205 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14206 index 5f55e69..e20bfb1 100644
14207 --- a/arch/x86/include/asm/mmu.h
14208 +++ b/arch/x86/include/asm/mmu.h
14209 @@ -9,7 +9,7 @@
14210 * we put the segment information here.
14211 */
14212 typedef struct {
14213 - void *ldt;
14214 + struct desc_struct *ldt;
14215 int size;
14216
14217 #ifdef CONFIG_X86_64
14218 @@ -18,7 +18,19 @@ typedef struct {
14219 #endif
14220
14221 struct mutex lock;
14222 - void *vdso;
14223 + unsigned long vdso;
14224 +
14225 +#ifdef CONFIG_X86_32
14226 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14227 + unsigned long user_cs_base;
14228 + unsigned long user_cs_limit;
14229 +
14230 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14231 + cpumask_t cpu_user_cs_mask;
14232 +#endif
14233 +
14234 +#endif
14235 +#endif
14236 } mm_context_t;
14237
14238 #ifdef CONFIG_SMP
14239 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14240 index cdbf367..adb37ac 100644
14241 --- a/arch/x86/include/asm/mmu_context.h
14242 +++ b/arch/x86/include/asm/mmu_context.h
14243 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14244
14245 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14246 {
14247 +
14248 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14249 + unsigned int i;
14250 + pgd_t *pgd;
14251 +
14252 + pax_open_kernel();
14253 + pgd = get_cpu_pgd(smp_processor_id());
14254 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14255 + set_pgd_batched(pgd+i, native_make_pgd(0));
14256 + pax_close_kernel();
14257 +#endif
14258 +
14259 #ifdef CONFIG_SMP
14260 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14261 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14262 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14263 struct task_struct *tsk)
14264 {
14265 unsigned cpu = smp_processor_id();
14266 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14267 + int tlbstate = TLBSTATE_OK;
14268 +#endif
14269
14270 if (likely(prev != next)) {
14271 #ifdef CONFIG_SMP
14272 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14273 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14274 +#endif
14275 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14276 this_cpu_write(cpu_tlbstate.active_mm, next);
14277 #endif
14278 cpumask_set_cpu(cpu, mm_cpumask(next));
14279
14280 /* Re-load page tables */
14281 +#ifdef CONFIG_PAX_PER_CPU_PGD
14282 + pax_open_kernel();
14283 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14284 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14285 + pax_close_kernel();
14286 + load_cr3(get_cpu_pgd(cpu));
14287 +#else
14288 load_cr3(next->pgd);
14289 +#endif
14290
14291 /* stop flush ipis for the previous mm */
14292 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14293 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14294 */
14295 if (unlikely(prev->context.ldt != next->context.ldt))
14296 load_LDT_nolock(&next->context);
14297 - }
14298 +
14299 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14300 + if (!(__supported_pte_mask & _PAGE_NX)) {
14301 + smp_mb__before_clear_bit();
14302 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14303 + smp_mb__after_clear_bit();
14304 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14305 + }
14306 +#endif
14307 +
14308 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14309 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14310 + prev->context.user_cs_limit != next->context.user_cs_limit))
14311 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14312 #ifdef CONFIG_SMP
14313 + else if (unlikely(tlbstate != TLBSTATE_OK))
14314 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14315 +#endif
14316 +#endif
14317 +
14318 + }
14319 else {
14320 +
14321 +#ifdef CONFIG_PAX_PER_CPU_PGD
14322 + pax_open_kernel();
14323 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14324 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14325 + pax_close_kernel();
14326 + load_cr3(get_cpu_pgd(cpu));
14327 +#endif
14328 +
14329 +#ifdef CONFIG_SMP
14330 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14331 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14332
14333 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14334 * tlb flush IPI delivery. We must reload CR3
14335 * to make sure to use no freed page tables.
14336 */
14337 +
14338 +#ifndef CONFIG_PAX_PER_CPU_PGD
14339 load_cr3(next->pgd);
14340 +#endif
14341 +
14342 load_LDT_nolock(&next->context);
14343 +
14344 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14345 + if (!(__supported_pte_mask & _PAGE_NX))
14346 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14347 +#endif
14348 +
14349 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14350 +#ifdef CONFIG_PAX_PAGEEXEC
14351 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14352 +#endif
14353 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14354 +#endif
14355 +
14356 }
14357 +#endif
14358 }
14359 -#endif
14360 }
14361
14362 #define activate_mm(prev, next) \
14363 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14364 index e3b7819..b257c64 100644
14365 --- a/arch/x86/include/asm/module.h
14366 +++ b/arch/x86/include/asm/module.h
14367 @@ -5,6 +5,7 @@
14368
14369 #ifdef CONFIG_X86_64
14370 /* X86_64 does not define MODULE_PROC_FAMILY */
14371 +#define MODULE_PROC_FAMILY ""
14372 #elif defined CONFIG_M486
14373 #define MODULE_PROC_FAMILY "486 "
14374 #elif defined CONFIG_M586
14375 @@ -57,8 +58,20 @@
14376 #error unknown processor family
14377 #endif
14378
14379 -#ifdef CONFIG_X86_32
14380 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14381 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14382 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14383 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14384 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14385 +#else
14386 +#define MODULE_PAX_KERNEXEC ""
14387 #endif
14388
14389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14390 +#define MODULE_PAX_UDEREF "UDEREF "
14391 +#else
14392 +#define MODULE_PAX_UDEREF ""
14393 +#endif
14394 +
14395 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14396 +
14397 #endif /* _ASM_X86_MODULE_H */
14398 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14399 index c0fa356..07a498a 100644
14400 --- a/arch/x86/include/asm/nmi.h
14401 +++ b/arch/x86/include/asm/nmi.h
14402 @@ -42,11 +42,11 @@ struct nmiaction {
14403 nmi_handler_t handler;
14404 unsigned long flags;
14405 const char *name;
14406 -};
14407 +} __do_const;
14408
14409 #define register_nmi_handler(t, fn, fg, n, init...) \
14410 ({ \
14411 - static struct nmiaction init fn##_na = { \
14412 + static const struct nmiaction init fn##_na = { \
14413 .handler = (fn), \
14414 .name = (n), \
14415 .flags = (fg), \
14416 @@ -54,7 +54,7 @@ struct nmiaction {
14417 __register_nmi_handler((t), &fn##_na); \
14418 })
14419
14420 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14421 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14422
14423 void unregister_nmi_handler(unsigned int, const char *);
14424
14425 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14426 index 320f7bb..e89f8f8 100644
14427 --- a/arch/x86/include/asm/page_64_types.h
14428 +++ b/arch/x86/include/asm/page_64_types.h
14429 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14430
14431 /* duplicated to the one in bootmem.h */
14432 extern unsigned long max_pfn;
14433 -extern unsigned long phys_base;
14434 +extern const unsigned long phys_base;
14435
14436 extern unsigned long __phys_addr(unsigned long);
14437 #define __phys_reloc_hide(x) (x)
14438 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14439 index 7361e47..16dc226 100644
14440 --- a/arch/x86/include/asm/paravirt.h
14441 +++ b/arch/x86/include/asm/paravirt.h
14442 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14443 return (pmd_t) { ret };
14444 }
14445
14446 -static inline pmdval_t pmd_val(pmd_t pmd)
14447 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14448 {
14449 pmdval_t ret;
14450
14451 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14452 val);
14453 }
14454
14455 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14456 +{
14457 + pgdval_t val = native_pgd_val(pgd);
14458 +
14459 + if (sizeof(pgdval_t) > sizeof(long))
14460 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14461 + val, (u64)val >> 32);
14462 + else
14463 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14464 + val);
14465 +}
14466 +
14467 static inline void pgd_clear(pgd_t *pgdp)
14468 {
14469 set_pgd(pgdp, __pgd(0));
14470 @@ -714,6 +726,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14471 pv_mmu_ops.set_fixmap(idx, phys, flags);
14472 }
14473
14474 +#ifdef CONFIG_PAX_KERNEXEC
14475 +static inline unsigned long pax_open_kernel(void)
14476 +{
14477 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14478 +}
14479 +
14480 +static inline unsigned long pax_close_kernel(void)
14481 +{
14482 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14483 +}
14484 +#else
14485 +static inline unsigned long pax_open_kernel(void) { return 0; }
14486 +static inline unsigned long pax_close_kernel(void) { return 0; }
14487 +#endif
14488 +
14489 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14490
14491 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14492 @@ -930,7 +957,7 @@ extern void default_banner(void);
14493
14494 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14495 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14496 -#define PARA_INDIRECT(addr) *%cs:addr
14497 +#define PARA_INDIRECT(addr) *%ss:addr
14498 #endif
14499
14500 #define INTERRUPT_RETURN \
14501 @@ -1005,6 +1032,21 @@ extern void default_banner(void);
14502 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14503 CLBR_NONE, \
14504 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14505 +
14506 +#define GET_CR0_INTO_RDI \
14507 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14508 + mov %rax,%rdi
14509 +
14510 +#define SET_RDI_INTO_CR0 \
14511 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14512 +
14513 +#define GET_CR3_INTO_RDI \
14514 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14515 + mov %rax,%rdi
14516 +
14517 +#define SET_RDI_INTO_CR3 \
14518 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14519 +
14520 #endif /* CONFIG_X86_32 */
14521
14522 #endif /* __ASSEMBLY__ */
14523 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14524 index b3b0ec1..b1cd3eb 100644
14525 --- a/arch/x86/include/asm/paravirt_types.h
14526 +++ b/arch/x86/include/asm/paravirt_types.h
14527 @@ -84,7 +84,7 @@ struct pv_init_ops {
14528 */
14529 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14530 unsigned long addr, unsigned len);
14531 -};
14532 +} __no_const;
14533
14534
14535 struct pv_lazy_ops {
14536 @@ -98,7 +98,7 @@ struct pv_time_ops {
14537 unsigned long long (*sched_clock)(void);
14538 unsigned long long (*steal_clock)(int cpu);
14539 unsigned long (*get_tsc_khz)(void);
14540 -};
14541 +} __no_const;
14542
14543 struct pv_cpu_ops {
14544 /* hooks for various privileged instructions */
14545 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14546
14547 void (*start_context_switch)(struct task_struct *prev);
14548 void (*end_context_switch)(struct task_struct *next);
14549 -};
14550 +} __no_const;
14551
14552 struct pv_irq_ops {
14553 /*
14554 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14555 unsigned long start_eip,
14556 unsigned long start_esp);
14557 #endif
14558 -};
14559 +} __no_const;
14560
14561 struct pv_mmu_ops {
14562 unsigned long (*read_cr2)(void);
14563 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14564 struct paravirt_callee_save make_pud;
14565
14566 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14567 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14568 #endif /* PAGETABLE_LEVELS == 4 */
14569 #endif /* PAGETABLE_LEVELS >= 3 */
14570
14571 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14572 an mfn. We can tell which is which from the index. */
14573 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14574 phys_addr_t phys, pgprot_t flags);
14575 +
14576 +#ifdef CONFIG_PAX_KERNEXEC
14577 + unsigned long (*pax_open_kernel)(void);
14578 + unsigned long (*pax_close_kernel)(void);
14579 +#endif
14580 +
14581 };
14582
14583 struct arch_spinlock;
14584 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14585 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14586 int (*spin_trylock)(struct arch_spinlock *lock);
14587 void (*spin_unlock)(struct arch_spinlock *lock);
14588 -};
14589 +} __no_const;
14590
14591 /* This contains all the paravirt structures: we get a convenient
14592 * number for each function using the offset which we use to indicate
14593 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14594 index b4389a4..7024269 100644
14595 --- a/arch/x86/include/asm/pgalloc.h
14596 +++ b/arch/x86/include/asm/pgalloc.h
14597 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14598 pmd_t *pmd, pte_t *pte)
14599 {
14600 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14601 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14602 +}
14603 +
14604 +static inline void pmd_populate_user(struct mm_struct *mm,
14605 + pmd_t *pmd, pte_t *pte)
14606 +{
14607 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14608 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14609 }
14610
14611 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14612
14613 #ifdef CONFIG_X86_PAE
14614 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14615 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14616 +{
14617 + pud_populate(mm, pudp, pmd);
14618 +}
14619 #else /* !CONFIG_X86_PAE */
14620 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14621 {
14622 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14623 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14624 }
14625 +
14626 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14627 +{
14628 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14629 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14630 +}
14631 #endif /* CONFIG_X86_PAE */
14632
14633 #if PAGETABLE_LEVELS > 3
14634 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14635 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14636 }
14637
14638 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14639 +{
14640 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14641 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14642 +}
14643 +
14644 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14645 {
14646 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14647 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14648 index f2b489c..4f7e2e5 100644
14649 --- a/arch/x86/include/asm/pgtable-2level.h
14650 +++ b/arch/x86/include/asm/pgtable-2level.h
14651 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14652
14653 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14654 {
14655 + pax_open_kernel();
14656 *pmdp = pmd;
14657 + pax_close_kernel();
14658 }
14659
14660 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14661 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14662 index 4cc9f2b..5fd9226 100644
14663 --- a/arch/x86/include/asm/pgtable-3level.h
14664 +++ b/arch/x86/include/asm/pgtable-3level.h
14665 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14666
14667 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14668 {
14669 + pax_open_kernel();
14670 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14671 + pax_close_kernel();
14672 }
14673
14674 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14675 {
14676 + pax_open_kernel();
14677 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14678 + pax_close_kernel();
14679 }
14680
14681 /*
14682 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14683 index 1c1a955..50f828c 100644
14684 --- a/arch/x86/include/asm/pgtable.h
14685 +++ b/arch/x86/include/asm/pgtable.h
14686 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14687
14688 #ifndef __PAGETABLE_PUD_FOLDED
14689 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14690 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14691 #define pgd_clear(pgd) native_pgd_clear(pgd)
14692 #endif
14693
14694 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14695
14696 #define arch_end_context_switch(prev) do {} while(0)
14697
14698 +#define pax_open_kernel() native_pax_open_kernel()
14699 +#define pax_close_kernel() native_pax_close_kernel()
14700 #endif /* CONFIG_PARAVIRT */
14701
14702 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14703 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14704 +
14705 +#ifdef CONFIG_PAX_KERNEXEC
14706 +static inline unsigned long native_pax_open_kernel(void)
14707 +{
14708 + unsigned long cr0;
14709 +
14710 + preempt_disable();
14711 + barrier();
14712 + cr0 = read_cr0() ^ X86_CR0_WP;
14713 + BUG_ON(cr0 & X86_CR0_WP);
14714 + write_cr0(cr0);
14715 + return cr0 ^ X86_CR0_WP;
14716 +}
14717 +
14718 +static inline unsigned long native_pax_close_kernel(void)
14719 +{
14720 + unsigned long cr0;
14721 +
14722 + cr0 = read_cr0() ^ X86_CR0_WP;
14723 + BUG_ON(!(cr0 & X86_CR0_WP));
14724 + write_cr0(cr0);
14725 + barrier();
14726 + preempt_enable_no_resched();
14727 + return cr0 ^ X86_CR0_WP;
14728 +}
14729 +#else
14730 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14731 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14732 +#endif
14733 +
14734 /*
14735 * The following only work if pte_present() is true.
14736 * Undefined behaviour if not..
14737 */
14738 +static inline int pte_user(pte_t pte)
14739 +{
14740 + return pte_val(pte) & _PAGE_USER;
14741 +}
14742 +
14743 static inline int pte_dirty(pte_t pte)
14744 {
14745 return pte_flags(pte) & _PAGE_DIRTY;
14746 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14747 return pte_clear_flags(pte, _PAGE_RW);
14748 }
14749
14750 +static inline pte_t pte_mkread(pte_t pte)
14751 +{
14752 + return __pte(pte_val(pte) | _PAGE_USER);
14753 +}
14754 +
14755 static inline pte_t pte_mkexec(pte_t pte)
14756 {
14757 - return pte_clear_flags(pte, _PAGE_NX);
14758 +#ifdef CONFIG_X86_PAE
14759 + if (__supported_pte_mask & _PAGE_NX)
14760 + return pte_clear_flags(pte, _PAGE_NX);
14761 + else
14762 +#endif
14763 + return pte_set_flags(pte, _PAGE_USER);
14764 +}
14765 +
14766 +static inline pte_t pte_exprotect(pte_t pte)
14767 +{
14768 +#ifdef CONFIG_X86_PAE
14769 + if (__supported_pte_mask & _PAGE_NX)
14770 + return pte_set_flags(pte, _PAGE_NX);
14771 + else
14772 +#endif
14773 + return pte_clear_flags(pte, _PAGE_USER);
14774 }
14775
14776 static inline pte_t pte_mkdirty(pte_t pte)
14777 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14778 #endif
14779
14780 #ifndef __ASSEMBLY__
14781 +
14782 +#ifdef CONFIG_PAX_PER_CPU_PGD
14783 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14784 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14785 +{
14786 + return cpu_pgd[cpu];
14787 +}
14788 +#endif
14789 +
14790 #include <linux/mm_types.h>
14791
14792 static inline int pte_none(pte_t pte)
14793 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14794
14795 static inline int pgd_bad(pgd_t pgd)
14796 {
14797 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14798 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14799 }
14800
14801 static inline int pgd_none(pgd_t pgd)
14802 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14803 * pgd_offset() returns a (pgd_t *)
14804 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14805 */
14806 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14807 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14808 +
14809 +#ifdef CONFIG_PAX_PER_CPU_PGD
14810 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14811 +#endif
14812 +
14813 /*
14814 * a shortcut which implies the use of the kernel's pgd, instead
14815 * of a process's
14816 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14817 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14818 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14819
14820 +#ifdef CONFIG_X86_32
14821 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14822 +#else
14823 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14824 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14825 +
14826 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14827 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14828 +#else
14829 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14830 +#endif
14831 +
14832 +#endif
14833 +
14834 #ifndef __ASSEMBLY__
14835
14836 extern int direct_gbpages;
14837 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14838 * dst and src can be on the same page, but the range must not overlap,
14839 * and must not cross a page boundary.
14840 */
14841 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14842 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14843 {
14844 - memcpy(dst, src, count * sizeof(pgd_t));
14845 + pax_open_kernel();
14846 + while (count--)
14847 + *dst++ = *src++;
14848 + pax_close_kernel();
14849 }
14850
14851 +#ifdef CONFIG_PAX_PER_CPU_PGD
14852 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14853 +#endif
14854 +
14855 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14856 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14857 +#else
14858 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14859 +#endif
14860
14861 #include <asm-generic/pgtable.h>
14862 #endif /* __ASSEMBLY__ */
14863 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14864 index 8faa215..a8a17ea 100644
14865 --- a/arch/x86/include/asm/pgtable_32.h
14866 +++ b/arch/x86/include/asm/pgtable_32.h
14867 @@ -25,9 +25,6 @@
14868 struct mm_struct;
14869 struct vm_area_struct;
14870
14871 -extern pgd_t swapper_pg_dir[1024];
14872 -extern pgd_t initial_page_table[1024];
14873 -
14874 static inline void pgtable_cache_init(void) { }
14875 static inline void check_pgt_cache(void) { }
14876 void paging_init(void);
14877 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14878 # include <asm/pgtable-2level.h>
14879 #endif
14880
14881 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14882 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14883 +#ifdef CONFIG_X86_PAE
14884 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14885 +#endif
14886 +
14887 #if defined(CONFIG_HIGHPTE)
14888 #define pte_offset_map(dir, address) \
14889 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14890 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14891 /* Clear a kernel PTE and flush it from the TLB */
14892 #define kpte_clear_flush(ptep, vaddr) \
14893 do { \
14894 + pax_open_kernel(); \
14895 pte_clear(&init_mm, (vaddr), (ptep)); \
14896 + pax_close_kernel(); \
14897 __flush_tlb_one((vaddr)); \
14898 } while (0)
14899
14900 @@ -75,6 +80,9 @@ do { \
14901
14902 #endif /* !__ASSEMBLY__ */
14903
14904 +#define HAVE_ARCH_UNMAPPED_AREA
14905 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14906 +
14907 /*
14908 * kern_addr_valid() is (1) for FLATMEM and (0) for
14909 * SPARSEMEM and DISCONTIGMEM
14910 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14911 index ed5903b..c7fe163 100644
14912 --- a/arch/x86/include/asm/pgtable_32_types.h
14913 +++ b/arch/x86/include/asm/pgtable_32_types.h
14914 @@ -8,7 +8,7 @@
14915 */
14916 #ifdef CONFIG_X86_PAE
14917 # include <asm/pgtable-3level_types.h>
14918 -# define PMD_SIZE (1UL << PMD_SHIFT)
14919 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14920 # define PMD_MASK (~(PMD_SIZE - 1))
14921 #else
14922 # include <asm/pgtable-2level_types.h>
14923 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14924 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14925 #endif
14926
14927 +#ifdef CONFIG_PAX_KERNEXEC
14928 +#ifndef __ASSEMBLY__
14929 +extern unsigned char MODULES_EXEC_VADDR[];
14930 +extern unsigned char MODULES_EXEC_END[];
14931 +#endif
14932 +#include <asm/boot.h>
14933 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14934 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14935 +#else
14936 +#define ktla_ktva(addr) (addr)
14937 +#define ktva_ktla(addr) (addr)
14938 +#endif
14939 +
14940 #define MODULES_VADDR VMALLOC_START
14941 #define MODULES_END VMALLOC_END
14942 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14943 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14944 index 47356f9..deb94a2 100644
14945 --- a/arch/x86/include/asm/pgtable_64.h
14946 +++ b/arch/x86/include/asm/pgtable_64.h
14947 @@ -16,10 +16,14 @@
14948
14949 extern pud_t level3_kernel_pgt[512];
14950 extern pud_t level3_ident_pgt[512];
14951 +extern pud_t level3_vmalloc_start_pgt[512];
14952 +extern pud_t level3_vmalloc_end_pgt[512];
14953 +extern pud_t level3_vmemmap_pgt[512];
14954 +extern pud_t level2_vmemmap_pgt[512];
14955 extern pmd_t level2_kernel_pgt[512];
14956 extern pmd_t level2_fixmap_pgt[512];
14957 -extern pmd_t level2_ident_pgt[512];
14958 -extern pgd_t init_level4_pgt[];
14959 +extern pmd_t level2_ident_pgt[512*2];
14960 +extern pgd_t init_level4_pgt[512];
14961
14962 #define swapper_pg_dir init_level4_pgt
14963
14964 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14965
14966 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14967 {
14968 + pax_open_kernel();
14969 *pmdp = pmd;
14970 + pax_close_kernel();
14971 }
14972
14973 static inline void native_pmd_clear(pmd_t *pmd)
14974 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14975
14976 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14977 {
14978 + pax_open_kernel();
14979 *pudp = pud;
14980 + pax_close_kernel();
14981 }
14982
14983 static inline void native_pud_clear(pud_t *pud)
14984 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14985
14986 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14987 {
14988 + pax_open_kernel();
14989 + *pgdp = pgd;
14990 + pax_close_kernel();
14991 +}
14992 +
14993 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14994 +{
14995 *pgdp = pgd;
14996 }
14997
14998 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14999 index 766ea16..5b96cb3 100644
15000 --- a/arch/x86/include/asm/pgtable_64_types.h
15001 +++ b/arch/x86/include/asm/pgtable_64_types.h
15002 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
15003 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15004 #define MODULES_END _AC(0xffffffffff000000, UL)
15005 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15006 +#define MODULES_EXEC_VADDR MODULES_VADDR
15007 +#define MODULES_EXEC_END MODULES_END
15008 +
15009 +#define ktla_ktva(addr) (addr)
15010 +#define ktva_ktla(addr) (addr)
15011
15012 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
15013 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15014 index 3c32db8..1ddccf5 100644
15015 --- a/arch/x86/include/asm/pgtable_types.h
15016 +++ b/arch/x86/include/asm/pgtable_types.h
15017 @@ -16,13 +16,12 @@
15018 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15019 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15020 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15021 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15022 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15023 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15024 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15025 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15026 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15027 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15028 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15029 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15030 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15031 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15032
15033 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15034 @@ -40,7 +39,6 @@
15035 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15036 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15037 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15038 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15039 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15040 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15041 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15042 @@ -57,8 +55,10 @@
15043
15044 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15045 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15046 -#else
15047 +#elif defined(CONFIG_KMEMCHECK)
15048 #define _PAGE_NX (_AT(pteval_t, 0))
15049 +#else
15050 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15051 #endif
15052
15053 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15054 @@ -116,6 +116,9 @@
15055 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15056 _PAGE_ACCESSED)
15057
15058 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15059 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15060 +
15061 #define __PAGE_KERNEL_EXEC \
15062 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15063 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15064 @@ -126,7 +129,7 @@
15065 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15066 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15067 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15068 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15069 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15070 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15071 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15072 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15073 @@ -188,8 +191,8 @@
15074 * bits are combined, this will alow user to access the high address mapped
15075 * VDSO in the presence of CONFIG_COMPAT_VDSO
15076 */
15077 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15078 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15079 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15080 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15081 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15082 #endif
15083
15084 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15085 {
15086 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15087 }
15088 +#endif
15089
15090 +#if PAGETABLE_LEVELS == 3
15091 +#include <asm-generic/pgtable-nopud.h>
15092 +#endif
15093 +
15094 +#if PAGETABLE_LEVELS == 2
15095 +#include <asm-generic/pgtable-nopmd.h>
15096 +#endif
15097 +
15098 +#ifndef __ASSEMBLY__
15099 #if PAGETABLE_LEVELS > 3
15100 typedef struct { pudval_t pud; } pud_t;
15101
15102 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15103 return pud.pud;
15104 }
15105 #else
15106 -#include <asm-generic/pgtable-nopud.h>
15107 -
15108 static inline pudval_t native_pud_val(pud_t pud)
15109 {
15110 return native_pgd_val(pud.pgd);
15111 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15112 return pmd.pmd;
15113 }
15114 #else
15115 -#include <asm-generic/pgtable-nopmd.h>
15116 -
15117 static inline pmdval_t native_pmd_val(pmd_t pmd)
15118 {
15119 return native_pgd_val(pmd.pud.pgd);
15120 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15121
15122 extern pteval_t __supported_pte_mask;
15123 extern void set_nx(void);
15124 -extern int nx_enabled;
15125
15126 #define pgprot_writecombine pgprot_writecombine
15127 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15128 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15129 index 888184b..a07ac89 100644
15130 --- a/arch/x86/include/asm/processor.h
15131 +++ b/arch/x86/include/asm/processor.h
15132 @@ -287,7 +287,7 @@ struct tss_struct {
15133
15134 } ____cacheline_aligned;
15135
15136 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15137 +extern struct tss_struct init_tss[NR_CPUS];
15138
15139 /*
15140 * Save the original ist values for checking stack pointers during debugging
15141 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15142 */
15143 #define TASK_SIZE PAGE_OFFSET
15144 #define TASK_SIZE_MAX TASK_SIZE
15145 +
15146 +#ifdef CONFIG_PAX_SEGMEXEC
15147 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15148 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15149 +#else
15150 #define STACK_TOP TASK_SIZE
15151 -#define STACK_TOP_MAX STACK_TOP
15152 +#endif
15153 +
15154 +#define STACK_TOP_MAX TASK_SIZE
15155
15156 #define INIT_THREAD { \
15157 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15158 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15159 .vm86_info = NULL, \
15160 .sysenter_cs = __KERNEL_CS, \
15161 .io_bitmap_ptr = NULL, \
15162 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15163 */
15164 #define INIT_TSS { \
15165 .x86_tss = { \
15166 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15167 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15168 .ss0 = __KERNEL_DS, \
15169 .ss1 = __KERNEL_CS, \
15170 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15171 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15172 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15173
15174 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15175 -#define KSTK_TOP(info) \
15176 -({ \
15177 - unsigned long *__ptr = (unsigned long *)(info); \
15178 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15179 -})
15180 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15181
15182 /*
15183 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15184 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15185 #define task_pt_regs(task) \
15186 ({ \
15187 struct pt_regs *__regs__; \
15188 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15189 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15190 __regs__ - 1; \
15191 })
15192
15193 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15194 /*
15195 * User space process size. 47bits minus one guard page.
15196 */
15197 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15198 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15199
15200 /* This decides where the kernel will search for a free chunk of vm
15201 * space during mmap's.
15202 */
15203 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15204 - 0xc0000000 : 0xFFFFe000)
15205 + 0xc0000000 : 0xFFFFf000)
15206
15207 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15208 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15209 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15210 #define STACK_TOP_MAX TASK_SIZE_MAX
15211
15212 #define INIT_THREAD { \
15213 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15214 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15215 }
15216
15217 #define INIT_TSS { \
15218 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15219 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15220 }
15221
15222 /*
15223 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15224 */
15225 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15226
15227 +#ifdef CONFIG_PAX_SEGMEXEC
15228 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15229 +#endif
15230 +
15231 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15232
15233 /* Get/set a process' ability to use the timestamp counter instruction */
15234 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15235 #define cpu_has_amd_erratum(x) (false)
15236 #endif /* CONFIG_CPU_SUP_AMD */
15237
15238 -extern unsigned long arch_align_stack(unsigned long sp);
15239 +#define arch_align_stack(x) ((x) & ~0xfUL)
15240 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15241
15242 void default_idle(void);
15243 bool set_pm_idle_to_default(void);
15244
15245 -void stop_this_cpu(void *dummy);
15246 +void stop_this_cpu(void *dummy) __noreturn;
15247
15248 #endif /* _ASM_X86_PROCESSOR_H */
15249 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15250 index 942a086..6c26446 100644
15251 --- a/arch/x86/include/asm/ptrace.h
15252 +++ b/arch/x86/include/asm/ptrace.h
15253 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15254 }
15255
15256 /*
15257 - * user_mode_vm(regs) determines whether a register set came from user mode.
15258 + * user_mode(regs) determines whether a register set came from user mode.
15259 * This is true if V8086 mode was enabled OR if the register set was from
15260 * protected mode with RPL-3 CS value. This tricky test checks that with
15261 * one comparison. Many places in the kernel can bypass this full check
15262 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15263 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15264 + * be used.
15265 */
15266 -static inline int user_mode(struct pt_regs *regs)
15267 +static inline int user_mode_novm(struct pt_regs *regs)
15268 {
15269 #ifdef CONFIG_X86_32
15270 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15271 #else
15272 - return !!(regs->cs & 3);
15273 + return !!(regs->cs & SEGMENT_RPL_MASK);
15274 #endif
15275 }
15276
15277 -static inline int user_mode_vm(struct pt_regs *regs)
15278 +static inline int user_mode(struct pt_regs *regs)
15279 {
15280 #ifdef CONFIG_X86_32
15281 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15282 USER_RPL;
15283 #else
15284 - return user_mode(regs);
15285 + return user_mode_novm(regs);
15286 #endif
15287 }
15288
15289 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15290 #ifdef CONFIG_X86_64
15291 static inline bool user_64bit_mode(struct pt_regs *regs)
15292 {
15293 + unsigned long cs = regs->cs & 0xffff;
15294 #ifndef CONFIG_PARAVIRT
15295 /*
15296 * On non-paravirt systems, this is the only long mode CPL 3
15297 * selector. We do not allow long mode selectors in the LDT.
15298 */
15299 - return regs->cs == __USER_CS;
15300 + return cs == __USER_CS;
15301 #else
15302 /* Headers are too twisted for this to go in paravirt.h. */
15303 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15304 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15305 #endif
15306 }
15307
15308 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15309 * Traps from the kernel do not save sp and ss.
15310 * Use the helper function to retrieve sp.
15311 */
15312 - if (offset == offsetof(struct pt_regs, sp) &&
15313 - regs->cs == __KERNEL_CS)
15314 - return kernel_stack_pointer(regs);
15315 + if (offset == offsetof(struct pt_regs, sp)) {
15316 + unsigned long cs = regs->cs & 0xffff;
15317 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15318 + return kernel_stack_pointer(regs);
15319 + }
15320 #endif
15321 return *(unsigned long *)((unsigned long)regs + offset);
15322 }
15323 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15324 index fe1ec5b..dc5c3fe 100644
15325 --- a/arch/x86/include/asm/realmode.h
15326 +++ b/arch/x86/include/asm/realmode.h
15327 @@ -22,16 +22,14 @@ struct real_mode_header {
15328 #endif
15329 /* APM/BIOS reboot */
15330 u32 machine_real_restart_asm;
15331 -#ifdef CONFIG_X86_64
15332 u32 machine_real_restart_seg;
15333 -#endif
15334 };
15335
15336 /* This must match data at trampoline_32/64.S */
15337 struct trampoline_header {
15338 #ifdef CONFIG_X86_32
15339 u32 start;
15340 - u16 gdt_pad;
15341 + u16 boot_cs;
15342 u16 gdt_limit;
15343 u32 gdt_base;
15344 #else
15345 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15346 index a82c4f1..ac45053 100644
15347 --- a/arch/x86/include/asm/reboot.h
15348 +++ b/arch/x86/include/asm/reboot.h
15349 @@ -6,13 +6,13 @@
15350 struct pt_regs;
15351
15352 struct machine_ops {
15353 - void (*restart)(char *cmd);
15354 - void (*halt)(void);
15355 - void (*power_off)(void);
15356 + void (* __noreturn restart)(char *cmd);
15357 + void (* __noreturn halt)(void);
15358 + void (* __noreturn power_off)(void);
15359 void (*shutdown)(void);
15360 void (*crash_shutdown)(struct pt_regs *);
15361 - void (*emergency_restart)(void);
15362 -};
15363 + void (* __noreturn emergency_restart)(void);
15364 +} __no_const;
15365
15366 extern struct machine_ops machine_ops;
15367
15368 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15369 index 2dbe4a7..ce1db00 100644
15370 --- a/arch/x86/include/asm/rwsem.h
15371 +++ b/arch/x86/include/asm/rwsem.h
15372 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15373 {
15374 asm volatile("# beginning down_read\n\t"
15375 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15376 +
15377 +#ifdef CONFIG_PAX_REFCOUNT
15378 + "jno 0f\n"
15379 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15380 + "int $4\n0:\n"
15381 + _ASM_EXTABLE(0b, 0b)
15382 +#endif
15383 +
15384 /* adds 0x00000001 */
15385 " jns 1f\n"
15386 " call call_rwsem_down_read_failed\n"
15387 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15388 "1:\n\t"
15389 " mov %1,%2\n\t"
15390 " add %3,%2\n\t"
15391 +
15392 +#ifdef CONFIG_PAX_REFCOUNT
15393 + "jno 0f\n"
15394 + "sub %3,%2\n"
15395 + "int $4\n0:\n"
15396 + _ASM_EXTABLE(0b, 0b)
15397 +#endif
15398 +
15399 " jle 2f\n\t"
15400 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15401 " jnz 1b\n\t"
15402 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15403 long tmp;
15404 asm volatile("# beginning down_write\n\t"
15405 LOCK_PREFIX " xadd %1,(%2)\n\t"
15406 +
15407 +#ifdef CONFIG_PAX_REFCOUNT
15408 + "jno 0f\n"
15409 + "mov %1,(%2)\n"
15410 + "int $4\n0:\n"
15411 + _ASM_EXTABLE(0b, 0b)
15412 +#endif
15413 +
15414 /* adds 0xffff0001, returns the old value */
15415 " test %1,%1\n\t"
15416 /* was the count 0 before? */
15417 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15418 long tmp;
15419 asm volatile("# beginning __up_read\n\t"
15420 LOCK_PREFIX " xadd %1,(%2)\n\t"
15421 +
15422 +#ifdef CONFIG_PAX_REFCOUNT
15423 + "jno 0f\n"
15424 + "mov %1,(%2)\n"
15425 + "int $4\n0:\n"
15426 + _ASM_EXTABLE(0b, 0b)
15427 +#endif
15428 +
15429 /* subtracts 1, returns the old value */
15430 " jns 1f\n\t"
15431 " call call_rwsem_wake\n" /* expects old value in %edx */
15432 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15433 long tmp;
15434 asm volatile("# beginning __up_write\n\t"
15435 LOCK_PREFIX " xadd %1,(%2)\n\t"
15436 +
15437 +#ifdef CONFIG_PAX_REFCOUNT
15438 + "jno 0f\n"
15439 + "mov %1,(%2)\n"
15440 + "int $4\n0:\n"
15441 + _ASM_EXTABLE(0b, 0b)
15442 +#endif
15443 +
15444 /* subtracts 0xffff0001, returns the old value */
15445 " jns 1f\n\t"
15446 " call call_rwsem_wake\n" /* expects old value in %edx */
15447 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15448 {
15449 asm volatile("# beginning __downgrade_write\n\t"
15450 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15451 +
15452 +#ifdef CONFIG_PAX_REFCOUNT
15453 + "jno 0f\n"
15454 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15455 + "int $4\n0:\n"
15456 + _ASM_EXTABLE(0b, 0b)
15457 +#endif
15458 +
15459 /*
15460 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15461 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15462 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15463 */
15464 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15465 {
15466 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15467 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15468 +
15469 +#ifdef CONFIG_PAX_REFCOUNT
15470 + "jno 0f\n"
15471 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15472 + "int $4\n0:\n"
15473 + _ASM_EXTABLE(0b, 0b)
15474 +#endif
15475 +
15476 : "+m" (sem->count)
15477 : "er" (delta));
15478 }
15479 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15480 */
15481 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15482 {
15483 - return delta + xadd(&sem->count, delta);
15484 + return delta + xadd_check_overflow(&sem->count, delta);
15485 }
15486
15487 #endif /* __KERNEL__ */
15488 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15489 index c48a950..c6d7468 100644
15490 --- a/arch/x86/include/asm/segment.h
15491 +++ b/arch/x86/include/asm/segment.h
15492 @@ -64,10 +64,15 @@
15493 * 26 - ESPFIX small SS
15494 * 27 - per-cpu [ offset to per-cpu data area ]
15495 * 28 - stack_canary-20 [ for stack protector ]
15496 - * 29 - unused
15497 - * 30 - unused
15498 + * 29 - PCI BIOS CS
15499 + * 30 - PCI BIOS DS
15500 * 31 - TSS for double fault handler
15501 */
15502 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15503 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15504 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15505 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15506 +
15507 #define GDT_ENTRY_TLS_MIN 6
15508 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15509
15510 @@ -79,6 +84,8 @@
15511
15512 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15513
15514 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15515 +
15516 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15517
15518 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15519 @@ -104,6 +111,12 @@
15520 #define __KERNEL_STACK_CANARY 0
15521 #endif
15522
15523 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15524 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15525 +
15526 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15527 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15528 +
15529 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15530
15531 /*
15532 @@ -141,7 +154,7 @@
15533 */
15534
15535 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15536 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15537 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15538
15539
15540 #else
15541 @@ -165,6 +178,8 @@
15542 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15543 #define __USER32_DS __USER_DS
15544
15545 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15546 +
15547 #define GDT_ENTRY_TSS 8 /* needs two entries */
15548 #define GDT_ENTRY_LDT 10 /* needs two entries */
15549 #define GDT_ENTRY_TLS_MIN 12
15550 @@ -185,6 +200,7 @@
15551 #endif
15552
15553 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15554 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15555 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15556 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15557 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15558 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15559 {
15560 unsigned long __limit;
15561 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15562 - return __limit + 1;
15563 + return __limit;
15564 }
15565
15566 #endif /* !__ASSEMBLY__ */
15567 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15568 index b073aae..39f9bdd 100644
15569 --- a/arch/x86/include/asm/smp.h
15570 +++ b/arch/x86/include/asm/smp.h
15571 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15572 /* cpus sharing the last level cache: */
15573 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15574 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15575 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15576 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15577
15578 static inline struct cpumask *cpu_sibling_mask(int cpu)
15579 {
15580 @@ -79,7 +79,7 @@ struct smp_ops {
15581
15582 void (*send_call_func_ipi)(const struct cpumask *mask);
15583 void (*send_call_func_single_ipi)(int cpu);
15584 -};
15585 +} __no_const;
15586
15587 /* Globals due to paravirt */
15588 extern void set_cpu_sibling_map(int cpu);
15589 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15590 extern int safe_smp_processor_id(void);
15591
15592 #elif defined(CONFIG_X86_64_SMP)
15593 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15594 -
15595 -#define stack_smp_processor_id() \
15596 -({ \
15597 - struct thread_info *ti; \
15598 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15599 - ti->cpu; \
15600 -})
15601 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15602 +#define stack_smp_processor_id() raw_smp_processor_id()
15603 #define safe_smp_processor_id() smp_processor_id()
15604
15605 #endif
15606 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15607 index 33692ea..350a534 100644
15608 --- a/arch/x86/include/asm/spinlock.h
15609 +++ b/arch/x86/include/asm/spinlock.h
15610 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15611 static inline void arch_read_lock(arch_rwlock_t *rw)
15612 {
15613 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15614 +
15615 +#ifdef CONFIG_PAX_REFCOUNT
15616 + "jno 0f\n"
15617 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15618 + "int $4\n0:\n"
15619 + _ASM_EXTABLE(0b, 0b)
15620 +#endif
15621 +
15622 "jns 1f\n"
15623 "call __read_lock_failed\n\t"
15624 "1:\n"
15625 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15626 static inline void arch_write_lock(arch_rwlock_t *rw)
15627 {
15628 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15629 +
15630 +#ifdef CONFIG_PAX_REFCOUNT
15631 + "jno 0f\n"
15632 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15633 + "int $4\n0:\n"
15634 + _ASM_EXTABLE(0b, 0b)
15635 +#endif
15636 +
15637 "jz 1f\n"
15638 "call __write_lock_failed\n\t"
15639 "1:\n"
15640 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15641
15642 static inline void arch_read_unlock(arch_rwlock_t *rw)
15643 {
15644 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15645 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15646 +
15647 +#ifdef CONFIG_PAX_REFCOUNT
15648 + "jno 0f\n"
15649 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15650 + "int $4\n0:\n"
15651 + _ASM_EXTABLE(0b, 0b)
15652 +#endif
15653 +
15654 :"+m" (rw->lock) : : "memory");
15655 }
15656
15657 static inline void arch_write_unlock(arch_rwlock_t *rw)
15658 {
15659 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15660 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15661 +
15662 +#ifdef CONFIG_PAX_REFCOUNT
15663 + "jno 0f\n"
15664 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15665 + "int $4\n0:\n"
15666 + _ASM_EXTABLE(0b, 0b)
15667 +#endif
15668 +
15669 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15670 }
15671
15672 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15673 index 6a99859..03cb807 100644
15674 --- a/arch/x86/include/asm/stackprotector.h
15675 +++ b/arch/x86/include/asm/stackprotector.h
15676 @@ -47,7 +47,7 @@
15677 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15678 */
15679 #define GDT_STACK_CANARY_INIT \
15680 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15681 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15682
15683 /*
15684 * Initialize the stackprotector canary value.
15685 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15686
15687 static inline void load_stack_canary_segment(void)
15688 {
15689 -#ifdef CONFIG_X86_32
15690 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15691 asm volatile ("mov %0, %%gs" : : "r" (0));
15692 #endif
15693 }
15694 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15695 index 70bbe39..4ae2bd4 100644
15696 --- a/arch/x86/include/asm/stacktrace.h
15697 +++ b/arch/x86/include/asm/stacktrace.h
15698 @@ -11,28 +11,20 @@
15699
15700 extern int kstack_depth_to_print;
15701
15702 -struct thread_info;
15703 +struct task_struct;
15704 struct stacktrace_ops;
15705
15706 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15707 - unsigned long *stack,
15708 - unsigned long bp,
15709 - const struct stacktrace_ops *ops,
15710 - void *data,
15711 - unsigned long *end,
15712 - int *graph);
15713 +typedef unsigned long walk_stack_t(struct task_struct *task,
15714 + void *stack_start,
15715 + unsigned long *stack,
15716 + unsigned long bp,
15717 + const struct stacktrace_ops *ops,
15718 + void *data,
15719 + unsigned long *end,
15720 + int *graph);
15721
15722 -extern unsigned long
15723 -print_context_stack(struct thread_info *tinfo,
15724 - unsigned long *stack, unsigned long bp,
15725 - const struct stacktrace_ops *ops, void *data,
15726 - unsigned long *end, int *graph);
15727 -
15728 -extern unsigned long
15729 -print_context_stack_bp(struct thread_info *tinfo,
15730 - unsigned long *stack, unsigned long bp,
15731 - const struct stacktrace_ops *ops, void *data,
15732 - unsigned long *end, int *graph);
15733 +extern walk_stack_t print_context_stack;
15734 +extern walk_stack_t print_context_stack_bp;
15735
15736 /* Generic stack tracer with callbacks */
15737
15738 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15739 void (*address)(void *data, unsigned long address, int reliable);
15740 /* On negative return stop dumping */
15741 int (*stack)(void *data, char *name);
15742 - walk_stack_t walk_stack;
15743 + walk_stack_t *walk_stack;
15744 };
15745
15746 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15747 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15748 index 4ec45b3..a4f0a8a 100644
15749 --- a/arch/x86/include/asm/switch_to.h
15750 +++ b/arch/x86/include/asm/switch_to.h
15751 @@ -108,7 +108,7 @@ do { \
15752 "call __switch_to\n\t" \
15753 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15754 __switch_canary \
15755 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15756 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15757 "movq %%rax,%%rdi\n\t" \
15758 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15759 "jnz ret_from_fork\n\t" \
15760 @@ -119,7 +119,7 @@ do { \
15761 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15762 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15763 [_tif_fork] "i" (_TIF_FORK), \
15764 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15765 + [thread_info] "m" (current_tinfo), \
15766 [current_task] "m" (current_task) \
15767 __switch_canary_iparam \
15768 : "memory", "cc" __EXTRA_CLOBBER)
15769 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15770 index 2d946e6..e453ec4 100644
15771 --- a/arch/x86/include/asm/thread_info.h
15772 +++ b/arch/x86/include/asm/thread_info.h
15773 @@ -10,6 +10,7 @@
15774 #include <linux/compiler.h>
15775 #include <asm/page.h>
15776 #include <asm/types.h>
15777 +#include <asm/percpu.h>
15778
15779 /*
15780 * low level task data that entry.S needs immediate access to
15781 @@ -24,7 +25,6 @@ struct exec_domain;
15782 #include <linux/atomic.h>
15783
15784 struct thread_info {
15785 - struct task_struct *task; /* main task structure */
15786 struct exec_domain *exec_domain; /* execution domain */
15787 __u32 flags; /* low level flags */
15788 __u32 status; /* thread synchronous flags */
15789 @@ -34,19 +34,13 @@ struct thread_info {
15790 mm_segment_t addr_limit;
15791 struct restart_block restart_block;
15792 void __user *sysenter_return;
15793 -#ifdef CONFIG_X86_32
15794 - unsigned long previous_esp; /* ESP of the previous stack in
15795 - case of nested (IRQ) stacks
15796 - */
15797 - __u8 supervisor_stack[0];
15798 -#endif
15799 + unsigned long lowest_stack;
15800 unsigned int sig_on_uaccess_error:1;
15801 unsigned int uaccess_err:1; /* uaccess failed */
15802 };
15803
15804 -#define INIT_THREAD_INFO(tsk) \
15805 +#define INIT_THREAD_INFO \
15806 { \
15807 - .task = &tsk, \
15808 .exec_domain = &default_exec_domain, \
15809 .flags = 0, \
15810 .cpu = 0, \
15811 @@ -57,7 +51,7 @@ struct thread_info {
15812 }, \
15813 }
15814
15815 -#define init_thread_info (init_thread_union.thread_info)
15816 +#define init_thread_info (init_thread_union.stack)
15817 #define init_stack (init_thread_union.stack)
15818
15819 #else /* !__ASSEMBLY__ */
15820 @@ -98,6 +92,7 @@ struct thread_info {
15821 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15822 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15823 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15824 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15825
15826 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15827 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15828 @@ -122,17 +117,18 @@ struct thread_info {
15829 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15830 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15831 #define _TIF_X32 (1 << TIF_X32)
15832 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15833
15834 /* work to do in syscall_trace_enter() */
15835 #define _TIF_WORK_SYSCALL_ENTRY \
15836 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15837 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15838 - _TIF_NOHZ)
15839 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15840
15841 /* work to do in syscall_trace_leave() */
15842 #define _TIF_WORK_SYSCALL_EXIT \
15843 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15844 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15845 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15846
15847 /* work to do on interrupt/exception return */
15848 #define _TIF_WORK_MASK \
15849 @@ -143,7 +139,7 @@ struct thread_info {
15850 /* work to do on any return to user space */
15851 #define _TIF_ALLWORK_MASK \
15852 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15853 - _TIF_NOHZ)
15854 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15855
15856 /* Only used for 64 bit */
15857 #define _TIF_DO_NOTIFY_MASK \
15858 @@ -159,45 +155,40 @@ struct thread_info {
15859
15860 #define PREEMPT_ACTIVE 0x10000000
15861
15862 -#ifdef CONFIG_X86_32
15863 -
15864 -#define STACK_WARN (THREAD_SIZE/8)
15865 -/*
15866 - * macros/functions for gaining access to the thread information structure
15867 - *
15868 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15869 - */
15870 -#ifndef __ASSEMBLY__
15871 -
15872 -
15873 -/* how to get the current stack pointer from C */
15874 -register unsigned long current_stack_pointer asm("esp") __used;
15875 -
15876 -/* how to get the thread information struct from C */
15877 -static inline struct thread_info *current_thread_info(void)
15878 -{
15879 - return (struct thread_info *)
15880 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15881 -}
15882 -
15883 -#else /* !__ASSEMBLY__ */
15884 -
15885 +#ifdef __ASSEMBLY__
15886 /* how to get the thread information struct from ASM */
15887 #define GET_THREAD_INFO(reg) \
15888 - movl $-THREAD_SIZE, reg; \
15889 - andl %esp, reg
15890 + mov PER_CPU_VAR(current_tinfo), reg
15891
15892 /* use this one if reg already contains %esp */
15893 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15894 - andl $-THREAD_SIZE, reg
15895 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15896 +#else
15897 +/* how to get the thread information struct from C */
15898 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15899 +
15900 +static __always_inline struct thread_info *current_thread_info(void)
15901 +{
15902 + return this_cpu_read_stable(current_tinfo);
15903 +}
15904 +#endif
15905 +
15906 +#ifdef CONFIG_X86_32
15907 +
15908 +#define STACK_WARN (THREAD_SIZE/8)
15909 +/*
15910 + * macros/functions for gaining access to the thread information structure
15911 + *
15912 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15913 + */
15914 +#ifndef __ASSEMBLY__
15915 +
15916 +/* how to get the current stack pointer from C */
15917 +register unsigned long current_stack_pointer asm("esp") __used;
15918
15919 #endif
15920
15921 #else /* X86_32 */
15922
15923 -#include <asm/percpu.h>
15924 -#define KERNEL_STACK_OFFSET (5*8)
15925 -
15926 /*
15927 * macros/functions for gaining access to the thread information structure
15928 * preempt_count needs to be 1 initially, until the scheduler is functional.
15929 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15930 #ifndef __ASSEMBLY__
15931 DECLARE_PER_CPU(unsigned long, kernel_stack);
15932
15933 -static inline struct thread_info *current_thread_info(void)
15934 -{
15935 - struct thread_info *ti;
15936 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15937 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15938 - return ti;
15939 -}
15940 -
15941 -#else /* !__ASSEMBLY__ */
15942 -
15943 -/* how to get the thread information struct from ASM */
15944 -#define GET_THREAD_INFO(reg) \
15945 - movq PER_CPU_VAR(kernel_stack),reg ; \
15946 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15947 -
15948 -/*
15949 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15950 - * a certain register (to be used in assembler memory operands).
15951 - */
15952 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15953 -
15954 +/* how to get the current stack pointer from C */
15955 +register unsigned long current_stack_pointer asm("rsp") __used;
15956 #endif
15957
15958 #endif /* !X86_32 */
15959 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15960 extern void arch_task_cache_init(void);
15961 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15962 extern void arch_release_task_struct(struct task_struct *tsk);
15963 +
15964 +#define __HAVE_THREAD_FUNCTIONS
15965 +#define task_thread_info(task) (&(task)->tinfo)
15966 +#define task_stack_page(task) ((task)->stack)
15967 +#define setup_thread_stack(p, org) do {} while (0)
15968 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15969 +
15970 #endif
15971 #endif /* _ASM_X86_THREAD_INFO_H */
15972 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15973 index 1709801..0a60f2f 100644
15974 --- a/arch/x86/include/asm/uaccess.h
15975 +++ b/arch/x86/include/asm/uaccess.h
15976 @@ -7,6 +7,7 @@
15977 #include <linux/compiler.h>
15978 #include <linux/thread_info.h>
15979 #include <linux/string.h>
15980 +#include <linux/sched.h>
15981 #include <asm/asm.h>
15982 #include <asm/page.h>
15983 #include <asm/smap.h>
15984 @@ -29,7 +30,12 @@
15985
15986 #define get_ds() (KERNEL_DS)
15987 #define get_fs() (current_thread_info()->addr_limit)
15988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15989 +void __set_fs(mm_segment_t x);
15990 +void set_fs(mm_segment_t x);
15991 +#else
15992 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15993 +#endif
15994
15995 #define segment_eq(a, b) ((a).seg == (b).seg)
15996
15997 @@ -77,8 +83,33 @@
15998 * checks that the pointer is in the user space range - after calling
15999 * this function, memory access functions may still return -EFAULT.
16000 */
16001 -#define access_ok(type, addr, size) \
16002 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16003 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16004 +#define access_ok(type, addr, size) \
16005 +({ \
16006 + long __size = size; \
16007 + unsigned long __addr = (unsigned long)addr; \
16008 + unsigned long __addr_ao = __addr & PAGE_MASK; \
16009 + unsigned long __end_ao = __addr + __size - 1; \
16010 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
16011 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
16012 + while(__addr_ao <= __end_ao) { \
16013 + char __c_ao; \
16014 + __addr_ao += PAGE_SIZE; \
16015 + if (__size > PAGE_SIZE) \
16016 + cond_resched(); \
16017 + if (__get_user(__c_ao, (char __user *)__addr)) \
16018 + break; \
16019 + if (type != VERIFY_WRITE) { \
16020 + __addr = __addr_ao; \
16021 + continue; \
16022 + } \
16023 + if (__put_user(__c_ao, (char __user *)__addr)) \
16024 + break; \
16025 + __addr = __addr_ao; \
16026 + } \
16027 + } \
16028 + __ret_ao; \
16029 +})
16030
16031 /*
16032 * The exception table consists of pairs of addresses relative to the
16033 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
16034 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
16035 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
16036
16037 -
16038 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16039 +#define __copyuser_seg "gs;"
16040 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
16041 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16042 +#else
16043 +#define __copyuser_seg
16044 +#define __COPYUSER_SET_ES
16045 +#define __COPYUSER_RESTORE_ES
16046 +#endif
16047
16048 #ifdef CONFIG_X86_32
16049 #define __put_user_asm_u64(x, addr, err, errret) \
16050 asm volatile(ASM_STAC "\n" \
16051 - "1: movl %%eax,0(%2)\n" \
16052 - "2: movl %%edx,4(%2)\n" \
16053 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16054 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16055 "3: " ASM_CLAC "\n" \
16056 ".section .fixup,\"ax\"\n" \
16057 "4: movl %3,%0\n" \
16058 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16059
16060 #define __put_user_asm_ex_u64(x, addr) \
16061 asm volatile(ASM_STAC "\n" \
16062 - "1: movl %%eax,0(%1)\n" \
16063 - "2: movl %%edx,4(%1)\n" \
16064 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16065 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16066 "3: " ASM_CLAC "\n" \
16067 _ASM_EXTABLE_EX(1b, 2b) \
16068 _ASM_EXTABLE_EX(2b, 3b) \
16069 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16070 __typeof__(*(ptr)) __pu_val; \
16071 __chk_user_ptr(ptr); \
16072 might_fault(); \
16073 - __pu_val = x; \
16074 + __pu_val = (x); \
16075 switch (sizeof(*(ptr))) { \
16076 case 1: \
16077 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16078 @@ -358,7 +397,7 @@ do { \
16079
16080 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16081 asm volatile(ASM_STAC "\n" \
16082 - "1: mov"itype" %2,%"rtype"1\n" \
16083 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16084 "2: " ASM_CLAC "\n" \
16085 ".section .fixup,\"ax\"\n" \
16086 "3: mov %3,%0\n" \
16087 @@ -366,7 +405,7 @@ do { \
16088 " jmp 2b\n" \
16089 ".previous\n" \
16090 _ASM_EXTABLE(1b, 3b) \
16091 - : "=r" (err), ltype(x) \
16092 + : "=r" (err), ltype (x) \
16093 : "m" (__m(addr)), "i" (errret), "0" (err))
16094
16095 #define __get_user_size_ex(x, ptr, size) \
16096 @@ -391,7 +430,7 @@ do { \
16097 } while (0)
16098
16099 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16100 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16101 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16102 "2:\n" \
16103 _ASM_EXTABLE_EX(1b, 2b) \
16104 : ltype(x) : "m" (__m(addr)))
16105 @@ -408,13 +447,24 @@ do { \
16106 int __gu_err; \
16107 unsigned long __gu_val; \
16108 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16109 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16110 + (x) = (__typeof__(*(ptr)))__gu_val; \
16111 __gu_err; \
16112 })
16113
16114 /* FIXME: this hack is definitely wrong -AK */
16115 struct __large_struct { unsigned long buf[100]; };
16116 -#define __m(x) (*(struct __large_struct __user *)(x))
16117 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16118 +#define ____m(x) \
16119 +({ \
16120 + unsigned long ____x = (unsigned long)(x); \
16121 + if (____x < PAX_USER_SHADOW_BASE) \
16122 + ____x += PAX_USER_SHADOW_BASE; \
16123 + (void __user *)____x; \
16124 +})
16125 +#else
16126 +#define ____m(x) (x)
16127 +#endif
16128 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16129
16130 /*
16131 * Tell gcc we read from memory instead of writing: this is because
16132 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16133 */
16134 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16135 asm volatile(ASM_STAC "\n" \
16136 - "1: mov"itype" %"rtype"1,%2\n" \
16137 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16138 "2: " ASM_CLAC "\n" \
16139 ".section .fixup,\"ax\"\n" \
16140 "3: mov %3,%0\n" \
16141 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16142 ".previous\n" \
16143 _ASM_EXTABLE(1b, 3b) \
16144 : "=r"(err) \
16145 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16146 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16147
16148 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16149 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16150 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16151 "2:\n" \
16152 _ASM_EXTABLE_EX(1b, 2b) \
16153 : : ltype(x), "m" (__m(addr)))
16154 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16155 * On error, the variable @x is set to zero.
16156 */
16157
16158 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16159 +#define __get_user(x, ptr) get_user((x), (ptr))
16160 +#else
16161 #define __get_user(x, ptr) \
16162 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16163 +#endif
16164
16165 /**
16166 * __put_user: - Write a simple value into user space, with less checking.
16167 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16168 * Returns zero on success, or -EFAULT on error.
16169 */
16170
16171 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16172 +#define __put_user(x, ptr) put_user((x), (ptr))
16173 +#else
16174 #define __put_user(x, ptr) \
16175 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16176 +#endif
16177
16178 #define __get_user_unaligned __get_user
16179 #define __put_user_unaligned __put_user
16180 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16181 #define get_user_ex(x, ptr) do { \
16182 unsigned long __gue_val; \
16183 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16184 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16185 + (x) = (__typeof__(*(ptr)))__gue_val; \
16186 } while (0)
16187
16188 #define put_user_try uaccess_try
16189 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16190 extern __must_check long strlen_user(const char __user *str);
16191 extern __must_check long strnlen_user(const char __user *str, long n);
16192
16193 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16194 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16195 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16196 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16197
16198 /*
16199 * movsl can be slow when source and dest are not both 8-byte aligned
16200 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16201 index 7f760a9..04b1c65 100644
16202 --- a/arch/x86/include/asm/uaccess_32.h
16203 +++ b/arch/x86/include/asm/uaccess_32.h
16204 @@ -11,15 +11,15 @@
16205 #include <asm/page.h>
16206
16207 unsigned long __must_check __copy_to_user_ll
16208 - (void __user *to, const void *from, unsigned long n);
16209 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16210 unsigned long __must_check __copy_from_user_ll
16211 - (void *to, const void __user *from, unsigned long n);
16212 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16213 unsigned long __must_check __copy_from_user_ll_nozero
16214 - (void *to, const void __user *from, unsigned long n);
16215 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16216 unsigned long __must_check __copy_from_user_ll_nocache
16217 - (void *to, const void __user *from, unsigned long n);
16218 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16219 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16220 - (void *to, const void __user *from, unsigned long n);
16221 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16222
16223 /**
16224 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16225 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16226 static __always_inline unsigned long __must_check
16227 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16228 {
16229 + if ((long)n < 0)
16230 + return n;
16231 +
16232 + check_object_size(from, n, true);
16233 +
16234 if (__builtin_constant_p(n)) {
16235 unsigned long ret;
16236
16237 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16238 __copy_to_user(void __user *to, const void *from, unsigned long n)
16239 {
16240 might_fault();
16241 +
16242 return __copy_to_user_inatomic(to, from, n);
16243 }
16244
16245 static __always_inline unsigned long
16246 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16247 {
16248 + if ((long)n < 0)
16249 + return n;
16250 +
16251 /* Avoid zeroing the tail if the copy fails..
16252 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16253 * but as the zeroing behaviour is only significant when n is not
16254 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16255 __copy_from_user(void *to, const void __user *from, unsigned long n)
16256 {
16257 might_fault();
16258 +
16259 + if ((long)n < 0)
16260 + return n;
16261 +
16262 + check_object_size(to, n, false);
16263 +
16264 if (__builtin_constant_p(n)) {
16265 unsigned long ret;
16266
16267 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16268 const void __user *from, unsigned long n)
16269 {
16270 might_fault();
16271 +
16272 + if ((long)n < 0)
16273 + return n;
16274 +
16275 if (__builtin_constant_p(n)) {
16276 unsigned long ret;
16277
16278 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16279 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16280 unsigned long n)
16281 {
16282 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16283 + if ((long)n < 0)
16284 + return n;
16285 +
16286 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16287 }
16288
16289 -unsigned long __must_check copy_to_user(void __user *to,
16290 - const void *from, unsigned long n);
16291 -unsigned long __must_check _copy_from_user(void *to,
16292 - const void __user *from,
16293 - unsigned long n);
16294 -
16295 +extern void copy_to_user_overflow(void)
16296 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16297 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16298 +#else
16299 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16300 +#endif
16301 +;
16302
16303 extern void copy_from_user_overflow(void)
16304 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16305 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16306 #endif
16307 ;
16308
16309 -static inline unsigned long __must_check copy_from_user(void *to,
16310 - const void __user *from,
16311 - unsigned long n)
16312 +/**
16313 + * copy_to_user: - Copy a block of data into user space.
16314 + * @to: Destination address, in user space.
16315 + * @from: Source address, in kernel space.
16316 + * @n: Number of bytes to copy.
16317 + *
16318 + * Context: User context only. This function may sleep.
16319 + *
16320 + * Copy data from kernel space to user space.
16321 + *
16322 + * Returns number of bytes that could not be copied.
16323 + * On success, this will be zero.
16324 + */
16325 +static inline unsigned long __must_check
16326 +copy_to_user(void __user *to, const void *from, unsigned long n)
16327 {
16328 - int sz = __compiletime_object_size(to);
16329 + size_t sz = __compiletime_object_size(from);
16330
16331 - if (likely(sz == -1 || sz >= n))
16332 - n = _copy_from_user(to, from, n);
16333 - else
16334 + if (unlikely(sz != (size_t)-1 && sz < n))
16335 + copy_to_user_overflow();
16336 + else if (access_ok(VERIFY_WRITE, to, n))
16337 + n = __copy_to_user(to, from, n);
16338 + return n;
16339 +}
16340 +
16341 +/**
16342 + * copy_from_user: - Copy a block of data from user space.
16343 + * @to: Destination address, in kernel space.
16344 + * @from: Source address, in user space.
16345 + * @n: Number of bytes to copy.
16346 + *
16347 + * Context: User context only. This function may sleep.
16348 + *
16349 + * Copy data from user space to kernel space.
16350 + *
16351 + * Returns number of bytes that could not be copied.
16352 + * On success, this will be zero.
16353 + *
16354 + * If some data could not be copied, this function will pad the copied
16355 + * data to the requested size using zero bytes.
16356 + */
16357 +static inline unsigned long __must_check
16358 +copy_from_user(void *to, const void __user *from, unsigned long n)
16359 +{
16360 + size_t sz = __compiletime_object_size(to);
16361 +
16362 + check_object_size(to, n, false);
16363 +
16364 + if (unlikely(sz != (size_t)-1 && sz < n))
16365 copy_from_user_overflow();
16366 -
16367 + else if (access_ok(VERIFY_READ, from, n))
16368 + n = __copy_from_user(to, from, n);
16369 + else if ((long)n > 0)
16370 + memset(to, 0, n);
16371 return n;
16372 }
16373
16374 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16375 index 142810c..1f2a0a7 100644
16376 --- a/arch/x86/include/asm/uaccess_64.h
16377 +++ b/arch/x86/include/asm/uaccess_64.h
16378 @@ -10,6 +10,9 @@
16379 #include <asm/alternative.h>
16380 #include <asm/cpufeature.h>
16381 #include <asm/page.h>
16382 +#include <asm/pgtable.h>
16383 +
16384 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16385
16386 /*
16387 * Copy To/From Userspace
16388 @@ -17,13 +20,13 @@
16389
16390 /* Handles exceptions in both to and from, but doesn't do access_ok */
16391 __must_check unsigned long
16392 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16393 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16394 __must_check unsigned long
16395 -copy_user_generic_string(void *to, const void *from, unsigned len);
16396 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16397 __must_check unsigned long
16398 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16399 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16400
16401 -static __always_inline __must_check unsigned long
16402 +static __always_inline __must_check __size_overflow(3) unsigned long
16403 copy_user_generic(void *to, const void *from, unsigned len)
16404 {
16405 unsigned ret;
16406 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16407 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16408 "=d" (len)),
16409 "1" (to), "2" (from), "3" (len)
16410 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16411 + : "memory", "rcx", "r8", "r9", "r11");
16412 return ret;
16413 }
16414
16415 +static __always_inline __must_check unsigned long
16416 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16417 +static __always_inline __must_check unsigned long
16418 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16419 __must_check unsigned long
16420 -_copy_to_user(void __user *to, const void *from, unsigned len);
16421 -__must_check unsigned long
16422 -_copy_from_user(void *to, const void __user *from, unsigned len);
16423 -__must_check unsigned long
16424 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16425 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16426 +
16427 +extern void copy_to_user_overflow(void)
16428 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16429 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16430 +#else
16431 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16432 +#endif
16433 +;
16434 +
16435 +extern void copy_from_user_overflow(void)
16436 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16437 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16438 +#else
16439 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16440 +#endif
16441 +;
16442
16443 static inline unsigned long __must_check copy_from_user(void *to,
16444 const void __user *from,
16445 unsigned long n)
16446 {
16447 - int sz = __compiletime_object_size(to);
16448 -
16449 might_fault();
16450 - if (likely(sz == -1 || sz >= n))
16451 - n = _copy_from_user(to, from, n);
16452 -#ifdef CONFIG_DEBUG_VM
16453 - else
16454 - WARN(1, "Buffer overflow detected!\n");
16455 -#endif
16456 +
16457 + check_object_size(to, n, false);
16458 +
16459 + if (access_ok(VERIFY_READ, from, n))
16460 + n = __copy_from_user(to, from, n);
16461 + else if (n < INT_MAX)
16462 + memset(to, 0, n);
16463 return n;
16464 }
16465
16466 static __always_inline __must_check
16467 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16468 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16469 {
16470 might_fault();
16471
16472 - return _copy_to_user(dst, src, size);
16473 + if (access_ok(VERIFY_WRITE, dst, size))
16474 + size = __copy_to_user(dst, src, size);
16475 + return size;
16476 }
16477
16478 static __always_inline __must_check
16479 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16480 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16481 {
16482 - int ret = 0;
16483 + size_t sz = __compiletime_object_size(dst);
16484 + unsigned ret = 0;
16485
16486 might_fault();
16487 +
16488 + if (size > INT_MAX)
16489 + return size;
16490 +
16491 + check_object_size(dst, size, false);
16492 +
16493 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16494 + if (!__access_ok(VERIFY_READ, src, size))
16495 + return size;
16496 +#endif
16497 +
16498 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16499 + copy_from_user_overflow();
16500 + return size;
16501 + }
16502 +
16503 if (!__builtin_constant_p(size))
16504 - return copy_user_generic(dst, (__force void *)src, size);
16505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16506 switch (size) {
16507 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16508 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16509 ret, "b", "b", "=q", 1);
16510 return ret;
16511 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16512 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16513 ret, "w", "w", "=r", 2);
16514 return ret;
16515 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16516 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16517 ret, "l", "k", "=r", 4);
16518 return ret;
16519 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16520 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16521 ret, "q", "", "=r", 8);
16522 return ret;
16523 case 10:
16524 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16525 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16526 ret, "q", "", "=r", 10);
16527 if (unlikely(ret))
16528 return ret;
16529 __get_user_asm(*(u16 *)(8 + (char *)dst),
16530 - (u16 __user *)(8 + (char __user *)src),
16531 + (const u16 __user *)(8 + (const char __user *)src),
16532 ret, "w", "w", "=r", 2);
16533 return ret;
16534 case 16:
16535 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16536 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16537 ret, "q", "", "=r", 16);
16538 if (unlikely(ret))
16539 return ret;
16540 __get_user_asm(*(u64 *)(8 + (char *)dst),
16541 - (u64 __user *)(8 + (char __user *)src),
16542 + (const u64 __user *)(8 + (const char __user *)src),
16543 ret, "q", "", "=r", 8);
16544 return ret;
16545 default:
16546 - return copy_user_generic(dst, (__force void *)src, size);
16547 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16548 }
16549 }
16550
16551 static __always_inline __must_check
16552 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16553 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16554 {
16555 - int ret = 0;
16556 + size_t sz = __compiletime_object_size(src);
16557 + unsigned ret = 0;
16558
16559 might_fault();
16560 +
16561 + if (size > INT_MAX)
16562 + return size;
16563 +
16564 + check_object_size(src, size, true);
16565 +
16566 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16567 + if (!__access_ok(VERIFY_WRITE, dst, size))
16568 + return size;
16569 +#endif
16570 +
16571 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16572 + copy_to_user_overflow();
16573 + return size;
16574 + }
16575 +
16576 if (!__builtin_constant_p(size))
16577 - return copy_user_generic((__force void *)dst, src, size);
16578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16579 switch (size) {
16580 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16581 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16582 ret, "b", "b", "iq", 1);
16583 return ret;
16584 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16585 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16586 ret, "w", "w", "ir", 2);
16587 return ret;
16588 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16589 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16590 ret, "l", "k", "ir", 4);
16591 return ret;
16592 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16593 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16594 ret, "q", "", "er", 8);
16595 return ret;
16596 case 10:
16597 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16598 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16599 ret, "q", "", "er", 10);
16600 if (unlikely(ret))
16601 return ret;
16602 asm("":::"memory");
16603 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16604 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16605 ret, "w", "w", "ir", 2);
16606 return ret;
16607 case 16:
16608 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16609 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16610 ret, "q", "", "er", 16);
16611 if (unlikely(ret))
16612 return ret;
16613 asm("":::"memory");
16614 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16615 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16616 ret, "q", "", "er", 8);
16617 return ret;
16618 default:
16619 - return copy_user_generic((__force void *)dst, src, size);
16620 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16621 }
16622 }
16623
16624 static __always_inline __must_check
16625 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16626 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16627 {
16628 - int ret = 0;
16629 + unsigned ret = 0;
16630
16631 might_fault();
16632 +
16633 + if (size > INT_MAX)
16634 + return size;
16635 +
16636 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16637 + if (!__access_ok(VERIFY_READ, src, size))
16638 + return size;
16639 + if (!__access_ok(VERIFY_WRITE, dst, size))
16640 + return size;
16641 +#endif
16642 +
16643 if (!__builtin_constant_p(size))
16644 - return copy_user_generic((__force void *)dst,
16645 - (__force void *)src, size);
16646 + return copy_user_generic((__force_kernel void *)____m(dst),
16647 + (__force_kernel const void *)____m(src), size);
16648 switch (size) {
16649 case 1: {
16650 u8 tmp;
16651 - __get_user_asm(tmp, (u8 __user *)src,
16652 + __get_user_asm(tmp, (const u8 __user *)src,
16653 ret, "b", "b", "=q", 1);
16654 if (likely(!ret))
16655 __put_user_asm(tmp, (u8 __user *)dst,
16656 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16657 }
16658 case 2: {
16659 u16 tmp;
16660 - __get_user_asm(tmp, (u16 __user *)src,
16661 + __get_user_asm(tmp, (const u16 __user *)src,
16662 ret, "w", "w", "=r", 2);
16663 if (likely(!ret))
16664 __put_user_asm(tmp, (u16 __user *)dst,
16665 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16666
16667 case 4: {
16668 u32 tmp;
16669 - __get_user_asm(tmp, (u32 __user *)src,
16670 + __get_user_asm(tmp, (const u32 __user *)src,
16671 ret, "l", "k", "=r", 4);
16672 if (likely(!ret))
16673 __put_user_asm(tmp, (u32 __user *)dst,
16674 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16675 }
16676 case 8: {
16677 u64 tmp;
16678 - __get_user_asm(tmp, (u64 __user *)src,
16679 + __get_user_asm(tmp, (const u64 __user *)src,
16680 ret, "q", "", "=r", 8);
16681 if (likely(!ret))
16682 __put_user_asm(tmp, (u64 __user *)dst,
16683 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16684 return ret;
16685 }
16686 default:
16687 - return copy_user_generic((__force void *)dst,
16688 - (__force void *)src, size);
16689 + return copy_user_generic((__force_kernel void *)____m(dst),
16690 + (__force_kernel const void *)____m(src), size);
16691 }
16692 }
16693
16694 static __must_check __always_inline int
16695 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16696 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16697 {
16698 - return copy_user_generic(dst, (__force const void *)src, size);
16699 + if (size > INT_MAX)
16700 + return size;
16701 +
16702 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16703 + if (!__access_ok(VERIFY_READ, src, size))
16704 + return size;
16705 +#endif
16706 +
16707 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16708 }
16709
16710 -static __must_check __always_inline int
16711 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16712 +static __must_check __always_inline unsigned long
16713 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16714 {
16715 - return copy_user_generic((__force void *)dst, src, size);
16716 + if (size > INT_MAX)
16717 + return size;
16718 +
16719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16720 + if (!__access_ok(VERIFY_WRITE, dst, size))
16721 + return size;
16722 +#endif
16723 +
16724 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16725 }
16726
16727 -extern long __copy_user_nocache(void *dst, const void __user *src,
16728 - unsigned size, int zerorest);
16729 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16730 + unsigned long size, int zerorest) __size_overflow(3);
16731
16732 -static inline int
16733 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16734 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16735 {
16736 might_sleep();
16737 +
16738 + if (size > INT_MAX)
16739 + return size;
16740 +
16741 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16742 + if (!__access_ok(VERIFY_READ, src, size))
16743 + return size;
16744 +#endif
16745 +
16746 return __copy_user_nocache(dst, src, size, 1);
16747 }
16748
16749 -static inline int
16750 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16751 - unsigned size)
16752 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16753 + unsigned long size)
16754 {
16755 + if (size > INT_MAX)
16756 + return size;
16757 +
16758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16759 + if (!__access_ok(VERIFY_READ, src, size))
16760 + return size;
16761 +#endif
16762 +
16763 return __copy_user_nocache(dst, src, size, 0);
16764 }
16765
16766 -unsigned long
16767 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16768 +extern unsigned long
16769 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16770
16771 #endif /* _ASM_X86_UACCESS_64_H */
16772 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16773 index 5b238981..77fdd78 100644
16774 --- a/arch/x86/include/asm/word-at-a-time.h
16775 +++ b/arch/x86/include/asm/word-at-a-time.h
16776 @@ -11,7 +11,7 @@
16777 * and shift, for example.
16778 */
16779 struct word_at_a_time {
16780 - const unsigned long one_bits, high_bits;
16781 + unsigned long one_bits, high_bits;
16782 };
16783
16784 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16785 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16786 index 5769349..a3d3e2a 100644
16787 --- a/arch/x86/include/asm/x86_init.h
16788 +++ b/arch/x86/include/asm/x86_init.h
16789 @@ -141,7 +141,7 @@ struct x86_init_ops {
16790 struct x86_init_timers timers;
16791 struct x86_init_iommu iommu;
16792 struct x86_init_pci pci;
16793 -};
16794 +} __no_const;
16795
16796 /**
16797 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16798 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16799 void (*setup_percpu_clockev)(void);
16800 void (*early_percpu_clock_init)(void);
16801 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16802 -};
16803 +} __no_const;
16804
16805 /**
16806 * struct x86_platform_ops - platform specific runtime functions
16807 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16808 void (*save_sched_clock_state)(void);
16809 void (*restore_sched_clock_state)(void);
16810 void (*apic_post_init)(void);
16811 -};
16812 +} __no_const;
16813
16814 struct pci_dev;
16815
16816 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16817 void (*teardown_msi_irq)(unsigned int irq);
16818 void (*teardown_msi_irqs)(struct pci_dev *dev);
16819 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16820 -};
16821 +} __no_const;
16822
16823 struct x86_io_apic_ops {
16824 void (*init) (void);
16825 unsigned int (*read) (unsigned int apic, unsigned int reg);
16826 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16827 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16828 -};
16829 +} __no_const;
16830
16831 extern struct x86_init_ops x86_init;
16832 extern struct x86_cpuinit_ops x86_cpuinit;
16833 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16834 index 0415cda..b43d877 100644
16835 --- a/arch/x86/include/asm/xsave.h
16836 +++ b/arch/x86/include/asm/xsave.h
16837 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16838 return -EFAULT;
16839
16840 __asm__ __volatile__(ASM_STAC "\n"
16841 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16842 + "1:"
16843 + __copyuser_seg
16844 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16845 "2: " ASM_CLAC "\n"
16846 ".section .fixup,\"ax\"\n"
16847 "3: movl $-1,%[err]\n"
16848 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16849 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16850 {
16851 int err;
16852 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16853 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16854 u32 lmask = mask;
16855 u32 hmask = mask >> 32;
16856
16857 __asm__ __volatile__(ASM_STAC "\n"
16858 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16859 + "1:"
16860 + __copyuser_seg
16861 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16862 "2: " ASM_CLAC "\n"
16863 ".section .fixup,\"ax\"\n"
16864 "3: movl $-1,%[err]\n"
16865 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16866 index bbae024..e1528f9 100644
16867 --- a/arch/x86/include/uapi/asm/e820.h
16868 +++ b/arch/x86/include/uapi/asm/e820.h
16869 @@ -63,7 +63,7 @@ struct e820map {
16870 #define ISA_START_ADDRESS 0xa0000
16871 #define ISA_END_ADDRESS 0x100000
16872
16873 -#define BIOS_BEGIN 0x000a0000
16874 +#define BIOS_BEGIN 0x000c0000
16875 #define BIOS_END 0x00100000
16876
16877 #define BIOS_ROM_BASE 0xffe00000
16878 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16879 index 34e923a..0c6bb6e 100644
16880 --- a/arch/x86/kernel/Makefile
16881 +++ b/arch/x86/kernel/Makefile
16882 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16883 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16884 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16885 obj-y += probe_roms.o
16886 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16887 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16888 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16889 obj-y += syscall_$(BITS).o
16890 obj-$(CONFIG_X86_64) += vsyscall_64.o
16891 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16892 index bacf4b0..4ede72e 100644
16893 --- a/arch/x86/kernel/acpi/boot.c
16894 +++ b/arch/x86/kernel/acpi/boot.c
16895 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16896 * If your system is blacklisted here, but you find that acpi=force
16897 * works for you, please contact linux-acpi@vger.kernel.org
16898 */
16899 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16900 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16901 /*
16902 * Boxes that need ACPI disabled
16903 */
16904 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16905 };
16906
16907 /* second table for DMI checks that should run after early-quirks */
16908 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16909 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16910 /*
16911 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16912 * which includes some code which overrides all temperature
16913 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16914 index d5e0d71..6533e08 100644
16915 --- a/arch/x86/kernel/acpi/sleep.c
16916 +++ b/arch/x86/kernel/acpi/sleep.c
16917 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16918 #else /* CONFIG_64BIT */
16919 #ifdef CONFIG_SMP
16920 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16921 +
16922 + pax_open_kernel();
16923 early_gdt_descr.address =
16924 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16925 + pax_close_kernel();
16926 +
16927 initial_gs = per_cpu_offset(smp_processor_id());
16928 #endif
16929 initial_code = (unsigned long)wakeup_long64;
16930 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16931 index 13ab720..95d5442 100644
16932 --- a/arch/x86/kernel/acpi/wakeup_32.S
16933 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16934 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16935 # and restore the stack ... but you need gdt for this to work
16936 movl saved_context_esp, %esp
16937
16938 - movl %cs:saved_magic, %eax
16939 - cmpl $0x12345678, %eax
16940 + cmpl $0x12345678, saved_magic
16941 jne bogus_magic
16942
16943 # jump to place where we left off
16944 - movl saved_eip, %eax
16945 - jmp *%eax
16946 + jmp *(saved_eip)
16947
16948 bogus_magic:
16949 jmp bogus_magic
16950 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16951 index ef5ccca..bd83949 100644
16952 --- a/arch/x86/kernel/alternative.c
16953 +++ b/arch/x86/kernel/alternative.c
16954 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16955 */
16956 for (a = start; a < end; a++) {
16957 instr = (u8 *)&a->instr_offset + a->instr_offset;
16958 +
16959 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16960 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16961 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16962 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16963 +#endif
16964 +
16965 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16966 BUG_ON(a->replacementlen > a->instrlen);
16967 BUG_ON(a->instrlen > sizeof(insnbuf));
16968 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16969 for (poff = start; poff < end; poff++) {
16970 u8 *ptr = (u8 *)poff + *poff;
16971
16972 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16973 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16974 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16975 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16976 +#endif
16977 +
16978 if (!*poff || ptr < text || ptr >= text_end)
16979 continue;
16980 /* turn DS segment override prefix into lock prefix */
16981 - if (*ptr == 0x3e)
16982 + if (*ktla_ktva(ptr) == 0x3e)
16983 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16984 }
16985 mutex_unlock(&text_mutex);
16986 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16987 for (poff = start; poff < end; poff++) {
16988 u8 *ptr = (u8 *)poff + *poff;
16989
16990 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16991 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16992 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16993 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16994 +#endif
16995 +
16996 if (!*poff || ptr < text || ptr >= text_end)
16997 continue;
16998 /* turn lock prefix into DS segment override prefix */
16999 - if (*ptr == 0xf0)
17000 + if (*ktla_ktva(ptr) == 0xf0)
17001 text_poke(ptr, ((unsigned char []){0x3E}), 1);
17002 }
17003 mutex_unlock(&text_mutex);
17004 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
17005
17006 BUG_ON(p->len > MAX_PATCH_LEN);
17007 /* prep the buffer with the original instructions */
17008 - memcpy(insnbuf, p->instr, p->len);
17009 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
17010 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
17011 (unsigned long)p->instr, p->len);
17012
17013 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
17014 if (!uniproc_patched || num_possible_cpus() == 1)
17015 free_init_pages("SMP alternatives",
17016 (unsigned long)__smp_locks,
17017 - (unsigned long)__smp_locks_end);
17018 + PAGE_ALIGN((unsigned long)__smp_locks_end));
17019 #endif
17020
17021 apply_paravirt(__parainstructions, __parainstructions_end);
17022 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
17023 * instructions. And on the local CPU you need to be protected again NMI or MCE
17024 * handlers seeing an inconsistent instruction while you patch.
17025 */
17026 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
17027 +void *__kprobes text_poke_early(void *addr, const void *opcode,
17028 size_t len)
17029 {
17030 unsigned long flags;
17031 local_irq_save(flags);
17032 - memcpy(addr, opcode, len);
17033 +
17034 + pax_open_kernel();
17035 + memcpy(ktla_ktva(addr), opcode, len);
17036 sync_core();
17037 + pax_close_kernel();
17038 +
17039 local_irq_restore(flags);
17040 /* Could also do a CLFLUSH here to speed up CPU recovery; but
17041 that causes hangs on some VIA CPUs. */
17042 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
17043 */
17044 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
17045 {
17046 - unsigned long flags;
17047 - char *vaddr;
17048 + unsigned char *vaddr = ktla_ktva(addr);
17049 struct page *pages[2];
17050 - int i;
17051 + size_t i;
17052
17053 if (!core_kernel_text((unsigned long)addr)) {
17054 - pages[0] = vmalloc_to_page(addr);
17055 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17056 + pages[0] = vmalloc_to_page(vaddr);
17057 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17058 } else {
17059 - pages[0] = virt_to_page(addr);
17060 + pages[0] = virt_to_page(vaddr);
17061 WARN_ON(!PageReserved(pages[0]));
17062 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17063 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17064 }
17065 BUG_ON(!pages[0]);
17066 - local_irq_save(flags);
17067 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17068 - if (pages[1])
17069 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17070 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17071 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17072 - clear_fixmap(FIX_TEXT_POKE0);
17073 - if (pages[1])
17074 - clear_fixmap(FIX_TEXT_POKE1);
17075 - local_flush_tlb();
17076 - sync_core();
17077 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17078 - that causes hangs on some VIA CPUs. */
17079 + text_poke_early(addr, opcode, len);
17080 for (i = 0; i < len; i++)
17081 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17082 - local_irq_restore(flags);
17083 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17084 return addr;
17085 }
17086
17087 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17088 index cbf5121..812b537 100644
17089 --- a/arch/x86/kernel/apic/apic.c
17090 +++ b/arch/x86/kernel/apic/apic.c
17091 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17092 /*
17093 * Debug level, exported for io_apic.c
17094 */
17095 -unsigned int apic_verbosity;
17096 +int apic_verbosity;
17097
17098 int pic_mode;
17099
17100 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17101 apic_write(APIC_ESR, 0);
17102 v1 = apic_read(APIC_ESR);
17103 ack_APIC_irq();
17104 - atomic_inc(&irq_err_count);
17105 + atomic_inc_unchecked(&irq_err_count);
17106
17107 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17108 smp_processor_id(), v0 , v1);
17109 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17110 index 00c77cf..2dc6a2d 100644
17111 --- a/arch/x86/kernel/apic/apic_flat_64.c
17112 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17113 @@ -157,7 +157,7 @@ static int flat_probe(void)
17114 return 1;
17115 }
17116
17117 -static struct apic apic_flat = {
17118 +static struct apic apic_flat __read_only = {
17119 .name = "flat",
17120 .probe = flat_probe,
17121 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17122 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17123 return 0;
17124 }
17125
17126 -static struct apic apic_physflat = {
17127 +static struct apic apic_physflat __read_only = {
17128
17129 .name = "physical flat",
17130 .probe = physflat_probe,
17131 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17132 index e145f28..2752888 100644
17133 --- a/arch/x86/kernel/apic/apic_noop.c
17134 +++ b/arch/x86/kernel/apic/apic_noop.c
17135 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17136 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17137 }
17138
17139 -struct apic apic_noop = {
17140 +struct apic apic_noop __read_only = {
17141 .name = "noop",
17142 .probe = noop_probe,
17143 .acpi_madt_oem_check = NULL,
17144 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17145 index d50e364..543bee3 100644
17146 --- a/arch/x86/kernel/apic/bigsmp_32.c
17147 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17148 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17149 return dmi_bigsmp;
17150 }
17151
17152 -static struct apic apic_bigsmp = {
17153 +static struct apic apic_bigsmp __read_only = {
17154
17155 .name = "bigsmp",
17156 .probe = probe_bigsmp,
17157 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17158 index 0874799..a7a7892 100644
17159 --- a/arch/x86/kernel/apic/es7000_32.c
17160 +++ b/arch/x86/kernel/apic/es7000_32.c
17161 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17162 return ret && es7000_apic_is_cluster();
17163 }
17164
17165 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17166 -static struct apic __refdata apic_es7000_cluster = {
17167 +static struct apic apic_es7000_cluster __read_only = {
17168
17169 .name = "es7000",
17170 .probe = probe_es7000,
17171 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17172 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17173 };
17174
17175 -static struct apic __refdata apic_es7000 = {
17176 +static struct apic apic_es7000 __read_only = {
17177
17178 .name = "es7000",
17179 .probe = probe_es7000,
17180 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17181 index b739d39..aebc14c 100644
17182 --- a/arch/x86/kernel/apic/io_apic.c
17183 +++ b/arch/x86/kernel/apic/io_apic.c
17184 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17185 }
17186 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17187
17188 -void lock_vector_lock(void)
17189 +void lock_vector_lock(void) __acquires(vector_lock)
17190 {
17191 /* Used to the online set of cpus does not change
17192 * during assign_irq_vector.
17193 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17194 raw_spin_lock(&vector_lock);
17195 }
17196
17197 -void unlock_vector_lock(void)
17198 +void unlock_vector_lock(void) __releases(vector_lock)
17199 {
17200 raw_spin_unlock(&vector_lock);
17201 }
17202 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17203 ack_APIC_irq();
17204 }
17205
17206 -atomic_t irq_mis_count;
17207 +atomic_unchecked_t irq_mis_count;
17208
17209 #ifdef CONFIG_GENERIC_PENDING_IRQ
17210 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17211 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17212 * at the cpu.
17213 */
17214 if (!(v & (1 << (i & 0x1f)))) {
17215 - atomic_inc(&irq_mis_count);
17216 + atomic_inc_unchecked(&irq_mis_count);
17217
17218 eoi_ioapic_irq(irq, cfg);
17219 }
17220 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17221
17222 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17223 {
17224 - chip->irq_print_chip = ir_print_prefix;
17225 - chip->irq_ack = ir_ack_apic_edge;
17226 - chip->irq_eoi = ir_ack_apic_level;
17227 + pax_open_kernel();
17228 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17229 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17230 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17231
17232 - chip->irq_set_affinity = set_remapped_irq_affinity;
17233 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17234 + pax_close_kernel();
17235 }
17236 #endif /* CONFIG_IRQ_REMAP */
17237
17238 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17239 index d661ee9..791fd33 100644
17240 --- a/arch/x86/kernel/apic/numaq_32.c
17241 +++ b/arch/x86/kernel/apic/numaq_32.c
17242 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17243 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17244 }
17245
17246 -/* Use __refdata to keep false positive warning calm. */
17247 -static struct apic __refdata apic_numaq = {
17248 +static struct apic apic_numaq __read_only = {
17249
17250 .name = "NUMAQ",
17251 .probe = probe_numaq,
17252 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17253 index eb35ef9..f184a21 100644
17254 --- a/arch/x86/kernel/apic/probe_32.c
17255 +++ b/arch/x86/kernel/apic/probe_32.c
17256 @@ -72,7 +72,7 @@ static int probe_default(void)
17257 return 1;
17258 }
17259
17260 -static struct apic apic_default = {
17261 +static struct apic apic_default __read_only = {
17262
17263 .name = "default",
17264 .probe = probe_default,
17265 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17266 index 77c95c0..434f8a4 100644
17267 --- a/arch/x86/kernel/apic/summit_32.c
17268 +++ b/arch/x86/kernel/apic/summit_32.c
17269 @@ -486,7 +486,7 @@ void setup_summit(void)
17270 }
17271 #endif
17272
17273 -static struct apic apic_summit = {
17274 +static struct apic apic_summit __read_only = {
17275
17276 .name = "summit",
17277 .probe = probe_summit,
17278 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17279 index c88baa4..757aee1 100644
17280 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17281 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17282 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17283 return notifier_from_errno(err);
17284 }
17285
17286 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17287 +static struct notifier_block x2apic_cpu_notifier = {
17288 .notifier_call = update_clusterinfo,
17289 };
17290
17291 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17292 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17293 }
17294
17295 -static struct apic apic_x2apic_cluster = {
17296 +static struct apic apic_x2apic_cluster __read_only = {
17297
17298 .name = "cluster x2apic",
17299 .probe = x2apic_cluster_probe,
17300 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17301 index 562a76d..a003c0f 100644
17302 --- a/arch/x86/kernel/apic/x2apic_phys.c
17303 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17304 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17305 return apic == &apic_x2apic_phys;
17306 }
17307
17308 -static struct apic apic_x2apic_phys = {
17309 +static struct apic apic_x2apic_phys __read_only = {
17310
17311 .name = "physical x2apic",
17312 .probe = x2apic_phys_probe,
17313 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17314 index 8cfade9..b9d04fc 100644
17315 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17316 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17317 @@ -333,7 +333,7 @@ static int uv_probe(void)
17318 return apic == &apic_x2apic_uv_x;
17319 }
17320
17321 -static struct apic __refdata apic_x2apic_uv_x = {
17322 +static struct apic apic_x2apic_uv_x __read_only = {
17323
17324 .name = "UV large system",
17325 .probe = uv_probe,
17326 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17327 index d65464e..1035d31 100644
17328 --- a/arch/x86/kernel/apm_32.c
17329 +++ b/arch/x86/kernel/apm_32.c
17330 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17331 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17332 * even though they are called in protected mode.
17333 */
17334 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17335 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17336 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17337
17338 static const char driver_version[] = "1.16ac"; /* no spaces */
17339 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17340 BUG_ON(cpu != 0);
17341 gdt = get_cpu_gdt_table(cpu);
17342 save_desc_40 = gdt[0x40 / 8];
17343 +
17344 + pax_open_kernel();
17345 gdt[0x40 / 8] = bad_bios_desc;
17346 + pax_close_kernel();
17347
17348 apm_irq_save(flags);
17349 APM_DO_SAVE_SEGS;
17350 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17351 &call->esi);
17352 APM_DO_RESTORE_SEGS;
17353 apm_irq_restore(flags);
17354 +
17355 + pax_open_kernel();
17356 gdt[0x40 / 8] = save_desc_40;
17357 + pax_close_kernel();
17358 +
17359 put_cpu();
17360
17361 return call->eax & 0xff;
17362 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17363 BUG_ON(cpu != 0);
17364 gdt = get_cpu_gdt_table(cpu);
17365 save_desc_40 = gdt[0x40 / 8];
17366 +
17367 + pax_open_kernel();
17368 gdt[0x40 / 8] = bad_bios_desc;
17369 + pax_close_kernel();
17370
17371 apm_irq_save(flags);
17372 APM_DO_SAVE_SEGS;
17373 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17374 &call->eax);
17375 APM_DO_RESTORE_SEGS;
17376 apm_irq_restore(flags);
17377 +
17378 + pax_open_kernel();
17379 gdt[0x40 / 8] = save_desc_40;
17380 + pax_close_kernel();
17381 +
17382 put_cpu();
17383 return error;
17384 }
17385 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17386 * code to that CPU.
17387 */
17388 gdt = get_cpu_gdt_table(0);
17389 +
17390 + pax_open_kernel();
17391 set_desc_base(&gdt[APM_CS >> 3],
17392 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17393 set_desc_base(&gdt[APM_CS_16 >> 3],
17394 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17395 set_desc_base(&gdt[APM_DS >> 3],
17396 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17397 + pax_close_kernel();
17398
17399 proc_create("apm", 0, NULL, &apm_file_ops);
17400
17401 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17402 index 2861082..6d4718e 100644
17403 --- a/arch/x86/kernel/asm-offsets.c
17404 +++ b/arch/x86/kernel/asm-offsets.c
17405 @@ -33,6 +33,8 @@ void common(void) {
17406 OFFSET(TI_status, thread_info, status);
17407 OFFSET(TI_addr_limit, thread_info, addr_limit);
17408 OFFSET(TI_preempt_count, thread_info, preempt_count);
17409 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17410 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17411
17412 BLANK();
17413 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17414 @@ -53,8 +55,26 @@ void common(void) {
17415 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17416 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17417 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17418 +
17419 +#ifdef CONFIG_PAX_KERNEXEC
17420 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17421 #endif
17422
17423 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17424 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17425 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17426 +#ifdef CONFIG_X86_64
17427 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17428 +#endif
17429 +#endif
17430 +
17431 +#endif
17432 +
17433 + BLANK();
17434 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17435 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17436 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17437 +
17438 #ifdef CONFIG_XEN
17439 BLANK();
17440 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17441 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17442 index 1b4754f..fbb4227 100644
17443 --- a/arch/x86/kernel/asm-offsets_64.c
17444 +++ b/arch/x86/kernel/asm-offsets_64.c
17445 @@ -76,6 +76,7 @@ int main(void)
17446 BLANK();
17447 #undef ENTRY
17448
17449 + DEFINE(TSS_size, sizeof(struct tss_struct));
17450 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17451 BLANK();
17452
17453 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17454 index a0e067d..9c7db16 100644
17455 --- a/arch/x86/kernel/cpu/Makefile
17456 +++ b/arch/x86/kernel/cpu/Makefile
17457 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17458 CFLAGS_REMOVE_perf_event.o = -pg
17459 endif
17460
17461 -# Make sure load_percpu_segment has no stackprotector
17462 -nostackp := $(call cc-option, -fno-stack-protector)
17463 -CFLAGS_common.o := $(nostackp)
17464 -
17465 obj-y := intel_cacheinfo.o scattered.o topology.o
17466 obj-y += proc.o capflags.o powerflags.o common.o
17467 obj-y += vmware.o hypervisor.o mshyperv.o
17468 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17469 index 15239ff..e23e04e 100644
17470 --- a/arch/x86/kernel/cpu/amd.c
17471 +++ b/arch/x86/kernel/cpu/amd.c
17472 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17473 unsigned int size)
17474 {
17475 /* AMD errata T13 (order #21922) */
17476 - if ((c->x86 == 6)) {
17477 + if (c->x86 == 6) {
17478 /* Duron Rev A0 */
17479 if (c->x86_model == 3 && c->x86_mask == 0)
17480 size = 64;
17481 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17482 index 9c3ab43..51e6366 100644
17483 --- a/arch/x86/kernel/cpu/common.c
17484 +++ b/arch/x86/kernel/cpu/common.c
17485 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17486
17487 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17488
17489 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17490 -#ifdef CONFIG_X86_64
17491 - /*
17492 - * We need valid kernel segments for data and code in long mode too
17493 - * IRET will check the segment types kkeil 2000/10/28
17494 - * Also sysret mandates a special GDT layout
17495 - *
17496 - * TLS descriptors are currently at a different place compared to i386.
17497 - * Hopefully nobody expects them at a fixed place (Wine?)
17498 - */
17499 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17500 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17501 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17502 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17503 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17504 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17505 -#else
17506 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17507 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17508 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17509 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17510 - /*
17511 - * Segments used for calling PnP BIOS have byte granularity.
17512 - * They code segments and data segments have fixed 64k limits,
17513 - * the transfer segment sizes are set at run time.
17514 - */
17515 - /* 32-bit code */
17516 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17517 - /* 16-bit code */
17518 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17519 - /* 16-bit data */
17520 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17521 - /* 16-bit data */
17522 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17523 - /* 16-bit data */
17524 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17525 - /*
17526 - * The APM segments have byte granularity and their bases
17527 - * are set at run time. All have 64k limits.
17528 - */
17529 - /* 32-bit code */
17530 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17531 - /* 16-bit code */
17532 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17533 - /* data */
17534 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17535 -
17536 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17537 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17538 - GDT_STACK_CANARY_INIT
17539 -#endif
17540 -} };
17541 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17542 -
17543 static int __init x86_xsave_setup(char *s)
17544 {
17545 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17546 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17547 {
17548 struct desc_ptr gdt_descr;
17549
17550 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17551 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17552 gdt_descr.size = GDT_SIZE - 1;
17553 load_gdt(&gdt_descr);
17554 /* Reload the per-cpu base */
17555 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17556 /* Filter out anything that depends on CPUID levels we don't have */
17557 filter_cpuid_features(c, true);
17558
17559 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17560 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17561 +#endif
17562 +
17563 /* If the model name is still unset, do table lookup. */
17564 if (!c->x86_model_id[0]) {
17565 const char *p;
17566 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17567 }
17568 __setup("clearcpuid=", setup_disablecpuid);
17569
17570 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17571 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17572 +
17573 #ifdef CONFIG_X86_64
17574 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17575 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17576 - (unsigned long) nmi_idt_table };
17577 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17578
17579 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17580 irq_stack_union) __aligned(PAGE_SIZE);
17581 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17582 EXPORT_PER_CPU_SYMBOL(current_task);
17583
17584 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17585 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17586 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17587 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17588
17589 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17590 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17591 int i;
17592
17593 cpu = stack_smp_processor_id();
17594 - t = &per_cpu(init_tss, cpu);
17595 + t = init_tss + cpu;
17596 oist = &per_cpu(orig_ist, cpu);
17597
17598 #ifdef CONFIG_NUMA
17599 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17600 switch_to_new_gdt(cpu);
17601 loadsegment(fs, 0);
17602
17603 - load_idt((const struct desc_ptr *)&idt_descr);
17604 + load_idt(&idt_descr);
17605
17606 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17607 syscall_init();
17608 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17609 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17610 barrier();
17611
17612 - x86_configure_nx();
17613 enable_x2apic();
17614
17615 /*
17616 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17617 {
17618 int cpu = smp_processor_id();
17619 struct task_struct *curr = current;
17620 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17621 + struct tss_struct *t = init_tss + cpu;
17622 struct thread_struct *thread = &curr->thread;
17623
17624 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17625 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17626 index fcaabd0..7b55a26 100644
17627 --- a/arch/x86/kernel/cpu/intel.c
17628 +++ b/arch/x86/kernel/cpu/intel.c
17629 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17630 * Update the IDT descriptor and reload the IDT so that
17631 * it uses the read-only mapped virtual address.
17632 */
17633 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17634 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17635 load_idt(&idt_descr);
17636 }
17637 #endif
17638 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17639 index 84c1309..39b7224 100644
17640 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17641 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17642 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17643 };
17644
17645 #ifdef CONFIG_AMD_NB
17646 +static struct attribute *default_attrs_amd_nb[] = {
17647 + &type.attr,
17648 + &level.attr,
17649 + &coherency_line_size.attr,
17650 + &physical_line_partition.attr,
17651 + &ways_of_associativity.attr,
17652 + &number_of_sets.attr,
17653 + &size.attr,
17654 + &shared_cpu_map.attr,
17655 + &shared_cpu_list.attr,
17656 + NULL,
17657 + NULL,
17658 + NULL,
17659 + NULL
17660 +};
17661 +
17662 static struct attribute ** __cpuinit amd_l3_attrs(void)
17663 {
17664 static struct attribute **attrs;
17665 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17666
17667 n = ARRAY_SIZE(default_attrs);
17668
17669 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17670 - n += 2;
17671 -
17672 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17673 - n += 1;
17674 -
17675 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17676 - if (attrs == NULL)
17677 - return attrs = default_attrs;
17678 -
17679 - for (n = 0; default_attrs[n]; n++)
17680 - attrs[n] = default_attrs[n];
17681 + attrs = default_attrs_amd_nb;
17682
17683 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17684 attrs[n++] = &cache_disable_0.attr;
17685 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17686 .default_attrs = default_attrs,
17687 };
17688
17689 +#ifdef CONFIG_AMD_NB
17690 +static struct kobj_type ktype_cache_amd_nb = {
17691 + .sysfs_ops = &sysfs_ops,
17692 + .default_attrs = default_attrs_amd_nb,
17693 +};
17694 +#endif
17695 +
17696 static struct kobj_type ktype_percpu_entry = {
17697 .sysfs_ops = &sysfs_ops,
17698 };
17699 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17700 return retval;
17701 }
17702
17703 +#ifdef CONFIG_AMD_NB
17704 + amd_l3_attrs();
17705 +#endif
17706 +
17707 for (i = 0; i < num_cache_leaves; i++) {
17708 + struct kobj_type *ktype;
17709 +
17710 this_object = INDEX_KOBJECT_PTR(cpu, i);
17711 this_object->cpu = cpu;
17712 this_object->index = i;
17713
17714 this_leaf = CPUID4_INFO_IDX(cpu, i);
17715
17716 - ktype_cache.default_attrs = default_attrs;
17717 + ktype = &ktype_cache;
17718 #ifdef CONFIG_AMD_NB
17719 if (this_leaf->base.nb)
17720 - ktype_cache.default_attrs = amd_l3_attrs();
17721 + ktype = &ktype_cache_amd_nb;
17722 #endif
17723 retval = kobject_init_and_add(&(this_object->kobj),
17724 - &ktype_cache,
17725 + ktype,
17726 per_cpu(ici_cache_kobject, cpu),
17727 "index%1lu", i);
17728 if (unlikely(retval)) {
17729 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17730 return NOTIFY_OK;
17731 }
17732
17733 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17734 +static struct notifier_block cacheinfo_cpu_notifier = {
17735 .notifier_call = cacheinfo_cpu_callback,
17736 };
17737
17738 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17739 index 80dbda8..be16652 100644
17740 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17741 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17742 @@ -45,6 +45,7 @@
17743 #include <asm/processor.h>
17744 #include <asm/mce.h>
17745 #include <asm/msr.h>
17746 +#include <asm/local.h>
17747
17748 #include "mce-internal.h"
17749
17750 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17751 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17752 m->cs, m->ip);
17753
17754 - if (m->cs == __KERNEL_CS)
17755 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17756 print_symbol("{%s}", m->ip);
17757 pr_cont("\n");
17758 }
17759 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17760
17761 #define PANIC_TIMEOUT 5 /* 5 seconds */
17762
17763 -static atomic_t mce_paniced;
17764 +static atomic_unchecked_t mce_paniced;
17765
17766 static int fake_panic;
17767 -static atomic_t mce_fake_paniced;
17768 +static atomic_unchecked_t mce_fake_paniced;
17769
17770 /* Panic in progress. Enable interrupts and wait for final IPI */
17771 static void wait_for_panic(void)
17772 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17773 /*
17774 * Make sure only one CPU runs in machine check panic
17775 */
17776 - if (atomic_inc_return(&mce_paniced) > 1)
17777 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17778 wait_for_panic();
17779 barrier();
17780
17781 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17782 console_verbose();
17783 } else {
17784 /* Don't log too much for fake panic */
17785 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17786 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17787 return;
17788 }
17789 /* First print corrected ones that are still unlogged */
17790 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17791 * might have been modified by someone else.
17792 */
17793 rmb();
17794 - if (atomic_read(&mce_paniced))
17795 + if (atomic_read_unchecked(&mce_paniced))
17796 wait_for_panic();
17797 if (!mca_cfg.monarch_timeout)
17798 goto out;
17799 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17800 }
17801
17802 /* Call the installed machine check handler for this CPU setup. */
17803 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17804 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17805 unexpected_machine_check;
17806
17807 /*
17808 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17809 return;
17810 }
17811
17812 + pax_open_kernel();
17813 machine_check_vector = do_machine_check;
17814 + pax_close_kernel();
17815
17816 __mcheck_cpu_init_generic();
17817 __mcheck_cpu_init_vendor(c);
17818 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17819 */
17820
17821 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17822 -static int mce_chrdev_open_count; /* #times opened */
17823 +static local_t mce_chrdev_open_count; /* #times opened */
17824 static int mce_chrdev_open_exclu; /* already open exclusive? */
17825
17826 static int mce_chrdev_open(struct inode *inode, struct file *file)
17827 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17828 spin_lock(&mce_chrdev_state_lock);
17829
17830 if (mce_chrdev_open_exclu ||
17831 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17832 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17833 spin_unlock(&mce_chrdev_state_lock);
17834
17835 return -EBUSY;
17836 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17837
17838 if (file->f_flags & O_EXCL)
17839 mce_chrdev_open_exclu = 1;
17840 - mce_chrdev_open_count++;
17841 + local_inc(&mce_chrdev_open_count);
17842
17843 spin_unlock(&mce_chrdev_state_lock);
17844
17845 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17846 {
17847 spin_lock(&mce_chrdev_state_lock);
17848
17849 - mce_chrdev_open_count--;
17850 + local_dec(&mce_chrdev_open_count);
17851 mce_chrdev_open_exclu = 0;
17852
17853 spin_unlock(&mce_chrdev_state_lock);
17854 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17855 return NOTIFY_OK;
17856 }
17857
17858 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17859 +static struct notifier_block mce_cpu_notifier = {
17860 .notifier_call = mce_cpu_callback,
17861 };
17862
17863 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17864
17865 for (i = 0; i < mca_cfg.banks; i++) {
17866 struct mce_bank *b = &mce_banks[i];
17867 - struct device_attribute *a = &b->attr;
17868 + device_attribute_no_const *a = &b->attr;
17869
17870 sysfs_attr_init(&a->attr);
17871 a->attr.name = b->attrname;
17872 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17873 static void mce_reset(void)
17874 {
17875 cpu_missing = 0;
17876 - atomic_set(&mce_fake_paniced, 0);
17877 + atomic_set_unchecked(&mce_fake_paniced, 0);
17878 atomic_set(&mce_executing, 0);
17879 atomic_set(&mce_callin, 0);
17880 atomic_set(&global_nwo, 0);
17881 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17882 index 2d5454c..51987eb 100644
17883 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17884 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17885 @@ -11,6 +11,7 @@
17886 #include <asm/processor.h>
17887 #include <asm/mce.h>
17888 #include <asm/msr.h>
17889 +#include <asm/pgtable.h>
17890
17891 /* By default disabled */
17892 int mce_p5_enabled __read_mostly;
17893 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17894 if (!cpu_has(c, X86_FEATURE_MCE))
17895 return;
17896
17897 + pax_open_kernel();
17898 machine_check_vector = pentium_machine_check;
17899 + pax_close_kernel();
17900 /* Make sure the vector pointer is visible before we enable MCEs: */
17901 wmb();
17902
17903 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17904 index 47a1870..8c019a7 100644
17905 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17906 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17907 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17908 return notifier_from_errno(err);
17909 }
17910
17911 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17912 +static struct notifier_block thermal_throttle_cpu_notifier =
17913 {
17914 .notifier_call = thermal_throttle_cpu_callback,
17915 };
17916 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17917 index 2d7998f..17c9de1 100644
17918 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17919 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17920 @@ -10,6 +10,7 @@
17921 #include <asm/processor.h>
17922 #include <asm/mce.h>
17923 #include <asm/msr.h>
17924 +#include <asm/pgtable.h>
17925
17926 /* Machine check handler for WinChip C6: */
17927 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17928 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17929 {
17930 u32 lo, hi;
17931
17932 + pax_open_kernel();
17933 machine_check_vector = winchip_machine_check;
17934 + pax_close_kernel();
17935 /* Make sure the vector pointer is visible before we enable MCEs: */
17936 wmb();
17937
17938 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17939 index 726bf96..81f0526 100644
17940 --- a/arch/x86/kernel/cpu/mtrr/main.c
17941 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17942 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17943 u64 size_or_mask, size_and_mask;
17944 static bool mtrr_aps_delayed_init;
17945
17946 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17947 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17948
17949 const struct mtrr_ops *mtrr_if;
17950
17951 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17952 index df5e41f..816c719 100644
17953 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17954 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17955 @@ -25,7 +25,7 @@ struct mtrr_ops {
17956 int (*validate_add_page)(unsigned long base, unsigned long size,
17957 unsigned int type);
17958 int (*have_wrcomb)(void);
17959 -};
17960 +} __do_const;
17961
17962 extern int generic_get_free_region(unsigned long base, unsigned long size,
17963 int replace_reg);
17964 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17965 index 6774c17..72c1b22 100644
17966 --- a/arch/x86/kernel/cpu/perf_event.c
17967 +++ b/arch/x86/kernel/cpu/perf_event.c
17968 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17969 pr_info("no hardware sampling interrupt available.\n");
17970 }
17971
17972 -static struct attribute_group x86_pmu_format_group = {
17973 +static attribute_group_no_const x86_pmu_format_group = {
17974 .name = "format",
17975 .attrs = NULL,
17976 };
17977 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17978 struct perf_pmu_events_attr {
17979 struct device_attribute attr;
17980 u64 id;
17981 -};
17982 +} __do_const;
17983
17984 /*
17985 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17986 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17987 NULL,
17988 };
17989
17990 -static struct attribute_group x86_pmu_events_group = {
17991 +static attribute_group_no_const x86_pmu_events_group = {
17992 .name = "events",
17993 .attrs = events_attr,
17994 };
17995 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17996 if (idx > GDT_ENTRIES)
17997 return 0;
17998
17999 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
18000 + desc = get_cpu_gdt_table(smp_processor_id());
18001 }
18002
18003 return get_desc_base(desc + idx);
18004 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
18005 break;
18006
18007 perf_callchain_store(entry, frame.return_address);
18008 - fp = frame.next_frame;
18009 + fp = (const void __force_user *)frame.next_frame;
18010 }
18011 }
18012
18013 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
18014 index 70602f8..9d9edb7 100644
18015 --- a/arch/x86/kernel/cpu/perf_event_intel.c
18016 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
18017 @@ -1964,10 +1964,10 @@ __init int intel_pmu_init(void)
18018 * v2 and above have a perf capabilities MSR
18019 */
18020 if (version > 1) {
18021 - u64 capabilities;
18022 + u64 capabilities = x86_pmu.intel_cap.capabilities;
18023
18024 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
18025 - x86_pmu.intel_cap.capabilities = capabilities;
18026 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
18027 + x86_pmu.intel_cap.capabilities = capabilities;
18028 }
18029
18030 intel_ds_init();
18031 diff --git a/arch/x86/kernel/cpu/perf_event_intel_lbr.c b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18032 index da02e9c..94db951 100644
18033 --- a/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18034 +++ b/arch/x86/kernel/cpu/perf_event_intel_lbr.c
18035 @@ -310,7 +310,7 @@ void intel_pmu_lbr_read(void)
18036 * - in case there is no HW filter
18037 * - in case the HW filter has errata or limitations
18038 */
18039 -static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18040 +static int intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18041 {
18042 u64 br_type = event->attr.branch_sample_type;
18043 int mask = 0;
18044 @@ -318,8 +318,11 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18045 if (br_type & PERF_SAMPLE_BRANCH_USER)
18046 mask |= X86_BR_USER;
18047
18048 - if (br_type & PERF_SAMPLE_BRANCH_KERNEL)
18049 + if (br_type & PERF_SAMPLE_BRANCH_KERNEL) {
18050 + if (perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
18051 + return -EACCES;
18052 mask |= X86_BR_KERNEL;
18053 + }
18054
18055 /* we ignore BRANCH_HV here */
18056
18057 @@ -339,6 +342,8 @@ static void intel_pmu_setup_sw_lbr_filter(struct perf_event *event)
18058 * be used by fixup code for some CPU
18059 */
18060 event->hw.branch_reg.reg = mask;
18061 +
18062 + return 0;
18063 }
18064
18065 /*
18066 @@ -386,7 +391,9 @@ int intel_pmu_setup_lbr_filter(struct perf_event *event)
18067 /*
18068 * setup SW LBR filter
18069 */
18070 - intel_pmu_setup_sw_lbr_filter(event);
18071 + ret = intel_pmu_setup_sw_lbr_filter(event);
18072 + if (ret)
18073 + return ret;
18074
18075 /*
18076 * setup HW LBR filter, if any
18077 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18078 index b43200d..d235b3e 100644
18079 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18080 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
18081 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
18082 static int __init uncore_type_init(struct intel_uncore_type *type)
18083 {
18084 struct intel_uncore_pmu *pmus;
18085 - struct attribute_group *events_group;
18086 + attribute_group_no_const *attr_group;
18087 struct attribute **attrs;
18088 int i, j;
18089
18090 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
18091 while (type->event_descs[i].attr.attr.name)
18092 i++;
18093
18094 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18095 - sizeof(*events_group), GFP_KERNEL);
18096 - if (!events_group)
18097 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18098 + sizeof(*attr_group), GFP_KERNEL);
18099 + if (!attr_group)
18100 goto fail;
18101
18102 - attrs = (struct attribute **)(events_group + 1);
18103 - events_group->name = "events";
18104 - events_group->attrs = attrs;
18105 + attrs = (struct attribute **)(attr_group + 1);
18106 + attr_group->name = "events";
18107 + attr_group->attrs = attrs;
18108
18109 for (j = 0; j < i; j++)
18110 attrs[j] = &type->event_descs[j].attr.attr;
18111
18112 - type->events_group = events_group;
18113 + type->events_group = attr_group;
18114 }
18115
18116 type->pmu_group = &uncore_pmu_attr_group;
18117 @@ -2826,7 +2826,7 @@ static int
18118 return NOTIFY_OK;
18119 }
18120
18121 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18122 +static struct notifier_block uncore_cpu_nb = {
18123 .notifier_call = uncore_cpu_notifier,
18124 /*
18125 * to migrate uncore events, our notifier should be executed
18126 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18127 index e68a455..975a932 100644
18128 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18129 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18130 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18131 struct uncore_event_desc {
18132 struct kobj_attribute attr;
18133 const char *config;
18134 -};
18135 +} __do_const;
18136
18137 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18138 { \
18139 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18140 index 60c7891..9e911d3 100644
18141 --- a/arch/x86/kernel/cpuid.c
18142 +++ b/arch/x86/kernel/cpuid.c
18143 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18144 return notifier_from_errno(err);
18145 }
18146
18147 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18148 +static struct notifier_block cpuid_class_cpu_notifier =
18149 {
18150 .notifier_call = cpuid_class_cpu_callback,
18151 };
18152 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18153 index 74467fe..18793d5 100644
18154 --- a/arch/x86/kernel/crash.c
18155 +++ b/arch/x86/kernel/crash.c
18156 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18157 {
18158 #ifdef CONFIG_X86_32
18159 struct pt_regs fixed_regs;
18160 -#endif
18161
18162 -#ifdef CONFIG_X86_32
18163 - if (!user_mode_vm(regs)) {
18164 + if (!user_mode(regs)) {
18165 crash_fixup_ss_esp(&fixed_regs, regs);
18166 regs = &fixed_regs;
18167 }
18168 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18169 index 37250fe..bf2ec74 100644
18170 --- a/arch/x86/kernel/doublefault_32.c
18171 +++ b/arch/x86/kernel/doublefault_32.c
18172 @@ -11,7 +11,7 @@
18173
18174 #define DOUBLEFAULT_STACKSIZE (1024)
18175 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18176 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18177 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18178
18179 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18180
18181 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18182 unsigned long gdt, tss;
18183
18184 store_gdt(&gdt_desc);
18185 - gdt = gdt_desc.address;
18186 + gdt = (unsigned long)gdt_desc.address;
18187
18188 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18189
18190 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18191 /* 0x2 bit is always set */
18192 .flags = X86_EFLAGS_SF | 0x2,
18193 .sp = STACK_START,
18194 - .es = __USER_DS,
18195 + .es = __KERNEL_DS,
18196 .cs = __KERNEL_CS,
18197 .ss = __KERNEL_DS,
18198 - .ds = __USER_DS,
18199 + .ds = __KERNEL_DS,
18200 .fs = __KERNEL_PERCPU,
18201
18202 .__cr3 = __pa_nodebug(swapper_pg_dir),
18203 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18204 index ae42418b..787c16b 100644
18205 --- a/arch/x86/kernel/dumpstack.c
18206 +++ b/arch/x86/kernel/dumpstack.c
18207 @@ -2,6 +2,9 @@
18208 * Copyright (C) 1991, 1992 Linus Torvalds
18209 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18210 */
18211 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18212 +#define __INCLUDED_BY_HIDESYM 1
18213 +#endif
18214 #include <linux/kallsyms.h>
18215 #include <linux/kprobes.h>
18216 #include <linux/uaccess.h>
18217 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18218 static void
18219 print_ftrace_graph_addr(unsigned long addr, void *data,
18220 const struct stacktrace_ops *ops,
18221 - struct thread_info *tinfo, int *graph)
18222 + struct task_struct *task, int *graph)
18223 {
18224 - struct task_struct *task;
18225 unsigned long ret_addr;
18226 int index;
18227
18228 if (addr != (unsigned long)return_to_handler)
18229 return;
18230
18231 - task = tinfo->task;
18232 index = task->curr_ret_stack;
18233
18234 if (!task->ret_stack || index < *graph)
18235 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18236 static inline void
18237 print_ftrace_graph_addr(unsigned long addr, void *data,
18238 const struct stacktrace_ops *ops,
18239 - struct thread_info *tinfo, int *graph)
18240 + struct task_struct *task, int *graph)
18241 { }
18242 #endif
18243
18244 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18245 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18246 */
18247
18248 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18249 - void *p, unsigned int size, void *end)
18250 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18251 {
18252 - void *t = tinfo;
18253 if (end) {
18254 if (p < end && p >= (end-THREAD_SIZE))
18255 return 1;
18256 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18257 }
18258
18259 unsigned long
18260 -print_context_stack(struct thread_info *tinfo,
18261 +print_context_stack(struct task_struct *task, void *stack_start,
18262 unsigned long *stack, unsigned long bp,
18263 const struct stacktrace_ops *ops, void *data,
18264 unsigned long *end, int *graph)
18265 {
18266 struct stack_frame *frame = (struct stack_frame *)bp;
18267
18268 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18269 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18270 unsigned long addr;
18271
18272 addr = *stack;
18273 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18274 } else {
18275 ops->address(data, addr, 0);
18276 }
18277 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18278 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18279 }
18280 stack++;
18281 }
18282 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18283 EXPORT_SYMBOL_GPL(print_context_stack);
18284
18285 unsigned long
18286 -print_context_stack_bp(struct thread_info *tinfo,
18287 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18288 unsigned long *stack, unsigned long bp,
18289 const struct stacktrace_ops *ops, void *data,
18290 unsigned long *end, int *graph)
18291 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18292 struct stack_frame *frame = (struct stack_frame *)bp;
18293 unsigned long *ret_addr = &frame->return_address;
18294
18295 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18296 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18297 unsigned long addr = *ret_addr;
18298
18299 if (!__kernel_text_address(addr))
18300 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18301 ops->address(data, addr, 1);
18302 frame = frame->next_frame;
18303 ret_addr = &frame->return_address;
18304 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18305 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18306 }
18307
18308 return (unsigned long)frame;
18309 @@ -189,7 +188,7 @@ void dump_stack(void)
18310
18311 bp = stack_frame(current, NULL);
18312 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18313 - current->pid, current->comm, print_tainted(),
18314 + task_pid_nr(current), current->comm, print_tainted(),
18315 init_utsname()->release,
18316 (int)strcspn(init_utsname()->version, " "),
18317 init_utsname()->version);
18318 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18319 }
18320 EXPORT_SYMBOL_GPL(oops_begin);
18321
18322 +extern void gr_handle_kernel_exploit(void);
18323 +
18324 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18325 {
18326 if (regs && kexec_should_crash(current))
18327 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18328 panic("Fatal exception in interrupt");
18329 if (panic_on_oops)
18330 panic("Fatal exception");
18331 - do_exit(signr);
18332 +
18333 + gr_handle_kernel_exploit();
18334 +
18335 + do_group_exit(signr);
18336 }
18337
18338 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18339 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18340 print_modules();
18341 show_regs(regs);
18342 #ifdef CONFIG_X86_32
18343 - if (user_mode_vm(regs)) {
18344 + if (user_mode(regs)) {
18345 sp = regs->sp;
18346 ss = regs->ss & 0xffff;
18347 } else {
18348 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18349 unsigned long flags = oops_begin();
18350 int sig = SIGSEGV;
18351
18352 - if (!user_mode_vm(regs))
18353 + if (!user_mode(regs))
18354 report_bug(regs->ip, regs);
18355
18356 if (__die(str, regs, err))
18357 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18358 index 1038a41..db2c12b 100644
18359 --- a/arch/x86/kernel/dumpstack_32.c
18360 +++ b/arch/x86/kernel/dumpstack_32.c
18361 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18362 bp = stack_frame(task, regs);
18363
18364 for (;;) {
18365 - struct thread_info *context;
18366 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18367
18368 - context = (struct thread_info *)
18369 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18370 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18371 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18372
18373 - stack = (unsigned long *)context->previous_esp;
18374 - if (!stack)
18375 + if (stack_start == task_stack_page(task))
18376 break;
18377 + stack = *(unsigned long **)stack_start;
18378 if (ops->stack(data, "IRQ") < 0)
18379 break;
18380 touch_nmi_watchdog();
18381 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18382 {
18383 int i;
18384
18385 - __show_regs(regs, !user_mode_vm(regs));
18386 + __show_regs(regs, !user_mode(regs));
18387
18388 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18389 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18390 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18391 * When in-kernel, we also print out the stack and code at the
18392 * time of the fault..
18393 */
18394 - if (!user_mode_vm(regs)) {
18395 + if (!user_mode(regs)) {
18396 unsigned int code_prologue = code_bytes * 43 / 64;
18397 unsigned int code_len = code_bytes;
18398 unsigned char c;
18399 u8 *ip;
18400 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18401
18402 pr_emerg("Stack:\n");
18403 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18404
18405 pr_emerg("Code:");
18406
18407 - ip = (u8 *)regs->ip - code_prologue;
18408 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18409 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18410 /* try starting at IP */
18411 - ip = (u8 *)regs->ip;
18412 + ip = (u8 *)regs->ip + cs_base;
18413 code_len = code_len - code_prologue + 1;
18414 }
18415 for (i = 0; i < code_len; i++, ip++) {
18416 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18417 pr_cont(" Bad EIP value.");
18418 break;
18419 }
18420 - if (ip == (u8 *)regs->ip)
18421 + if (ip == (u8 *)regs->ip + cs_base)
18422 pr_cont(" <%02x>", c);
18423 else
18424 pr_cont(" %02x", c);
18425 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18426 {
18427 unsigned short ud2;
18428
18429 + ip = ktla_ktva(ip);
18430 if (ip < PAGE_OFFSET)
18431 return 0;
18432 if (probe_kernel_address((unsigned short *)ip, ud2))
18433 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18434
18435 return ud2 == 0x0b0f;
18436 }
18437 +
18438 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18439 +void pax_check_alloca(unsigned long size)
18440 +{
18441 + unsigned long sp = (unsigned long)&sp, stack_left;
18442 +
18443 + /* all kernel stacks are of the same size */
18444 + stack_left = sp & (THREAD_SIZE - 1);
18445 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18446 +}
18447 +EXPORT_SYMBOL(pax_check_alloca);
18448 +#endif
18449 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18450 index b653675..51cc8c0 100644
18451 --- a/arch/x86/kernel/dumpstack_64.c
18452 +++ b/arch/x86/kernel/dumpstack_64.c
18453 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18454 unsigned long *irq_stack_end =
18455 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18456 unsigned used = 0;
18457 - struct thread_info *tinfo;
18458 int graph = 0;
18459 unsigned long dummy;
18460 + void *stack_start;
18461
18462 if (!task)
18463 task = current;
18464 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18465 * current stack address. If the stacks consist of nested
18466 * exceptions
18467 */
18468 - tinfo = task_thread_info(task);
18469 for (;;) {
18470 char *id;
18471 unsigned long *estack_end;
18472 +
18473 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18474 &used, &id);
18475
18476 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18477 if (ops->stack(data, id) < 0)
18478 break;
18479
18480 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18481 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18482 data, estack_end, &graph);
18483 ops->stack(data, "<EOE>");
18484 /*
18485 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18486 * second-to-last pointer (index -2 to end) in the
18487 * exception stack:
18488 */
18489 + if ((u16)estack_end[-1] != __KERNEL_DS)
18490 + goto out;
18491 stack = (unsigned long *) estack_end[-2];
18492 continue;
18493 }
18494 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18495 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18496 if (ops->stack(data, "IRQ") < 0)
18497 break;
18498 - bp = ops->walk_stack(tinfo, stack, bp,
18499 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18500 ops, data, irq_stack_end, &graph);
18501 /*
18502 * We link to the next stack (which would be
18503 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18504 /*
18505 * This handles the process stack:
18506 */
18507 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18508 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18509 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18510 +out:
18511 put_cpu();
18512 }
18513 EXPORT_SYMBOL(dump_trace);
18514 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18515 {
18516 int i;
18517 unsigned long sp;
18518 - const int cpu = smp_processor_id();
18519 + const int cpu = raw_smp_processor_id();
18520 struct task_struct *cur = current;
18521
18522 sp = regs->sp;
18523 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18524
18525 return ud2 == 0x0b0f;
18526 }
18527 +
18528 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18529 +void pax_check_alloca(unsigned long size)
18530 +{
18531 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18532 + unsigned cpu, used;
18533 + char *id;
18534 +
18535 + /* check the process stack first */
18536 + stack_start = (unsigned long)task_stack_page(current);
18537 + stack_end = stack_start + THREAD_SIZE;
18538 + if (likely(stack_start <= sp && sp < stack_end)) {
18539 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18540 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18541 + return;
18542 + }
18543 +
18544 + cpu = get_cpu();
18545 +
18546 + /* check the irq stacks */
18547 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18548 + stack_start = stack_end - IRQ_STACK_SIZE;
18549 + if (stack_start <= sp && sp < stack_end) {
18550 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18551 + put_cpu();
18552 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18553 + return;
18554 + }
18555 +
18556 + /* check the exception stacks */
18557 + used = 0;
18558 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18559 + stack_start = stack_end - EXCEPTION_STKSZ;
18560 + if (stack_end && stack_start <= sp && sp < stack_end) {
18561 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18562 + put_cpu();
18563 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18564 + return;
18565 + }
18566 +
18567 + put_cpu();
18568 +
18569 + /* unknown stack */
18570 + BUG();
18571 +}
18572 +EXPORT_SYMBOL(pax_check_alloca);
18573 +#endif
18574 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18575 index 9b9f18b..9fcaa04 100644
18576 --- a/arch/x86/kernel/early_printk.c
18577 +++ b/arch/x86/kernel/early_printk.c
18578 @@ -7,6 +7,7 @@
18579 #include <linux/pci_regs.h>
18580 #include <linux/pci_ids.h>
18581 #include <linux/errno.h>
18582 +#include <linux/sched.h>
18583 #include <asm/io.h>
18584 #include <asm/processor.h>
18585 #include <asm/fcntl.h>
18586 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18587 index 6ed91d9..6cc365b 100644
18588 --- a/arch/x86/kernel/entry_32.S
18589 +++ b/arch/x86/kernel/entry_32.S
18590 @@ -177,13 +177,153 @@
18591 /*CFI_REL_OFFSET gs, PT_GS*/
18592 .endm
18593 .macro SET_KERNEL_GS reg
18594 +
18595 +#ifdef CONFIG_CC_STACKPROTECTOR
18596 movl $(__KERNEL_STACK_CANARY), \reg
18597 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18598 + movl $(__USER_DS), \reg
18599 +#else
18600 + xorl \reg, \reg
18601 +#endif
18602 +
18603 movl \reg, %gs
18604 .endm
18605
18606 #endif /* CONFIG_X86_32_LAZY_GS */
18607
18608 -.macro SAVE_ALL
18609 +.macro pax_enter_kernel
18610 +#ifdef CONFIG_PAX_KERNEXEC
18611 + call pax_enter_kernel
18612 +#endif
18613 +.endm
18614 +
18615 +.macro pax_exit_kernel
18616 +#ifdef CONFIG_PAX_KERNEXEC
18617 + call pax_exit_kernel
18618 +#endif
18619 +.endm
18620 +
18621 +#ifdef CONFIG_PAX_KERNEXEC
18622 +ENTRY(pax_enter_kernel)
18623 +#ifdef CONFIG_PARAVIRT
18624 + pushl %eax
18625 + pushl %ecx
18626 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18627 + mov %eax, %esi
18628 +#else
18629 + mov %cr0, %esi
18630 +#endif
18631 + bts $16, %esi
18632 + jnc 1f
18633 + mov %cs, %esi
18634 + cmp $__KERNEL_CS, %esi
18635 + jz 3f
18636 + ljmp $__KERNEL_CS, $3f
18637 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18638 +2:
18639 +#ifdef CONFIG_PARAVIRT
18640 + mov %esi, %eax
18641 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18642 +#else
18643 + mov %esi, %cr0
18644 +#endif
18645 +3:
18646 +#ifdef CONFIG_PARAVIRT
18647 + popl %ecx
18648 + popl %eax
18649 +#endif
18650 + ret
18651 +ENDPROC(pax_enter_kernel)
18652 +
18653 +ENTRY(pax_exit_kernel)
18654 +#ifdef CONFIG_PARAVIRT
18655 + pushl %eax
18656 + pushl %ecx
18657 +#endif
18658 + mov %cs, %esi
18659 + cmp $__KERNEXEC_KERNEL_CS, %esi
18660 + jnz 2f
18661 +#ifdef CONFIG_PARAVIRT
18662 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18663 + mov %eax, %esi
18664 +#else
18665 + mov %cr0, %esi
18666 +#endif
18667 + btr $16, %esi
18668 + ljmp $__KERNEL_CS, $1f
18669 +1:
18670 +#ifdef CONFIG_PARAVIRT
18671 + mov %esi, %eax
18672 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18673 +#else
18674 + mov %esi, %cr0
18675 +#endif
18676 +2:
18677 +#ifdef CONFIG_PARAVIRT
18678 + popl %ecx
18679 + popl %eax
18680 +#endif
18681 + ret
18682 +ENDPROC(pax_exit_kernel)
18683 +#endif
18684 +
18685 +.macro pax_erase_kstack
18686 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18687 + call pax_erase_kstack
18688 +#endif
18689 +.endm
18690 +
18691 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18692 +/*
18693 + * ebp: thread_info
18694 + */
18695 +ENTRY(pax_erase_kstack)
18696 + pushl %edi
18697 + pushl %ecx
18698 + pushl %eax
18699 +
18700 + mov TI_lowest_stack(%ebp), %edi
18701 + mov $-0xBEEF, %eax
18702 + std
18703 +
18704 +1: mov %edi, %ecx
18705 + and $THREAD_SIZE_asm - 1, %ecx
18706 + shr $2, %ecx
18707 + repne scasl
18708 + jecxz 2f
18709 +
18710 + cmp $2*16, %ecx
18711 + jc 2f
18712 +
18713 + mov $2*16, %ecx
18714 + repe scasl
18715 + jecxz 2f
18716 + jne 1b
18717 +
18718 +2: cld
18719 + mov %esp, %ecx
18720 + sub %edi, %ecx
18721 +
18722 + cmp $THREAD_SIZE_asm, %ecx
18723 + jb 3f
18724 + ud2
18725 +3:
18726 +
18727 + shr $2, %ecx
18728 + rep stosl
18729 +
18730 + mov TI_task_thread_sp0(%ebp), %edi
18731 + sub $128, %edi
18732 + mov %edi, TI_lowest_stack(%ebp)
18733 +
18734 + popl %eax
18735 + popl %ecx
18736 + popl %edi
18737 + ret
18738 +ENDPROC(pax_erase_kstack)
18739 +#endif
18740 +
18741 +.macro __SAVE_ALL _DS
18742 cld
18743 PUSH_GS
18744 pushl_cfi %fs
18745 @@ -206,7 +346,7 @@
18746 CFI_REL_OFFSET ecx, 0
18747 pushl_cfi %ebx
18748 CFI_REL_OFFSET ebx, 0
18749 - movl $(__USER_DS), %edx
18750 + movl $\_DS, %edx
18751 movl %edx, %ds
18752 movl %edx, %es
18753 movl $(__KERNEL_PERCPU), %edx
18754 @@ -214,6 +354,15 @@
18755 SET_KERNEL_GS %edx
18756 .endm
18757
18758 +.macro SAVE_ALL
18759 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18760 + __SAVE_ALL __KERNEL_DS
18761 + pax_enter_kernel
18762 +#else
18763 + __SAVE_ALL __USER_DS
18764 +#endif
18765 +.endm
18766 +
18767 .macro RESTORE_INT_REGS
18768 popl_cfi %ebx
18769 CFI_RESTORE ebx
18770 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18771 popfl_cfi
18772 jmp syscall_exit
18773 CFI_ENDPROC
18774 -END(ret_from_fork)
18775 +ENDPROC(ret_from_fork)
18776
18777 ENTRY(ret_from_kernel_thread)
18778 CFI_STARTPROC
18779 @@ -344,7 +493,15 @@ ret_from_intr:
18780 andl $SEGMENT_RPL_MASK, %eax
18781 #endif
18782 cmpl $USER_RPL, %eax
18783 +
18784 +#ifdef CONFIG_PAX_KERNEXEC
18785 + jae resume_userspace
18786 +
18787 + pax_exit_kernel
18788 + jmp resume_kernel
18789 +#else
18790 jb resume_kernel # not returning to v8086 or userspace
18791 +#endif
18792
18793 ENTRY(resume_userspace)
18794 LOCKDEP_SYS_EXIT
18795 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18796 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18797 # int/exception return?
18798 jne work_pending
18799 - jmp restore_all
18800 -END(ret_from_exception)
18801 + jmp restore_all_pax
18802 +ENDPROC(ret_from_exception)
18803
18804 #ifdef CONFIG_PREEMPT
18805 ENTRY(resume_kernel)
18806 @@ -372,7 +529,7 @@ need_resched:
18807 jz restore_all
18808 call preempt_schedule_irq
18809 jmp need_resched
18810 -END(resume_kernel)
18811 +ENDPROC(resume_kernel)
18812 #endif
18813 CFI_ENDPROC
18814 /*
18815 @@ -406,30 +563,45 @@ sysenter_past_esp:
18816 /*CFI_REL_OFFSET cs, 0*/
18817 /*
18818 * Push current_thread_info()->sysenter_return to the stack.
18819 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18820 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18821 */
18822 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18823 + pushl_cfi $0
18824 CFI_REL_OFFSET eip, 0
18825
18826 pushl_cfi %eax
18827 SAVE_ALL
18828 + GET_THREAD_INFO(%ebp)
18829 + movl TI_sysenter_return(%ebp),%ebp
18830 + movl %ebp,PT_EIP(%esp)
18831 ENABLE_INTERRUPTS(CLBR_NONE)
18832
18833 /*
18834 * Load the potential sixth argument from user stack.
18835 * Careful about security.
18836 */
18837 + movl PT_OLDESP(%esp),%ebp
18838 +
18839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18840 + mov PT_OLDSS(%esp),%ds
18841 +1: movl %ds:(%ebp),%ebp
18842 + push %ss
18843 + pop %ds
18844 +#else
18845 cmpl $__PAGE_OFFSET-3,%ebp
18846 jae syscall_fault
18847 ASM_STAC
18848 1: movl (%ebp),%ebp
18849 ASM_CLAC
18850 +#endif
18851 +
18852 movl %ebp,PT_EBP(%esp)
18853 _ASM_EXTABLE(1b,syscall_fault)
18854
18855 GET_THREAD_INFO(%ebp)
18856
18857 +#ifdef CONFIG_PAX_RANDKSTACK
18858 + pax_erase_kstack
18859 +#endif
18860 +
18861 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18862 jnz sysenter_audit
18863 sysenter_do_call:
18864 @@ -444,12 +616,24 @@ sysenter_do_call:
18865 testl $_TIF_ALLWORK_MASK, %ecx
18866 jne sysexit_audit
18867 sysenter_exit:
18868 +
18869 +#ifdef CONFIG_PAX_RANDKSTACK
18870 + pushl_cfi %eax
18871 + movl %esp, %eax
18872 + call pax_randomize_kstack
18873 + popl_cfi %eax
18874 +#endif
18875 +
18876 + pax_erase_kstack
18877 +
18878 /* if something modifies registers it must also disable sysexit */
18879 movl PT_EIP(%esp), %edx
18880 movl PT_OLDESP(%esp), %ecx
18881 xorl %ebp,%ebp
18882 TRACE_IRQS_ON
18883 1: mov PT_FS(%esp), %fs
18884 +2: mov PT_DS(%esp), %ds
18885 +3: mov PT_ES(%esp), %es
18886 PTGS_TO_GS
18887 ENABLE_INTERRUPTS_SYSEXIT
18888
18889 @@ -466,6 +650,9 @@ sysenter_audit:
18890 movl %eax,%edx /* 2nd arg: syscall number */
18891 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18892 call __audit_syscall_entry
18893 +
18894 + pax_erase_kstack
18895 +
18896 pushl_cfi %ebx
18897 movl PT_EAX(%esp),%eax /* reload syscall number */
18898 jmp sysenter_do_call
18899 @@ -491,10 +678,16 @@ sysexit_audit:
18900
18901 CFI_ENDPROC
18902 .pushsection .fixup,"ax"
18903 -2: movl $0,PT_FS(%esp)
18904 +4: movl $0,PT_FS(%esp)
18905 + jmp 1b
18906 +5: movl $0,PT_DS(%esp)
18907 + jmp 1b
18908 +6: movl $0,PT_ES(%esp)
18909 jmp 1b
18910 .popsection
18911 - _ASM_EXTABLE(1b,2b)
18912 + _ASM_EXTABLE(1b,4b)
18913 + _ASM_EXTABLE(2b,5b)
18914 + _ASM_EXTABLE(3b,6b)
18915 PTGS_TO_GS_EX
18916 ENDPROC(ia32_sysenter_target)
18917
18918 @@ -509,6 +702,11 @@ ENTRY(system_call)
18919 pushl_cfi %eax # save orig_eax
18920 SAVE_ALL
18921 GET_THREAD_INFO(%ebp)
18922 +
18923 +#ifdef CONFIG_PAX_RANDKSTACK
18924 + pax_erase_kstack
18925 +#endif
18926 +
18927 # system call tracing in operation / emulation
18928 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18929 jnz syscall_trace_entry
18930 @@ -527,6 +725,15 @@ syscall_exit:
18931 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18932 jne syscall_exit_work
18933
18934 +restore_all_pax:
18935 +
18936 +#ifdef CONFIG_PAX_RANDKSTACK
18937 + movl %esp, %eax
18938 + call pax_randomize_kstack
18939 +#endif
18940 +
18941 + pax_erase_kstack
18942 +
18943 restore_all:
18944 TRACE_IRQS_IRET
18945 restore_all_notrace:
18946 @@ -583,14 +790,34 @@ ldt_ss:
18947 * compensating for the offset by changing to the ESPFIX segment with
18948 * a base address that matches for the difference.
18949 */
18950 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18951 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18952 mov %esp, %edx /* load kernel esp */
18953 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18954 mov %dx, %ax /* eax: new kernel esp */
18955 sub %eax, %edx /* offset (low word is 0) */
18956 +#ifdef CONFIG_SMP
18957 + movl PER_CPU_VAR(cpu_number), %ebx
18958 + shll $PAGE_SHIFT_asm, %ebx
18959 + addl $cpu_gdt_table, %ebx
18960 +#else
18961 + movl $cpu_gdt_table, %ebx
18962 +#endif
18963 shr $16, %edx
18964 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18965 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18966 +
18967 +#ifdef CONFIG_PAX_KERNEXEC
18968 + mov %cr0, %esi
18969 + btr $16, %esi
18970 + mov %esi, %cr0
18971 +#endif
18972 +
18973 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18974 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18975 +
18976 +#ifdef CONFIG_PAX_KERNEXEC
18977 + bts $16, %esi
18978 + mov %esi, %cr0
18979 +#endif
18980 +
18981 pushl_cfi $__ESPFIX_SS
18982 pushl_cfi %eax /* new kernel esp */
18983 /* Disable interrupts, but do not irqtrace this section: we
18984 @@ -619,20 +846,18 @@ work_resched:
18985 movl TI_flags(%ebp), %ecx
18986 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18987 # than syscall tracing?
18988 - jz restore_all
18989 + jz restore_all_pax
18990 testb $_TIF_NEED_RESCHED, %cl
18991 jnz work_resched
18992
18993 work_notifysig: # deal with pending signals and
18994 # notify-resume requests
18995 + movl %esp, %eax
18996 #ifdef CONFIG_VM86
18997 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18998 - movl %esp, %eax
18999 jne work_notifysig_v86 # returning to kernel-space or
19000 # vm86-space
19001 1:
19002 -#else
19003 - movl %esp, %eax
19004 #endif
19005 TRACE_IRQS_ON
19006 ENABLE_INTERRUPTS(CLBR_NONE)
19007 @@ -653,7 +878,7 @@ work_notifysig_v86:
19008 movl %eax, %esp
19009 jmp 1b
19010 #endif
19011 -END(work_pending)
19012 +ENDPROC(work_pending)
19013
19014 # perform syscall exit tracing
19015 ALIGN
19016 @@ -661,11 +886,14 @@ syscall_trace_entry:
19017 movl $-ENOSYS,PT_EAX(%esp)
19018 movl %esp, %eax
19019 call syscall_trace_enter
19020 +
19021 + pax_erase_kstack
19022 +
19023 /* What it returned is what we'll actually use. */
19024 cmpl $(NR_syscalls), %eax
19025 jnae syscall_call
19026 jmp syscall_exit
19027 -END(syscall_trace_entry)
19028 +ENDPROC(syscall_trace_entry)
19029
19030 # perform syscall exit tracing
19031 ALIGN
19032 @@ -678,21 +906,25 @@ syscall_exit_work:
19033 movl %esp, %eax
19034 call syscall_trace_leave
19035 jmp resume_userspace
19036 -END(syscall_exit_work)
19037 +ENDPROC(syscall_exit_work)
19038 CFI_ENDPROC
19039
19040 RING0_INT_FRAME # can't unwind into user space anyway
19041 syscall_fault:
19042 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19043 + push %ss
19044 + pop %ds
19045 +#endif
19046 ASM_CLAC
19047 GET_THREAD_INFO(%ebp)
19048 movl $-EFAULT,PT_EAX(%esp)
19049 jmp resume_userspace
19050 -END(syscall_fault)
19051 +ENDPROC(syscall_fault)
19052
19053 syscall_badsys:
19054 movl $-ENOSYS,PT_EAX(%esp)
19055 jmp resume_userspace
19056 -END(syscall_badsys)
19057 +ENDPROC(syscall_badsys)
19058 CFI_ENDPROC
19059 /*
19060 * End of kprobes section
19061 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
19062 * normal stack and adjusts ESP with the matching offset.
19063 */
19064 /* fixup the stack */
19065 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
19066 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
19067 +#ifdef CONFIG_SMP
19068 + movl PER_CPU_VAR(cpu_number), %ebx
19069 + shll $PAGE_SHIFT_asm, %ebx
19070 + addl $cpu_gdt_table, %ebx
19071 +#else
19072 + movl $cpu_gdt_table, %ebx
19073 +#endif
19074 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
19075 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
19076 shl $16, %eax
19077 addl %esp, %eax /* the adjusted stack pointer */
19078 pushl_cfi $__KERNEL_DS
19079 @@ -807,7 +1046,7 @@ vector=vector+1
19080 .endr
19081 2: jmp common_interrupt
19082 .endr
19083 -END(irq_entries_start)
19084 +ENDPROC(irq_entries_start)
19085
19086 .previous
19087 END(interrupt)
19088 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
19089 pushl_cfi $do_coprocessor_error
19090 jmp error_code
19091 CFI_ENDPROC
19092 -END(coprocessor_error)
19093 +ENDPROC(coprocessor_error)
19094
19095 ENTRY(simd_coprocessor_error)
19096 RING0_INT_FRAME
19097 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
19098 #endif
19099 jmp error_code
19100 CFI_ENDPROC
19101 -END(simd_coprocessor_error)
19102 +ENDPROC(simd_coprocessor_error)
19103
19104 ENTRY(device_not_available)
19105 RING0_INT_FRAME
19106 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19107 pushl_cfi $do_device_not_available
19108 jmp error_code
19109 CFI_ENDPROC
19110 -END(device_not_available)
19111 +ENDPROC(device_not_available)
19112
19113 #ifdef CONFIG_PARAVIRT
19114 ENTRY(native_iret)
19115 iret
19116 _ASM_EXTABLE(native_iret, iret_exc)
19117 -END(native_iret)
19118 +ENDPROC(native_iret)
19119
19120 ENTRY(native_irq_enable_sysexit)
19121 sti
19122 sysexit
19123 -END(native_irq_enable_sysexit)
19124 +ENDPROC(native_irq_enable_sysexit)
19125 #endif
19126
19127 ENTRY(overflow)
19128 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19129 pushl_cfi $do_overflow
19130 jmp error_code
19131 CFI_ENDPROC
19132 -END(overflow)
19133 +ENDPROC(overflow)
19134
19135 ENTRY(bounds)
19136 RING0_INT_FRAME
19137 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19138 pushl_cfi $do_bounds
19139 jmp error_code
19140 CFI_ENDPROC
19141 -END(bounds)
19142 +ENDPROC(bounds)
19143
19144 ENTRY(invalid_op)
19145 RING0_INT_FRAME
19146 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19147 pushl_cfi $do_invalid_op
19148 jmp error_code
19149 CFI_ENDPROC
19150 -END(invalid_op)
19151 +ENDPROC(invalid_op)
19152
19153 ENTRY(coprocessor_segment_overrun)
19154 RING0_INT_FRAME
19155 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19156 pushl_cfi $do_coprocessor_segment_overrun
19157 jmp error_code
19158 CFI_ENDPROC
19159 -END(coprocessor_segment_overrun)
19160 +ENDPROC(coprocessor_segment_overrun)
19161
19162 ENTRY(invalid_TSS)
19163 RING0_EC_FRAME
19164 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19165 pushl_cfi $do_invalid_TSS
19166 jmp error_code
19167 CFI_ENDPROC
19168 -END(invalid_TSS)
19169 +ENDPROC(invalid_TSS)
19170
19171 ENTRY(segment_not_present)
19172 RING0_EC_FRAME
19173 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19174 pushl_cfi $do_segment_not_present
19175 jmp error_code
19176 CFI_ENDPROC
19177 -END(segment_not_present)
19178 +ENDPROC(segment_not_present)
19179
19180 ENTRY(stack_segment)
19181 RING0_EC_FRAME
19182 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19183 pushl_cfi $do_stack_segment
19184 jmp error_code
19185 CFI_ENDPROC
19186 -END(stack_segment)
19187 +ENDPROC(stack_segment)
19188
19189 ENTRY(alignment_check)
19190 RING0_EC_FRAME
19191 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19192 pushl_cfi $do_alignment_check
19193 jmp error_code
19194 CFI_ENDPROC
19195 -END(alignment_check)
19196 +ENDPROC(alignment_check)
19197
19198 ENTRY(divide_error)
19199 RING0_INT_FRAME
19200 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19201 pushl_cfi $do_divide_error
19202 jmp error_code
19203 CFI_ENDPROC
19204 -END(divide_error)
19205 +ENDPROC(divide_error)
19206
19207 #ifdef CONFIG_X86_MCE
19208 ENTRY(machine_check)
19209 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19210 pushl_cfi machine_check_vector
19211 jmp error_code
19212 CFI_ENDPROC
19213 -END(machine_check)
19214 +ENDPROC(machine_check)
19215 #endif
19216
19217 ENTRY(spurious_interrupt_bug)
19218 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19219 pushl_cfi $do_spurious_interrupt_bug
19220 jmp error_code
19221 CFI_ENDPROC
19222 -END(spurious_interrupt_bug)
19223 +ENDPROC(spurious_interrupt_bug)
19224 /*
19225 * End of kprobes section
19226 */
19227 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19228
19229 ENTRY(mcount)
19230 ret
19231 -END(mcount)
19232 +ENDPROC(mcount)
19233
19234 ENTRY(ftrace_caller)
19235 cmpl $0, function_trace_stop
19236 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19237 .globl ftrace_stub
19238 ftrace_stub:
19239 ret
19240 -END(ftrace_caller)
19241 +ENDPROC(ftrace_caller)
19242
19243 ENTRY(ftrace_regs_caller)
19244 pushf /* push flags before compare (in cs location) */
19245 @@ -1235,7 +1474,7 @@ trace:
19246 popl %ecx
19247 popl %eax
19248 jmp ftrace_stub
19249 -END(mcount)
19250 +ENDPROC(mcount)
19251 #endif /* CONFIG_DYNAMIC_FTRACE */
19252 #endif /* CONFIG_FUNCTION_TRACER */
19253
19254 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19255 popl %ecx
19256 popl %eax
19257 ret
19258 -END(ftrace_graph_caller)
19259 +ENDPROC(ftrace_graph_caller)
19260
19261 .globl return_to_handler
19262 return_to_handler:
19263 @@ -1309,15 +1548,18 @@ error_code:
19264 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19265 REG_TO_PTGS %ecx
19266 SET_KERNEL_GS %ecx
19267 - movl $(__USER_DS), %ecx
19268 + movl $(__KERNEL_DS), %ecx
19269 movl %ecx, %ds
19270 movl %ecx, %es
19271 +
19272 + pax_enter_kernel
19273 +
19274 TRACE_IRQS_OFF
19275 movl %esp,%eax # pt_regs pointer
19276 call *%edi
19277 jmp ret_from_exception
19278 CFI_ENDPROC
19279 -END(page_fault)
19280 +ENDPROC(page_fault)
19281
19282 /*
19283 * Debug traps and NMI can happen at the one SYSENTER instruction
19284 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19285 call do_debug
19286 jmp ret_from_exception
19287 CFI_ENDPROC
19288 -END(debug)
19289 +ENDPROC(debug)
19290
19291 /*
19292 * NMI is doubly nasty. It can happen _while_ we're handling
19293 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19294 xorl %edx,%edx # zero error code
19295 movl %esp,%eax # pt_regs pointer
19296 call do_nmi
19297 +
19298 + pax_exit_kernel
19299 +
19300 jmp restore_all_notrace
19301 CFI_ENDPROC
19302
19303 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19304 FIXUP_ESPFIX_STACK # %eax == %esp
19305 xorl %edx,%edx # zero error code
19306 call do_nmi
19307 +
19308 + pax_exit_kernel
19309 +
19310 RESTORE_REGS
19311 lss 12+4(%esp), %esp # back to espfix stack
19312 CFI_ADJUST_CFA_OFFSET -24
19313 jmp irq_return
19314 CFI_ENDPROC
19315 -END(nmi)
19316 +ENDPROC(nmi)
19317
19318 ENTRY(int3)
19319 RING0_INT_FRAME
19320 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19321 call do_int3
19322 jmp ret_from_exception
19323 CFI_ENDPROC
19324 -END(int3)
19325 +ENDPROC(int3)
19326
19327 ENTRY(general_protection)
19328 RING0_EC_FRAME
19329 pushl_cfi $do_general_protection
19330 jmp error_code
19331 CFI_ENDPROC
19332 -END(general_protection)
19333 +ENDPROC(general_protection)
19334
19335 #ifdef CONFIG_KVM_GUEST
19336 ENTRY(async_page_fault)
19337 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19338 pushl_cfi $do_async_page_fault
19339 jmp error_code
19340 CFI_ENDPROC
19341 -END(async_page_fault)
19342 +ENDPROC(async_page_fault)
19343 #endif
19344
19345 /*
19346 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19347 index cb3c591..0617fa7 100644
19348 --- a/arch/x86/kernel/entry_64.S
19349 +++ b/arch/x86/kernel/entry_64.S
19350 @@ -59,6 +59,8 @@
19351 #include <asm/context_tracking.h>
19352 #include <asm/smap.h>
19353 #include <linux/err.h>
19354 +#include <asm/pgtable.h>
19355 +#include <asm/alternative-asm.h>
19356
19357 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19358 #include <linux/elf-em.h>
19359 @@ -80,8 +82,9 @@
19360 #ifdef CONFIG_DYNAMIC_FTRACE
19361
19362 ENTRY(function_hook)
19363 + pax_force_retaddr
19364 retq
19365 -END(function_hook)
19366 +ENDPROC(function_hook)
19367
19368 /* skip is set if stack has been adjusted */
19369 .macro ftrace_caller_setup skip=0
19370 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19371 #endif
19372
19373 GLOBAL(ftrace_stub)
19374 + pax_force_retaddr
19375 retq
19376 -END(ftrace_caller)
19377 +ENDPROC(ftrace_caller)
19378
19379 ENTRY(ftrace_regs_caller)
19380 /* Save the current flags before compare (in SS location)*/
19381 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19382 popfq
19383 jmp ftrace_stub
19384
19385 -END(ftrace_regs_caller)
19386 +ENDPROC(ftrace_regs_caller)
19387
19388
19389 #else /* ! CONFIG_DYNAMIC_FTRACE */
19390 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19391 #endif
19392
19393 GLOBAL(ftrace_stub)
19394 + pax_force_retaddr
19395 retq
19396
19397 trace:
19398 @@ -225,12 +230,13 @@ trace:
19399 #endif
19400 subq $MCOUNT_INSN_SIZE, %rdi
19401
19402 + pax_force_fptr ftrace_trace_function
19403 call *ftrace_trace_function
19404
19405 MCOUNT_RESTORE_FRAME
19406
19407 jmp ftrace_stub
19408 -END(function_hook)
19409 +ENDPROC(function_hook)
19410 #endif /* CONFIG_DYNAMIC_FTRACE */
19411 #endif /* CONFIG_FUNCTION_TRACER */
19412
19413 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19414
19415 MCOUNT_RESTORE_FRAME
19416
19417 + pax_force_retaddr
19418 retq
19419 -END(ftrace_graph_caller)
19420 +ENDPROC(ftrace_graph_caller)
19421
19422 GLOBAL(return_to_handler)
19423 subq $24, %rsp
19424 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19425 movq 8(%rsp), %rdx
19426 movq (%rsp), %rax
19427 addq $24, %rsp
19428 + pax_force_fptr %rdi
19429 jmp *%rdi
19430 +ENDPROC(return_to_handler)
19431 #endif
19432
19433
19434 @@ -284,6 +293,282 @@ ENTRY(native_usergs_sysret64)
19435 ENDPROC(native_usergs_sysret64)
19436 #endif /* CONFIG_PARAVIRT */
19437
19438 + .macro ljmpq sel, off
19439 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19440 + .byte 0x48; ljmp *1234f(%rip)
19441 + .pushsection .rodata
19442 + .align 16
19443 + 1234: .quad \off; .word \sel
19444 + .popsection
19445 +#else
19446 + pushq $\sel
19447 + pushq $\off
19448 + lretq
19449 +#endif
19450 + .endm
19451 +
19452 + .macro pax_enter_kernel
19453 + pax_set_fptr_mask
19454 +#ifdef CONFIG_PAX_KERNEXEC
19455 + call pax_enter_kernel
19456 +#endif
19457 + .endm
19458 +
19459 + .macro pax_exit_kernel
19460 +#ifdef CONFIG_PAX_KERNEXEC
19461 + call pax_exit_kernel
19462 +#endif
19463 + .endm
19464 +
19465 +#ifdef CONFIG_PAX_KERNEXEC
19466 +ENTRY(pax_enter_kernel)
19467 + pushq %rdi
19468 +
19469 +#ifdef CONFIG_PARAVIRT
19470 + PV_SAVE_REGS(CLBR_RDI)
19471 +#endif
19472 +
19473 + GET_CR0_INTO_RDI
19474 + bts $16,%rdi
19475 + jnc 3f
19476 + mov %cs,%edi
19477 + cmp $__KERNEL_CS,%edi
19478 + jnz 2f
19479 +1:
19480 +
19481 +#ifdef CONFIG_PARAVIRT
19482 + PV_RESTORE_REGS(CLBR_RDI)
19483 +#endif
19484 +
19485 + popq %rdi
19486 + pax_force_retaddr
19487 + retq
19488 +
19489 +2: ljmpq __KERNEL_CS,1b
19490 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19491 +4: SET_RDI_INTO_CR0
19492 + jmp 1b
19493 +ENDPROC(pax_enter_kernel)
19494 +
19495 +ENTRY(pax_exit_kernel)
19496 + pushq %rdi
19497 +
19498 +#ifdef CONFIG_PARAVIRT
19499 + PV_SAVE_REGS(CLBR_RDI)
19500 +#endif
19501 +
19502 + mov %cs,%rdi
19503 + cmp $__KERNEXEC_KERNEL_CS,%edi
19504 + jz 2f
19505 + GET_CR0_INTO_RDI
19506 + bts $16,%rdi
19507 + jnc 4f
19508 +1:
19509 +
19510 +#ifdef CONFIG_PARAVIRT
19511 + PV_RESTORE_REGS(CLBR_RDI);
19512 +#endif
19513 +
19514 + popq %rdi
19515 + pax_force_retaddr
19516 + retq
19517 +
19518 +2: GET_CR0_INTO_RDI
19519 + btr $16,%rdi
19520 + jnc 4f
19521 + ljmpq __KERNEL_CS,3f
19522 +3: SET_RDI_INTO_CR0
19523 + jmp 1b
19524 +4: ud2
19525 + jmp 4b
19526 +ENDPROC(pax_exit_kernel)
19527 +#endif
19528 +
19529 + .macro pax_enter_kernel_user
19530 + pax_set_fptr_mask
19531 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19532 + call pax_enter_kernel_user
19533 +#endif
19534 + .endm
19535 +
19536 + .macro pax_exit_kernel_user
19537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19538 + call pax_exit_kernel_user
19539 +#endif
19540 +#ifdef CONFIG_PAX_RANDKSTACK
19541 + pushq %rax
19542 + call pax_randomize_kstack
19543 + popq %rax
19544 +#endif
19545 + .endm
19546 +
19547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19548 +ENTRY(pax_enter_kernel_user)
19549 + pushq %rdi
19550 + pushq %rbx
19551 +
19552 +#ifdef CONFIG_PARAVIRT
19553 + PV_SAVE_REGS(CLBR_RDI)
19554 +#endif
19555 +
19556 + GET_CR3_INTO_RDI
19557 + mov %rdi,%rbx
19558 + add $__START_KERNEL_map,%rbx
19559 + sub phys_base(%rip),%rbx
19560 +
19561 +#ifdef CONFIG_PARAVIRT
19562 + pushq %rdi
19563 + cmpl $0, pv_info+PARAVIRT_enabled
19564 + jz 1f
19565 + i = 0
19566 + .rept USER_PGD_PTRS
19567 + mov i*8(%rbx),%rsi
19568 + mov $0,%sil
19569 + lea i*8(%rbx),%rdi
19570 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19571 + i = i + 1
19572 + .endr
19573 + jmp 2f
19574 +1:
19575 +#endif
19576 +
19577 + i = 0
19578 + .rept USER_PGD_PTRS
19579 + movb $0,i*8(%rbx)
19580 + i = i + 1
19581 + .endr
19582 +
19583 +#ifdef CONFIG_PARAVIRT
19584 +2: popq %rdi
19585 +#endif
19586 + SET_RDI_INTO_CR3
19587 +
19588 +#ifdef CONFIG_PAX_KERNEXEC
19589 + GET_CR0_INTO_RDI
19590 + bts $16,%rdi
19591 + SET_RDI_INTO_CR0
19592 +#endif
19593 +
19594 +#ifdef CONFIG_PARAVIRT
19595 + PV_RESTORE_REGS(CLBR_RDI)
19596 +#endif
19597 +
19598 + popq %rbx
19599 + popq %rdi
19600 + pax_force_retaddr
19601 + retq
19602 +ENDPROC(pax_enter_kernel_user)
19603 +
19604 +ENTRY(pax_exit_kernel_user)
19605 + push %rdi
19606 +
19607 +#ifdef CONFIG_PARAVIRT
19608 + pushq %rbx
19609 + PV_SAVE_REGS(CLBR_RDI)
19610 +#endif
19611 +
19612 +#ifdef CONFIG_PAX_KERNEXEC
19613 + GET_CR0_INTO_RDI
19614 + btr $16,%rdi
19615 + jnc 3f
19616 + SET_RDI_INTO_CR0
19617 +#endif
19618 +
19619 + GET_CR3_INTO_RDI
19620 + add $__START_KERNEL_map,%rdi
19621 + sub phys_base(%rip),%rdi
19622 +
19623 +#ifdef CONFIG_PARAVIRT
19624 + cmpl $0, pv_info+PARAVIRT_enabled
19625 + jz 1f
19626 + mov %rdi,%rbx
19627 + i = 0
19628 + .rept USER_PGD_PTRS
19629 + mov i*8(%rbx),%rsi
19630 + mov $0x67,%sil
19631 + lea i*8(%rbx),%rdi
19632 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19633 + i = i + 1
19634 + .endr
19635 + jmp 2f
19636 +1:
19637 +#endif
19638 +
19639 + i = 0
19640 + .rept USER_PGD_PTRS
19641 + movb $0x67,i*8(%rdi)
19642 + i = i + 1
19643 + .endr
19644 +
19645 +#ifdef CONFIG_PARAVIRT
19646 +2: PV_RESTORE_REGS(CLBR_RDI)
19647 + popq %rbx
19648 +#endif
19649 +
19650 + popq %rdi
19651 + pax_force_retaddr
19652 + retq
19653 +3: ud2
19654 + jmp 3b
19655 +ENDPROC(pax_exit_kernel_user)
19656 +#endif
19657 +
19658 +.macro pax_erase_kstack
19659 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19660 + call pax_erase_kstack
19661 +#endif
19662 +.endm
19663 +
19664 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19665 +ENTRY(pax_erase_kstack)
19666 + pushq %rdi
19667 + pushq %rcx
19668 + pushq %rax
19669 + pushq %r11
19670 +
19671 + GET_THREAD_INFO(%r11)
19672 + mov TI_lowest_stack(%r11), %rdi
19673 + mov $-0xBEEF, %rax
19674 + std
19675 +
19676 +1: mov %edi, %ecx
19677 + and $THREAD_SIZE_asm - 1, %ecx
19678 + shr $3, %ecx
19679 + repne scasq
19680 + jecxz 2f
19681 +
19682 + cmp $2*8, %ecx
19683 + jc 2f
19684 +
19685 + mov $2*8, %ecx
19686 + repe scasq
19687 + jecxz 2f
19688 + jne 1b
19689 +
19690 +2: cld
19691 + mov %esp, %ecx
19692 + sub %edi, %ecx
19693 +
19694 + cmp $THREAD_SIZE_asm, %rcx
19695 + jb 3f
19696 + ud2
19697 +3:
19698 +
19699 + shr $3, %ecx
19700 + rep stosq
19701 +
19702 + mov TI_task_thread_sp0(%r11), %rdi
19703 + sub $256, %rdi
19704 + mov %rdi, TI_lowest_stack(%r11)
19705 +
19706 + popq %r11
19707 + popq %rax
19708 + popq %rcx
19709 + popq %rdi
19710 + pax_force_retaddr
19711 + ret
19712 +ENDPROC(pax_erase_kstack)
19713 +#endif
19714
19715 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19716 #ifdef CONFIG_TRACE_IRQFLAGS
19717 @@ -375,8 +660,8 @@ ENDPROC(native_usergs_sysret64)
19718 .endm
19719
19720 .macro UNFAKE_STACK_FRAME
19721 - addq $8*6, %rsp
19722 - CFI_ADJUST_CFA_OFFSET -(6*8)
19723 + addq $8*6 + ARG_SKIP, %rsp
19724 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19725 .endm
19726
19727 /*
19728 @@ -463,7 +748,7 @@ ENDPROC(native_usergs_sysret64)
19729 movq %rsp, %rsi
19730
19731 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19732 - testl $3, CS-RBP(%rsi)
19733 + testb $3, CS-RBP(%rsi)
19734 je 1f
19735 SWAPGS
19736 /*
19737 @@ -498,9 +783,10 @@ ENTRY(save_rest)
19738 movq_cfi r15, R15+16
19739 movq %r11, 8(%rsp) /* return address */
19740 FIXUP_TOP_OF_STACK %r11, 16
19741 + pax_force_retaddr
19742 ret
19743 CFI_ENDPROC
19744 -END(save_rest)
19745 +ENDPROC(save_rest)
19746
19747 /* save complete stack frame */
19748 .pushsection .kprobes.text, "ax"
19749 @@ -529,9 +815,10 @@ ENTRY(save_paranoid)
19750 js 1f /* negative -> in kernel */
19751 SWAPGS
19752 xorl %ebx,%ebx
19753 -1: ret
19754 +1: pax_force_retaddr_bts
19755 + ret
19756 CFI_ENDPROC
19757 -END(save_paranoid)
19758 +ENDPROC(save_paranoid)
19759 .popsection
19760
19761 /*
19762 @@ -553,7 +840,7 @@ ENTRY(ret_from_fork)
19763
19764 RESTORE_REST
19765
19766 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19767 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19768 jz 1f
19769
19770 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19771 @@ -571,7 +858,7 @@ ENTRY(ret_from_fork)
19772 RESTORE_REST
19773 jmp int_ret_from_sys_call
19774 CFI_ENDPROC
19775 -END(ret_from_fork)
19776 +ENDPROC(ret_from_fork)
19777
19778 /*
19779 * System call entry. Up to 6 arguments in registers are supported.
19780 @@ -608,7 +895,7 @@ END(ret_from_fork)
19781 ENTRY(system_call)
19782 CFI_STARTPROC simple
19783 CFI_SIGNAL_FRAME
19784 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19785 + CFI_DEF_CFA rsp,0
19786 CFI_REGISTER rip,rcx
19787 /*CFI_REGISTER rflags,r11*/
19788 SWAPGS_UNSAFE_STACK
19789 @@ -621,16 +908,23 @@ GLOBAL(system_call_after_swapgs)
19790
19791 movq %rsp,PER_CPU_VAR(old_rsp)
19792 movq PER_CPU_VAR(kernel_stack),%rsp
19793 + SAVE_ARGS 8*6,0
19794 + pax_enter_kernel_user
19795 +
19796 +#ifdef CONFIG_PAX_RANDKSTACK
19797 + pax_erase_kstack
19798 +#endif
19799 +
19800 /*
19801 * No need to follow this irqs off/on section - it's straight
19802 * and short:
19803 */
19804 ENABLE_INTERRUPTS(CLBR_NONE)
19805 - SAVE_ARGS 8,0
19806 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19807 movq %rcx,RIP-ARGOFFSET(%rsp)
19808 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19809 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19810 + GET_THREAD_INFO(%rcx)
19811 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19812 jnz tracesys
19813 system_call_fastpath:
19814 #if __SYSCALL_MASK == ~0
19815 @@ -640,7 +934,7 @@ system_call_fastpath:
19816 cmpl $__NR_syscall_max,%eax
19817 #endif
19818 ja badsys
19819 - movq %r10,%rcx
19820 + movq R10-ARGOFFSET(%rsp),%rcx
19821 call *sys_call_table(,%rax,8) # XXX: rip relative
19822 movq %rax,RAX-ARGOFFSET(%rsp)
19823 /*
19824 @@ -654,10 +948,13 @@ sysret_check:
19825 LOCKDEP_SYS_EXIT
19826 DISABLE_INTERRUPTS(CLBR_NONE)
19827 TRACE_IRQS_OFF
19828 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19829 + GET_THREAD_INFO(%rcx)
19830 + movl TI_flags(%rcx),%edx
19831 andl %edi,%edx
19832 jnz sysret_careful
19833 CFI_REMEMBER_STATE
19834 + pax_exit_kernel_user
19835 + pax_erase_kstack
19836 /*
19837 * sysretq will re-enable interrupts:
19838 */
19839 @@ -709,14 +1006,18 @@ badsys:
19840 * jump back to the normal fast path.
19841 */
19842 auditsys:
19843 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19844 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19845 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19846 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19847 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19848 movq %rax,%rsi /* 2nd arg: syscall number */
19849 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19850 call __audit_syscall_entry
19851 +
19852 + pax_erase_kstack
19853 +
19854 LOAD_ARGS 0 /* reload call-clobbered registers */
19855 + pax_set_fptr_mask
19856 jmp system_call_fastpath
19857
19858 /*
19859 @@ -737,7 +1038,7 @@ sysret_audit:
19860 /* Do syscall tracing */
19861 tracesys:
19862 #ifdef CONFIG_AUDITSYSCALL
19863 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19864 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19865 jz auditsys
19866 #endif
19867 SAVE_REST
19868 @@ -745,12 +1046,16 @@ tracesys:
19869 FIXUP_TOP_OF_STACK %rdi
19870 movq %rsp,%rdi
19871 call syscall_trace_enter
19872 +
19873 + pax_erase_kstack
19874 +
19875 /*
19876 * Reload arg registers from stack in case ptrace changed them.
19877 * We don't reload %rax because syscall_trace_enter() returned
19878 * the value it wants us to use in the table lookup.
19879 */
19880 LOAD_ARGS ARGOFFSET, 1
19881 + pax_set_fptr_mask
19882 RESTORE_REST
19883 #if __SYSCALL_MASK == ~0
19884 cmpq $__NR_syscall_max,%rax
19885 @@ -759,7 +1064,7 @@ tracesys:
19886 cmpl $__NR_syscall_max,%eax
19887 #endif
19888 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19889 - movq %r10,%rcx /* fixup for C */
19890 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19891 call *sys_call_table(,%rax,8)
19892 movq %rax,RAX-ARGOFFSET(%rsp)
19893 /* Use IRET because user could have changed frame */
19894 @@ -780,7 +1085,9 @@ GLOBAL(int_with_check)
19895 andl %edi,%edx
19896 jnz int_careful
19897 andl $~TS_COMPAT,TI_status(%rcx)
19898 - jmp retint_swapgs
19899 + pax_exit_kernel_user
19900 + pax_erase_kstack
19901 + jmp retint_swapgs_pax
19902
19903 /* Either reschedule or signal or syscall exit tracking needed. */
19904 /* First do a reschedule test. */
19905 @@ -826,7 +1133,7 @@ int_restore_rest:
19906 TRACE_IRQS_OFF
19907 jmp int_with_check
19908 CFI_ENDPROC
19909 -END(system_call)
19910 +ENDPROC(system_call)
19911
19912 /*
19913 * Certain special system calls that need to save a complete full stack frame.
19914 @@ -842,7 +1149,7 @@ ENTRY(\label)
19915 call \func
19916 jmp ptregscall_common
19917 CFI_ENDPROC
19918 -END(\label)
19919 +ENDPROC(\label)
19920 .endm
19921
19922 .macro FORK_LIKE func
19923 @@ -856,9 +1163,10 @@ ENTRY(stub_\func)
19924 DEFAULT_FRAME 0 8 /* offset 8: return address */
19925 call sys_\func
19926 RESTORE_TOP_OF_STACK %r11, 8
19927 + pax_force_retaddr
19928 ret $REST_SKIP /* pop extended registers */
19929 CFI_ENDPROC
19930 -END(stub_\func)
19931 +ENDPROC(stub_\func)
19932 .endm
19933
19934 FORK_LIKE clone
19935 @@ -875,9 +1183,10 @@ ENTRY(ptregscall_common)
19936 movq_cfi_restore R12+8, r12
19937 movq_cfi_restore RBP+8, rbp
19938 movq_cfi_restore RBX+8, rbx
19939 + pax_force_retaddr
19940 ret $REST_SKIP /* pop extended registers */
19941 CFI_ENDPROC
19942 -END(ptregscall_common)
19943 +ENDPROC(ptregscall_common)
19944
19945 ENTRY(stub_execve)
19946 CFI_STARTPROC
19947 @@ -891,7 +1200,7 @@ ENTRY(stub_execve)
19948 RESTORE_REST
19949 jmp int_ret_from_sys_call
19950 CFI_ENDPROC
19951 -END(stub_execve)
19952 +ENDPROC(stub_execve)
19953
19954 /*
19955 * sigreturn is special because it needs to restore all registers on return.
19956 @@ -909,7 +1218,7 @@ ENTRY(stub_rt_sigreturn)
19957 RESTORE_REST
19958 jmp int_ret_from_sys_call
19959 CFI_ENDPROC
19960 -END(stub_rt_sigreturn)
19961 +ENDPROC(stub_rt_sigreturn)
19962
19963 #ifdef CONFIG_X86_X32_ABI
19964 ENTRY(stub_x32_rt_sigreturn)
19965 @@ -975,7 +1284,7 @@ vector=vector+1
19966 2: jmp common_interrupt
19967 .endr
19968 CFI_ENDPROC
19969 -END(irq_entries_start)
19970 +ENDPROC(irq_entries_start)
19971
19972 .previous
19973 END(interrupt)
19974 @@ -995,6 +1304,16 @@ END(interrupt)
19975 subq $ORIG_RAX-RBP, %rsp
19976 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19977 SAVE_ARGS_IRQ
19978 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19979 + testb $3, CS(%rdi)
19980 + jnz 1f
19981 + pax_enter_kernel
19982 + jmp 2f
19983 +1: pax_enter_kernel_user
19984 +2:
19985 +#else
19986 + pax_enter_kernel
19987 +#endif
19988 call \func
19989 .endm
19990
19991 @@ -1027,7 +1346,7 @@ ret_from_intr:
19992
19993 exit_intr:
19994 GET_THREAD_INFO(%rcx)
19995 - testl $3,CS-ARGOFFSET(%rsp)
19996 + testb $3,CS-ARGOFFSET(%rsp)
19997 je retint_kernel
19998
19999 /* Interrupt came from user space */
20000 @@ -1049,12 +1368,16 @@ retint_swapgs: /* return to user-space */
20001 * The iretq could re-enable interrupts:
20002 */
20003 DISABLE_INTERRUPTS(CLBR_ANY)
20004 + pax_exit_kernel_user
20005 +retint_swapgs_pax:
20006 TRACE_IRQS_IRETQ
20007 SWAPGS
20008 jmp restore_args
20009
20010 retint_restore_args: /* return to kernel space */
20011 DISABLE_INTERRUPTS(CLBR_ANY)
20012 + pax_exit_kernel
20013 + pax_force_retaddr (RIP-ARGOFFSET)
20014 /*
20015 * The iretq could re-enable interrupts:
20016 */
20017 @@ -1137,7 +1460,7 @@ ENTRY(retint_kernel)
20018 #endif
20019
20020 CFI_ENDPROC
20021 -END(common_interrupt)
20022 +ENDPROC(common_interrupt)
20023 /*
20024 * End of kprobes section
20025 */
20026 @@ -1155,7 +1478,7 @@ ENTRY(\sym)
20027 interrupt \do_sym
20028 jmp ret_from_intr
20029 CFI_ENDPROC
20030 -END(\sym)
20031 +ENDPROC(\sym)
20032 .endm
20033
20034 #ifdef CONFIG_SMP
20035 @@ -1211,12 +1534,22 @@ ENTRY(\sym)
20036 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20037 call error_entry
20038 DEFAULT_FRAME 0
20039 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20040 + testb $3, CS(%rsp)
20041 + jnz 1f
20042 + pax_enter_kernel
20043 + jmp 2f
20044 +1: pax_enter_kernel_user
20045 +2:
20046 +#else
20047 + pax_enter_kernel
20048 +#endif
20049 movq %rsp,%rdi /* pt_regs pointer */
20050 xorl %esi,%esi /* no error code */
20051 call \do_sym
20052 jmp error_exit /* %ebx: no swapgs flag */
20053 CFI_ENDPROC
20054 -END(\sym)
20055 +ENDPROC(\sym)
20056 .endm
20057
20058 .macro paranoidzeroentry sym do_sym
20059 @@ -1229,15 +1562,25 @@ ENTRY(\sym)
20060 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20061 call save_paranoid
20062 TRACE_IRQS_OFF
20063 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20064 + testb $3, CS(%rsp)
20065 + jnz 1f
20066 + pax_enter_kernel
20067 + jmp 2f
20068 +1: pax_enter_kernel_user
20069 +2:
20070 +#else
20071 + pax_enter_kernel
20072 +#endif
20073 movq %rsp,%rdi /* pt_regs pointer */
20074 xorl %esi,%esi /* no error code */
20075 call \do_sym
20076 jmp paranoid_exit /* %ebx: no swapgs flag */
20077 CFI_ENDPROC
20078 -END(\sym)
20079 +ENDPROC(\sym)
20080 .endm
20081
20082 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
20083 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
20084 .macro paranoidzeroentry_ist sym do_sym ist
20085 ENTRY(\sym)
20086 INTR_FRAME
20087 @@ -1248,14 +1591,30 @@ ENTRY(\sym)
20088 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20089 call save_paranoid
20090 TRACE_IRQS_OFF_DEBUG
20091 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20092 + testb $3, CS(%rsp)
20093 + jnz 1f
20094 + pax_enter_kernel
20095 + jmp 2f
20096 +1: pax_enter_kernel_user
20097 +2:
20098 +#else
20099 + pax_enter_kernel
20100 +#endif
20101 movq %rsp,%rdi /* pt_regs pointer */
20102 xorl %esi,%esi /* no error code */
20103 +#ifdef CONFIG_SMP
20104 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
20105 + lea init_tss(%r12), %r12
20106 +#else
20107 + lea init_tss(%rip), %r12
20108 +#endif
20109 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20110 call \do_sym
20111 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20112 jmp paranoid_exit /* %ebx: no swapgs flag */
20113 CFI_ENDPROC
20114 -END(\sym)
20115 +ENDPROC(\sym)
20116 .endm
20117
20118 .macro errorentry sym do_sym
20119 @@ -1267,13 +1626,23 @@ ENTRY(\sym)
20120 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20121 call error_entry
20122 DEFAULT_FRAME 0
20123 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20124 + testb $3, CS(%rsp)
20125 + jnz 1f
20126 + pax_enter_kernel
20127 + jmp 2f
20128 +1: pax_enter_kernel_user
20129 +2:
20130 +#else
20131 + pax_enter_kernel
20132 +#endif
20133 movq %rsp,%rdi /* pt_regs pointer */
20134 movq ORIG_RAX(%rsp),%rsi /* get error code */
20135 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20136 call \do_sym
20137 jmp error_exit /* %ebx: no swapgs flag */
20138 CFI_ENDPROC
20139 -END(\sym)
20140 +ENDPROC(\sym)
20141 .endm
20142
20143 /* error code is on the stack already */
20144 @@ -1287,13 +1656,23 @@ ENTRY(\sym)
20145 call save_paranoid
20146 DEFAULT_FRAME 0
20147 TRACE_IRQS_OFF
20148 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20149 + testb $3, CS(%rsp)
20150 + jnz 1f
20151 + pax_enter_kernel
20152 + jmp 2f
20153 +1: pax_enter_kernel_user
20154 +2:
20155 +#else
20156 + pax_enter_kernel
20157 +#endif
20158 movq %rsp,%rdi /* pt_regs pointer */
20159 movq ORIG_RAX(%rsp),%rsi /* get error code */
20160 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20161 call \do_sym
20162 jmp paranoid_exit /* %ebx: no swapgs flag */
20163 CFI_ENDPROC
20164 -END(\sym)
20165 +ENDPROC(\sym)
20166 .endm
20167
20168 zeroentry divide_error do_divide_error
20169 @@ -1323,9 +1702,10 @@ gs_change:
20170 2: mfence /* workaround */
20171 SWAPGS
20172 popfq_cfi
20173 + pax_force_retaddr
20174 ret
20175 CFI_ENDPROC
20176 -END(native_load_gs_index)
20177 +ENDPROC(native_load_gs_index)
20178
20179 _ASM_EXTABLE(gs_change,bad_gs)
20180 .section .fixup,"ax"
20181 @@ -1353,9 +1733,10 @@ ENTRY(call_softirq)
20182 CFI_DEF_CFA_REGISTER rsp
20183 CFI_ADJUST_CFA_OFFSET -8
20184 decl PER_CPU_VAR(irq_count)
20185 + pax_force_retaddr
20186 ret
20187 CFI_ENDPROC
20188 -END(call_softirq)
20189 +ENDPROC(call_softirq)
20190
20191 #ifdef CONFIG_XEN
20192 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20193 @@ -1393,7 +1774,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20194 decl PER_CPU_VAR(irq_count)
20195 jmp error_exit
20196 CFI_ENDPROC
20197 -END(xen_do_hypervisor_callback)
20198 +ENDPROC(xen_do_hypervisor_callback)
20199
20200 /*
20201 * Hypervisor uses this for application faults while it executes.
20202 @@ -1452,7 +1833,7 @@ ENTRY(xen_failsafe_callback)
20203 SAVE_ALL
20204 jmp error_exit
20205 CFI_ENDPROC
20206 -END(xen_failsafe_callback)
20207 +ENDPROC(xen_failsafe_callback)
20208
20209 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20210 xen_hvm_callback_vector xen_evtchn_do_upcall
20211 @@ -1501,16 +1882,31 @@ ENTRY(paranoid_exit)
20212 TRACE_IRQS_OFF_DEBUG
20213 testl %ebx,%ebx /* swapgs needed? */
20214 jnz paranoid_restore
20215 - testl $3,CS(%rsp)
20216 + testb $3,CS(%rsp)
20217 jnz paranoid_userspace
20218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20219 + pax_exit_kernel
20220 + TRACE_IRQS_IRETQ 0
20221 + SWAPGS_UNSAFE_STACK
20222 + RESTORE_ALL 8
20223 + pax_force_retaddr_bts
20224 + jmp irq_return
20225 +#endif
20226 paranoid_swapgs:
20227 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20228 + pax_exit_kernel_user
20229 +#else
20230 + pax_exit_kernel
20231 +#endif
20232 TRACE_IRQS_IRETQ 0
20233 SWAPGS_UNSAFE_STACK
20234 RESTORE_ALL 8
20235 jmp irq_return
20236 paranoid_restore:
20237 + pax_exit_kernel
20238 TRACE_IRQS_IRETQ_DEBUG 0
20239 RESTORE_ALL 8
20240 + pax_force_retaddr_bts
20241 jmp irq_return
20242 paranoid_userspace:
20243 GET_THREAD_INFO(%rcx)
20244 @@ -1539,7 +1935,7 @@ paranoid_schedule:
20245 TRACE_IRQS_OFF
20246 jmp paranoid_userspace
20247 CFI_ENDPROC
20248 -END(paranoid_exit)
20249 +ENDPROC(paranoid_exit)
20250
20251 /*
20252 * Exception entry point. This expects an error code/orig_rax on the stack.
20253 @@ -1566,12 +1962,13 @@ ENTRY(error_entry)
20254 movq_cfi r14, R14+8
20255 movq_cfi r15, R15+8
20256 xorl %ebx,%ebx
20257 - testl $3,CS+8(%rsp)
20258 + testb $3,CS+8(%rsp)
20259 je error_kernelspace
20260 error_swapgs:
20261 SWAPGS
20262 error_sti:
20263 TRACE_IRQS_OFF
20264 + pax_force_retaddr_bts
20265 ret
20266
20267 /*
20268 @@ -1598,7 +1995,7 @@ bstep_iret:
20269 movq %rcx,RIP+8(%rsp)
20270 jmp error_swapgs
20271 CFI_ENDPROC
20272 -END(error_entry)
20273 +ENDPROC(error_entry)
20274
20275
20276 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20277 @@ -1618,7 +2015,7 @@ ENTRY(error_exit)
20278 jnz retint_careful
20279 jmp retint_swapgs
20280 CFI_ENDPROC
20281 -END(error_exit)
20282 +ENDPROC(error_exit)
20283
20284 /*
20285 * Test if a given stack is an NMI stack or not.
20286 @@ -1676,9 +2073,11 @@ ENTRY(nmi)
20287 * If %cs was not the kernel segment, then the NMI triggered in user
20288 * space, which means it is definitely not nested.
20289 */
20290 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20291 + je 1f
20292 cmpl $__KERNEL_CS, 16(%rsp)
20293 jne first_nmi
20294 -
20295 +1:
20296 /*
20297 * Check the special variable on the stack to see if NMIs are
20298 * executing.
20299 @@ -1712,8 +2111,7 @@ nested_nmi:
20300
20301 1:
20302 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20303 - leaq -1*8(%rsp), %rdx
20304 - movq %rdx, %rsp
20305 + subq $8, %rsp
20306 CFI_ADJUST_CFA_OFFSET 1*8
20307 leaq -10*8(%rsp), %rdx
20308 pushq_cfi $__KERNEL_DS
20309 @@ -1731,6 +2129,7 @@ nested_nmi_out:
20310 CFI_RESTORE rdx
20311
20312 /* No need to check faults here */
20313 + pax_force_retaddr_bts
20314 INTERRUPT_RETURN
20315
20316 CFI_RESTORE_STATE
20317 @@ -1847,6 +2246,17 @@ end_repeat_nmi:
20318 */
20319 movq %cr2, %r12
20320
20321 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20322 + testb $3, CS(%rsp)
20323 + jnz 1f
20324 + pax_enter_kernel
20325 + jmp 2f
20326 +1: pax_enter_kernel_user
20327 +2:
20328 +#else
20329 + pax_enter_kernel
20330 +#endif
20331 +
20332 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20333 movq %rsp,%rdi
20334 movq $-1,%rsi
20335 @@ -1862,23 +2272,34 @@ end_repeat_nmi:
20336 testl %ebx,%ebx /* swapgs needed? */
20337 jnz nmi_restore
20338 nmi_swapgs:
20339 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20340 + pax_exit_kernel_user
20341 +#else
20342 + pax_exit_kernel
20343 +#endif
20344 SWAPGS_UNSAFE_STACK
20345 + RESTORE_ALL 6*8
20346 + /* Clear the NMI executing stack variable */
20347 + movq $0, 5*8(%rsp)
20348 + jmp irq_return
20349 nmi_restore:
20350 + pax_exit_kernel
20351 /* Pop the extra iret frame at once */
20352 RESTORE_ALL 6*8
20353 + pax_force_retaddr_bts
20354
20355 /* Clear the NMI executing stack variable */
20356 movq $0, 5*8(%rsp)
20357 jmp irq_return
20358 CFI_ENDPROC
20359 -END(nmi)
20360 +ENDPROC(nmi)
20361
20362 ENTRY(ignore_sysret)
20363 CFI_STARTPROC
20364 mov $-ENOSYS,%eax
20365 sysret
20366 CFI_ENDPROC
20367 -END(ignore_sysret)
20368 +ENDPROC(ignore_sysret)
20369
20370 /*
20371 * End of kprobes section
20372 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20373 index 1d41402..af9a46a 100644
20374 --- a/arch/x86/kernel/ftrace.c
20375 +++ b/arch/x86/kernel/ftrace.c
20376 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20377 {
20378 unsigned char replaced[MCOUNT_INSN_SIZE];
20379
20380 + ip = ktla_ktva(ip);
20381 +
20382 /*
20383 * Note: Due to modules and __init, code can
20384 * disappear and change, we need to protect against faulting
20385 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20386 unsigned char old[MCOUNT_INSN_SIZE], *new;
20387 int ret;
20388
20389 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20390 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20391 new = ftrace_call_replace(ip, (unsigned long)func);
20392
20393 /* See comment above by declaration of modifying_ftrace_code */
20394 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20395 /* Also update the regs callback function */
20396 if (!ret) {
20397 ip = (unsigned long)(&ftrace_regs_call);
20398 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20399 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20400 new = ftrace_call_replace(ip, (unsigned long)func);
20401 ret = ftrace_modify_code(ip, old, new);
20402 }
20403 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20404 * kernel identity mapping to modify code.
20405 */
20406 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20407 - ip = (unsigned long)__va(__pa(ip));
20408 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20409
20410 return probe_kernel_write((void *)ip, val, size);
20411 }
20412 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20413 unsigned char replaced[MCOUNT_INSN_SIZE];
20414 unsigned char brk = BREAKPOINT_INSTRUCTION;
20415
20416 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20417 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20418 return -EFAULT;
20419
20420 /* Make sure it is what we expect it to be */
20421 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20422 return ret;
20423
20424 fail_update:
20425 - probe_kernel_write((void *)ip, &old_code[0], 1);
20426 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20427 goto out;
20428 }
20429
20430 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20431 {
20432 unsigned char code[MCOUNT_INSN_SIZE];
20433
20434 + ip = ktla_ktva(ip);
20435 +
20436 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20437 return -EFAULT;
20438
20439 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20440 index c18f59d..9c0c9f6 100644
20441 --- a/arch/x86/kernel/head32.c
20442 +++ b/arch/x86/kernel/head32.c
20443 @@ -18,6 +18,7 @@
20444 #include <asm/io_apic.h>
20445 #include <asm/bios_ebda.h>
20446 #include <asm/tlbflush.h>
20447 +#include <asm/boot.h>
20448
20449 static void __init i386_default_early_setup(void)
20450 {
20451 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20452
20453 void __init i386_start_kernel(void)
20454 {
20455 - memblock_reserve(__pa_symbol(&_text),
20456 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20457 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20458
20459 #ifdef CONFIG_BLK_DEV_INITRD
20460 /* Reserve INITRD */
20461 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20462 index c8932c7..d56b622 100644
20463 --- a/arch/x86/kernel/head_32.S
20464 +++ b/arch/x86/kernel/head_32.S
20465 @@ -26,6 +26,12 @@
20466 /* Physical address */
20467 #define pa(X) ((X) - __PAGE_OFFSET)
20468
20469 +#ifdef CONFIG_PAX_KERNEXEC
20470 +#define ta(X) (X)
20471 +#else
20472 +#define ta(X) ((X) - __PAGE_OFFSET)
20473 +#endif
20474 +
20475 /*
20476 * References to members of the new_cpu_data structure.
20477 */
20478 @@ -55,11 +61,7 @@
20479 * and small than max_low_pfn, otherwise will waste some page table entries
20480 */
20481
20482 -#if PTRS_PER_PMD > 1
20483 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20484 -#else
20485 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20486 -#endif
20487 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20488
20489 /* Number of possible pages in the lowmem region */
20490 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20491 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20492 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20493
20494 /*
20495 + * Real beginning of normal "text" segment
20496 + */
20497 +ENTRY(stext)
20498 +ENTRY(_stext)
20499 +
20500 +/*
20501 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20502 * %esi points to the real-mode code as a 32-bit pointer.
20503 * CS and DS must be 4 GB flat segments, but we don't depend on
20504 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20505 * can.
20506 */
20507 __HEAD
20508 +
20509 +#ifdef CONFIG_PAX_KERNEXEC
20510 + jmp startup_32
20511 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20512 +.fill PAGE_SIZE-5,1,0xcc
20513 +#endif
20514 +
20515 ENTRY(startup_32)
20516 movl pa(stack_start),%ecx
20517
20518 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20519 2:
20520 leal -__PAGE_OFFSET(%ecx),%esp
20521
20522 +#ifdef CONFIG_SMP
20523 + movl $pa(cpu_gdt_table),%edi
20524 + movl $__per_cpu_load,%eax
20525 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20526 + rorl $16,%eax
20527 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20528 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20529 + movl $__per_cpu_end - 1,%eax
20530 + subl $__per_cpu_start,%eax
20531 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20532 +#endif
20533 +
20534 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20535 + movl $NR_CPUS,%ecx
20536 + movl $pa(cpu_gdt_table),%edi
20537 +1:
20538 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20539 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20540 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20541 + addl $PAGE_SIZE_asm,%edi
20542 + loop 1b
20543 +#endif
20544 +
20545 +#ifdef CONFIG_PAX_KERNEXEC
20546 + movl $pa(boot_gdt),%edi
20547 + movl $__LOAD_PHYSICAL_ADDR,%eax
20548 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20549 + rorl $16,%eax
20550 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20551 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20552 + rorl $16,%eax
20553 +
20554 + ljmp $(__BOOT_CS),$1f
20555 +1:
20556 +
20557 + movl $NR_CPUS,%ecx
20558 + movl $pa(cpu_gdt_table),%edi
20559 + addl $__PAGE_OFFSET,%eax
20560 +1:
20561 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20562 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20563 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20564 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20565 + rorl $16,%eax
20566 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20567 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20568 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20569 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20570 + rorl $16,%eax
20571 + addl $PAGE_SIZE_asm,%edi
20572 + loop 1b
20573 +#endif
20574 +
20575 /*
20576 * Clear BSS first so that there are no surprises...
20577 */
20578 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20579 movl %eax, pa(max_pfn_mapped)
20580
20581 /* Do early initialization of the fixmap area */
20582 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20583 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20584 +#ifdef CONFIG_COMPAT_VDSO
20585 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20586 +#else
20587 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20588 +#endif
20589 #else /* Not PAE */
20590
20591 page_pde_offset = (__PAGE_OFFSET >> 20);
20592 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20593 movl %eax, pa(max_pfn_mapped)
20594
20595 /* Do early initialization of the fixmap area */
20596 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20597 - movl %eax,pa(initial_page_table+0xffc)
20598 +#ifdef CONFIG_COMPAT_VDSO
20599 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20600 +#else
20601 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20602 +#endif
20603 #endif
20604
20605 #ifdef CONFIG_PARAVIRT
20606 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20607 cmpl $num_subarch_entries, %eax
20608 jae bad_subarch
20609
20610 - movl pa(subarch_entries)(,%eax,4), %eax
20611 - subl $__PAGE_OFFSET, %eax
20612 - jmp *%eax
20613 + jmp *pa(subarch_entries)(,%eax,4)
20614
20615 bad_subarch:
20616 WEAK(lguest_entry)
20617 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20618 __INITDATA
20619
20620 subarch_entries:
20621 - .long default_entry /* normal x86/PC */
20622 - .long lguest_entry /* lguest hypervisor */
20623 - .long xen_entry /* Xen hypervisor */
20624 - .long default_entry /* Moorestown MID */
20625 + .long ta(default_entry) /* normal x86/PC */
20626 + .long ta(lguest_entry) /* lguest hypervisor */
20627 + .long ta(xen_entry) /* Xen hypervisor */
20628 + .long ta(default_entry) /* Moorestown MID */
20629 num_subarch_entries = (. - subarch_entries) / 4
20630 .previous
20631 #else
20632 @@ -335,6 +407,7 @@ default_entry:
20633 movl pa(mmu_cr4_features),%eax
20634 movl %eax,%cr4
20635
20636 +#ifdef CONFIG_X86_PAE
20637 testb $X86_CR4_PAE, %al # check if PAE is enabled
20638 jz 6f
20639
20640 @@ -363,6 +436,9 @@ default_entry:
20641 /* Make changes effective */
20642 wrmsr
20643
20644 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20645 +#endif
20646 +
20647 6:
20648
20649 /*
20650 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20651 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20652 movl %eax,%ss # after changing gdt.
20653
20654 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20655 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20656 movl %eax,%ds
20657 movl %eax,%es
20658
20659 movl $(__KERNEL_PERCPU), %eax
20660 movl %eax,%fs # set this cpu's percpu
20661
20662 +#ifdef CONFIG_CC_STACKPROTECTOR
20663 movl $(__KERNEL_STACK_CANARY),%eax
20664 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20665 + movl $(__USER_DS),%eax
20666 +#else
20667 + xorl %eax,%eax
20668 +#endif
20669 movl %eax,%gs
20670
20671 xorl %eax,%eax # Clear LDT
20672 @@ -544,8 +626,11 @@ setup_once:
20673 * relocation. Manually set base address in stack canary
20674 * segment descriptor.
20675 */
20676 - movl $gdt_page,%eax
20677 + movl $cpu_gdt_table,%eax
20678 movl $stack_canary,%ecx
20679 +#ifdef CONFIG_SMP
20680 + addl $__per_cpu_load,%ecx
20681 +#endif
20682 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20683 shrl $16, %ecx
20684 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20685 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20686 /* This is global to keep gas from relaxing the jumps */
20687 ENTRY(early_idt_handler)
20688 cld
20689 - cmpl $2,%ss:early_recursion_flag
20690 + cmpl $1,%ss:early_recursion_flag
20691 je hlt_loop
20692 incl %ss:early_recursion_flag
20693
20694 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20695 pushl (20+6*4)(%esp) /* trapno */
20696 pushl $fault_msg
20697 call printk
20698 -#endif
20699 call dump_stack
20700 +#endif
20701 hlt_loop:
20702 hlt
20703 jmp hlt_loop
20704 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20705 /* This is the default interrupt "handler" :-) */
20706 ALIGN
20707 ignore_int:
20708 - cld
20709 #ifdef CONFIG_PRINTK
20710 + cmpl $2,%ss:early_recursion_flag
20711 + je hlt_loop
20712 + incl %ss:early_recursion_flag
20713 + cld
20714 pushl %eax
20715 pushl %ecx
20716 pushl %edx
20717 @@ -644,9 +732,6 @@ ignore_int:
20718 movl $(__KERNEL_DS),%eax
20719 movl %eax,%ds
20720 movl %eax,%es
20721 - cmpl $2,early_recursion_flag
20722 - je hlt_loop
20723 - incl early_recursion_flag
20724 pushl 16(%esp)
20725 pushl 24(%esp)
20726 pushl 32(%esp)
20727 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20728 /*
20729 * BSS section
20730 */
20731 -__PAGE_ALIGNED_BSS
20732 - .align PAGE_SIZE
20733 #ifdef CONFIG_X86_PAE
20734 +.section .initial_pg_pmd,"a",@progbits
20735 initial_pg_pmd:
20736 .fill 1024*KPMDS,4,0
20737 #else
20738 +.section .initial_page_table,"a",@progbits
20739 ENTRY(initial_page_table)
20740 .fill 1024,4,0
20741 #endif
20742 +.section .initial_pg_fixmap,"a",@progbits
20743 initial_pg_fixmap:
20744 .fill 1024,4,0
20745 +.section .empty_zero_page,"a",@progbits
20746 ENTRY(empty_zero_page)
20747 .fill 4096,1,0
20748 +.section .swapper_pg_dir,"a",@progbits
20749 ENTRY(swapper_pg_dir)
20750 +#ifdef CONFIG_X86_PAE
20751 + .fill 4,8,0
20752 +#else
20753 .fill 1024,4,0
20754 +#endif
20755 +
20756 +/*
20757 + * The IDT has to be page-aligned to simplify the Pentium
20758 + * F0 0F bug workaround.. We have a special link segment
20759 + * for this.
20760 + */
20761 +.section .idt,"a",@progbits
20762 +ENTRY(idt_table)
20763 + .fill 256,8,0
20764
20765 /*
20766 * This starts the data section.
20767 */
20768 #ifdef CONFIG_X86_PAE
20769 -__PAGE_ALIGNED_DATA
20770 - /* Page-aligned for the benefit of paravirt? */
20771 - .align PAGE_SIZE
20772 +.section .initial_page_table,"a",@progbits
20773 ENTRY(initial_page_table)
20774 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20775 # if KPMDS == 3
20776 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20777 # error "Kernel PMDs should be 1, 2 or 3"
20778 # endif
20779 .align PAGE_SIZE /* needs to be page-sized too */
20780 +
20781 +#ifdef CONFIG_PAX_PER_CPU_PGD
20782 +ENTRY(cpu_pgd)
20783 + .rept NR_CPUS
20784 + .fill 4,8,0
20785 + .endr
20786 +#endif
20787 +
20788 #endif
20789
20790 .data
20791 .balign 4
20792 ENTRY(stack_start)
20793 - .long init_thread_union+THREAD_SIZE
20794 + .long init_thread_union+THREAD_SIZE-8
20795
20796 __INITRODATA
20797 int_msg:
20798 @@ -754,7 +861,7 @@ fault_msg:
20799 * segment size, and 32-bit linear address value:
20800 */
20801
20802 - .data
20803 +.section .rodata,"a",@progbits
20804 .globl boot_gdt_descr
20805 .globl idt_descr
20806
20807 @@ -763,7 +870,7 @@ fault_msg:
20808 .word 0 # 32 bit align gdt_desc.address
20809 boot_gdt_descr:
20810 .word __BOOT_DS+7
20811 - .long boot_gdt - __PAGE_OFFSET
20812 + .long pa(boot_gdt)
20813
20814 .word 0 # 32-bit align idt_desc.address
20815 idt_descr:
20816 @@ -774,7 +881,7 @@ idt_descr:
20817 .word 0 # 32 bit align gdt_desc.address
20818 ENTRY(early_gdt_descr)
20819 .word GDT_ENTRIES*8-1
20820 - .long gdt_page /* Overwritten for secondary CPUs */
20821 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20822
20823 /*
20824 * The boot_gdt must mirror the equivalent in setup.S and is
20825 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20826 .align L1_CACHE_BYTES
20827 ENTRY(boot_gdt)
20828 .fill GDT_ENTRY_BOOT_CS,8,0
20829 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20830 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20831 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20832 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20833 +
20834 + .align PAGE_SIZE_asm
20835 +ENTRY(cpu_gdt_table)
20836 + .rept NR_CPUS
20837 + .quad 0x0000000000000000 /* NULL descriptor */
20838 + .quad 0x0000000000000000 /* 0x0b reserved */
20839 + .quad 0x0000000000000000 /* 0x13 reserved */
20840 + .quad 0x0000000000000000 /* 0x1b reserved */
20841 +
20842 +#ifdef CONFIG_PAX_KERNEXEC
20843 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20844 +#else
20845 + .quad 0x0000000000000000 /* 0x20 unused */
20846 +#endif
20847 +
20848 + .quad 0x0000000000000000 /* 0x28 unused */
20849 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20850 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20851 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20852 + .quad 0x0000000000000000 /* 0x4b reserved */
20853 + .quad 0x0000000000000000 /* 0x53 reserved */
20854 + .quad 0x0000000000000000 /* 0x5b reserved */
20855 +
20856 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20857 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20858 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20859 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20860 +
20861 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20862 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20863 +
20864 + /*
20865 + * Segments used for calling PnP BIOS have byte granularity.
20866 + * The code segments and data segments have fixed 64k limits,
20867 + * the transfer segment sizes are set at run time.
20868 + */
20869 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20870 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20871 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20872 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20873 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20874 +
20875 + /*
20876 + * The APM segments have byte granularity and their bases
20877 + * are set at run time. All have 64k limits.
20878 + */
20879 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20880 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20881 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20882 +
20883 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20884 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20885 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20886 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20887 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20888 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20889 +
20890 + /* Be sure this is zeroed to avoid false validations in Xen */
20891 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20892 + .endr
20893 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20894 index 980053c..74d3b44 100644
20895 --- a/arch/x86/kernel/head_64.S
20896 +++ b/arch/x86/kernel/head_64.S
20897 @@ -20,6 +20,8 @@
20898 #include <asm/processor-flags.h>
20899 #include <asm/percpu.h>
20900 #include <asm/nops.h>
20901 +#include <asm/cpufeature.h>
20902 +#include <asm/alternative-asm.h>
20903
20904 #ifdef CONFIG_PARAVIRT
20905 #include <asm/asm-offsets.h>
20906 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20907 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20908 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20909 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20910 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20911 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20912 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20913 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20914 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20915 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20916
20917 .text
20918 __HEAD
20919 @@ -88,35 +96,23 @@ startup_64:
20920 */
20921 addq %rbp, init_level4_pgt + 0(%rip)
20922 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20923 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20924 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20925 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20926 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20927
20928 addq %rbp, level3_ident_pgt + 0(%rip)
20929 +#ifndef CONFIG_XEN
20930 + addq %rbp, level3_ident_pgt + 8(%rip)
20931 +#endif
20932
20933 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20934 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20935 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20936 +
20937 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20938 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20939
20940 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20941 -
20942 - /* Add an Identity mapping if I am above 1G */
20943 - leaq _text(%rip), %rdi
20944 - andq $PMD_PAGE_MASK, %rdi
20945 -
20946 - movq %rdi, %rax
20947 - shrq $PUD_SHIFT, %rax
20948 - andq $(PTRS_PER_PUD - 1), %rax
20949 - jz ident_complete
20950 -
20951 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20952 - leaq level3_ident_pgt(%rip), %rbx
20953 - movq %rdx, 0(%rbx, %rax, 8)
20954 -
20955 - movq %rdi, %rax
20956 - shrq $PMD_SHIFT, %rax
20957 - andq $(PTRS_PER_PMD - 1), %rax
20958 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20959 - leaq level2_spare_pgt(%rip), %rbx
20960 - movq %rdx, 0(%rbx, %rax, 8)
20961 -ident_complete:
20962 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20963
20964 /*
20965 * Fixup the kernel text+data virtual addresses. Note that
20966 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20967 * after the boot processor executes this code.
20968 */
20969
20970 - /* Enable PAE mode and PGE */
20971 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20972 + /* Enable PAE mode and PSE/PGE */
20973 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20974 movq %rax, %cr4
20975
20976 /* Setup early boot stage 4 level pagetables. */
20977 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20978 movl $MSR_EFER, %ecx
20979 rdmsr
20980 btsl $_EFER_SCE, %eax /* Enable System Call */
20981 - btl $20,%edi /* No Execute supported? */
20982 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20983 jnc 1f
20984 btsl $_EFER_NX, %eax
20985 + leaq init_level4_pgt(%rip), %rdi
20986 +#ifndef CONFIG_EFI
20987 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20988 +#endif
20989 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20990 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20991 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20992 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20993 1: wrmsr /* Make changes effective */
20994
20995 /* Setup cr0 */
20996 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20997 * jump. In addition we need to ensure %cs is set so we make this
20998 * a far return.
20999 */
21000 + pax_set_fptr_mask
21001 movq initial_code(%rip),%rax
21002 pushq $0 # fake return address to stop unwinder
21003 pushq $__KERNEL_CS # set correct cs
21004 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
21005 bad_address:
21006 jmp bad_address
21007
21008 - .section ".init.text","ax"
21009 + __INIT
21010 .globl early_idt_handlers
21011 early_idt_handlers:
21012 # 104(%rsp) %rflags
21013 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
21014 call dump_stack
21015 #ifdef CONFIG_KALLSYMS
21016 leaq early_idt_ripmsg(%rip),%rdi
21017 - movq 40(%rsp),%rsi # %rip again
21018 + movq 88(%rsp),%rsi # %rip again
21019 call __print_symbol
21020 #endif
21021 #endif /* EARLY_PRINTK */
21022 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
21023 addq $16,%rsp # drop vector number and error code
21024 decl early_recursion_flag(%rip)
21025 INTERRUPT_RETURN
21026 + .previous
21027
21028 + __INITDATA
21029 .balign 4
21030 early_recursion_flag:
21031 .long 0
21032 + .previous
21033
21034 + .section .rodata,"a",@progbits
21035 #ifdef CONFIG_EARLY_PRINTK
21036 early_idt_msg:
21037 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
21038 @@ -376,6 +385,7 @@ early_idt_ripmsg:
21039 #endif /* CONFIG_EARLY_PRINTK */
21040 .previous
21041
21042 + .section .rodata,"a",@progbits
21043 #define NEXT_PAGE(name) \
21044 .balign PAGE_SIZE; \
21045 ENTRY(name)
21046 @@ -388,7 +398,6 @@ ENTRY(name)
21047 i = i + 1 ; \
21048 .endr
21049
21050 - .data
21051 /*
21052 * This default setting generates an ident mapping at address 0x100000
21053 * and a mapping for the kernel that precisely maps virtual address
21054 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
21055 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21056 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
21057 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21058 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
21059 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
21060 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
21061 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
21062 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
21063 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21064 .org init_level4_pgt + L4_START_KERNEL*8, 0
21065 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
21066 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
21067
21068 +#ifdef CONFIG_PAX_PER_CPU_PGD
21069 +NEXT_PAGE(cpu_pgd)
21070 + .rept NR_CPUS
21071 + .fill 512,8,0
21072 + .endr
21073 +#endif
21074 +
21075 NEXT_PAGE(level3_ident_pgt)
21076 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
21077 +#ifdef CONFIG_XEN
21078 .fill 511,8,0
21079 +#else
21080 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
21081 + .fill 510,8,0
21082 +#endif
21083 +
21084 +NEXT_PAGE(level3_vmalloc_start_pgt)
21085 + .fill 512,8,0
21086 +
21087 +NEXT_PAGE(level3_vmalloc_end_pgt)
21088 + .fill 512,8,0
21089 +
21090 +NEXT_PAGE(level3_vmemmap_pgt)
21091 + .fill L3_VMEMMAP_START,8,0
21092 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21093
21094 NEXT_PAGE(level3_kernel_pgt)
21095 .fill L3_START_KERNEL,8,0
21096 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
21097 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
21098 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21099
21100 +NEXT_PAGE(level2_vmemmap_pgt)
21101 + .fill 512,8,0
21102 +
21103 NEXT_PAGE(level2_fixmap_pgt)
21104 - .fill 506,8,0
21105 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21106 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21107 - .fill 5,8,0
21108 + .fill 507,8,0
21109 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21110 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21111 + .fill 4,8,0
21112
21113 -NEXT_PAGE(level1_fixmap_pgt)
21114 +NEXT_PAGE(level1_vsyscall_pgt)
21115 .fill 512,8,0
21116
21117 -NEXT_PAGE(level2_ident_pgt)
21118 - /* Since I easily can, map the first 1G.
21119 + /* Since I easily can, map the first 2G.
21120 * Don't set NX because code runs from these pages.
21121 */
21122 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21123 +NEXT_PAGE(level2_ident_pgt)
21124 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21125
21126 NEXT_PAGE(level2_kernel_pgt)
21127 /*
21128 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21129 * If you want to increase this then increase MODULES_VADDR
21130 * too.)
21131 */
21132 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21133 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21134 -
21135 -NEXT_PAGE(level2_spare_pgt)
21136 - .fill 512, 8, 0
21137 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21138
21139 #undef PMDS
21140 #undef NEXT_PAGE
21141
21142 - .data
21143 + .align PAGE_SIZE
21144 +ENTRY(cpu_gdt_table)
21145 + .rept NR_CPUS
21146 + .quad 0x0000000000000000 /* NULL descriptor */
21147 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21148 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21149 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21150 + .quad 0x00cffb000000ffff /* __USER32_CS */
21151 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21152 + .quad 0x00affb000000ffff /* __USER_CS */
21153 +
21154 +#ifdef CONFIG_PAX_KERNEXEC
21155 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21156 +#else
21157 + .quad 0x0 /* unused */
21158 +#endif
21159 +
21160 + .quad 0,0 /* TSS */
21161 + .quad 0,0 /* LDT */
21162 + .quad 0,0,0 /* three TLS descriptors */
21163 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21164 + /* asm/segment.h:GDT_ENTRIES must match this */
21165 +
21166 + /* zero the remaining page */
21167 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21168 + .endr
21169 +
21170 .align 16
21171 .globl early_gdt_descr
21172 early_gdt_descr:
21173 .word GDT_ENTRIES*8-1
21174 early_gdt_descr_base:
21175 - .quad INIT_PER_CPU_VAR(gdt_page)
21176 + .quad cpu_gdt_table
21177
21178 ENTRY(phys_base)
21179 /* This must match the first entry in level2_kernel_pgt */
21180 .quad 0x0000000000000000
21181
21182 #include "../../x86/xen/xen-head.S"
21183 -
21184 - .section .bss, "aw", @nobits
21185 +
21186 + .section .rodata,"a",@progbits
21187 .align L1_CACHE_BYTES
21188 ENTRY(idt_table)
21189 - .skip IDT_ENTRIES * 16
21190 + .fill 512,8,0
21191
21192 .align L1_CACHE_BYTES
21193 ENTRY(nmi_idt_table)
21194 - .skip IDT_ENTRIES * 16
21195 + .fill 512,8,0
21196
21197 __PAGE_ALIGNED_BSS
21198 .align PAGE_SIZE
21199 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21200 index 9c3bd4a..e1d9b35 100644
21201 --- a/arch/x86/kernel/i386_ksyms_32.c
21202 +++ b/arch/x86/kernel/i386_ksyms_32.c
21203 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21204 EXPORT_SYMBOL(cmpxchg8b_emu);
21205 #endif
21206
21207 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21208 +
21209 /* Networking helper routines. */
21210 EXPORT_SYMBOL(csum_partial_copy_generic);
21211 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21212 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21213
21214 EXPORT_SYMBOL(__get_user_1);
21215 EXPORT_SYMBOL(__get_user_2);
21216 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21217
21218 EXPORT_SYMBOL(csum_partial);
21219 EXPORT_SYMBOL(empty_zero_page);
21220 +
21221 +#ifdef CONFIG_PAX_KERNEXEC
21222 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21223 +#endif
21224 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21225 index 245a71d..89d9ce4 100644
21226 --- a/arch/x86/kernel/i387.c
21227 +++ b/arch/x86/kernel/i387.c
21228 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21229 static inline bool interrupted_user_mode(void)
21230 {
21231 struct pt_regs *regs = get_irq_regs();
21232 - return regs && user_mode_vm(regs);
21233 + return regs && user_mode(regs);
21234 }
21235
21236 /*
21237 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21238 index 9a5c460..84868423 100644
21239 --- a/arch/x86/kernel/i8259.c
21240 +++ b/arch/x86/kernel/i8259.c
21241 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
21242 static void make_8259A_irq(unsigned int irq)
21243 {
21244 disable_irq_nosync(irq);
21245 - io_apic_irqs &= ~(1<<irq);
21246 + io_apic_irqs &= ~(1UL<<irq);
21247 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
21248 i8259A_chip.name);
21249 enable_irq(irq);
21250 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21251 "spurious 8259A interrupt: IRQ%d.\n", irq);
21252 spurious_irq_mask |= irqmask;
21253 }
21254 - atomic_inc(&irq_err_count);
21255 + atomic_inc_unchecked(&irq_err_count);
21256 /*
21257 * Theoretically we do not have to handle this IRQ,
21258 * but in Linux this does not cause problems and is
21259 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21260 /* (slave's support for AEOI in flat mode is to be investigated) */
21261 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21262
21263 + pax_open_kernel();
21264 if (auto_eoi)
21265 /*
21266 * In AEOI mode we just have to mask the interrupt
21267 * when acking.
21268 */
21269 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21270 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21271 else
21272 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21273 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21274 + pax_close_kernel();
21275
21276 udelay(100); /* wait for 8259A to initialize */
21277
21278 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21279 index a979b5b..1d6db75 100644
21280 --- a/arch/x86/kernel/io_delay.c
21281 +++ b/arch/x86/kernel/io_delay.c
21282 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21283 * Quirk table for systems that misbehave (lock up, etc.) if port
21284 * 0x80 is used:
21285 */
21286 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21287 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21288 {
21289 .callback = dmi_io_delay_0xed_port,
21290 .ident = "Compaq Presario V6000",
21291 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21292 index 8c96897..be66bfa 100644
21293 --- a/arch/x86/kernel/ioport.c
21294 +++ b/arch/x86/kernel/ioport.c
21295 @@ -6,6 +6,7 @@
21296 #include <linux/sched.h>
21297 #include <linux/kernel.h>
21298 #include <linux/capability.h>
21299 +#include <linux/security.h>
21300 #include <linux/errno.h>
21301 #include <linux/types.h>
21302 #include <linux/ioport.h>
21303 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21304
21305 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21306 return -EINVAL;
21307 +#ifdef CONFIG_GRKERNSEC_IO
21308 + if (turn_on && grsec_disable_privio) {
21309 + gr_handle_ioperm();
21310 + return -EPERM;
21311 + }
21312 +#endif
21313 if (turn_on && !capable(CAP_SYS_RAWIO))
21314 return -EPERM;
21315
21316 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21317 * because the ->io_bitmap_max value must match the bitmap
21318 * contents:
21319 */
21320 - tss = &per_cpu(init_tss, get_cpu());
21321 + tss = init_tss + get_cpu();
21322
21323 if (turn_on)
21324 bitmap_clear(t->io_bitmap_ptr, from, num);
21325 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21326 return -EINVAL;
21327 /* Trying to gain more privileges? */
21328 if (level > old) {
21329 +#ifdef CONFIG_GRKERNSEC_IO
21330 + if (grsec_disable_privio) {
21331 + gr_handle_iopl();
21332 + return -EPERM;
21333 + }
21334 +#endif
21335 if (!capable(CAP_SYS_RAWIO))
21336 return -EPERM;
21337 }
21338 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21339 index 84b7789..e65e8be 100644
21340 --- a/arch/x86/kernel/irq.c
21341 +++ b/arch/x86/kernel/irq.c
21342 @@ -18,7 +18,7 @@
21343 #include <asm/mce.h>
21344 #include <asm/hw_irq.h>
21345
21346 -atomic_t irq_err_count;
21347 +atomic_unchecked_t irq_err_count;
21348
21349 /* Function pointer for generic interrupt vector handling */
21350 void (*x86_platform_ipi_callback)(void) = NULL;
21351 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21352 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21353 seq_printf(p, " Machine check polls\n");
21354 #endif
21355 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21356 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21357 #if defined(CONFIG_X86_IO_APIC)
21358 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21359 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21360 #endif
21361 return 0;
21362 }
21363 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21364
21365 u64 arch_irq_stat(void)
21366 {
21367 - u64 sum = atomic_read(&irq_err_count);
21368 + u64 sum = atomic_read_unchecked(&irq_err_count);
21369 return sum;
21370 }
21371
21372 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21373 index 344faf8..355f60d 100644
21374 --- a/arch/x86/kernel/irq_32.c
21375 +++ b/arch/x86/kernel/irq_32.c
21376 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21377 __asm__ __volatile__("andl %%esp,%0" :
21378 "=r" (sp) : "0" (THREAD_SIZE - 1));
21379
21380 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21381 + return sp < STACK_WARN;
21382 }
21383
21384 static void print_stack_overflow(void)
21385 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21386 * per-CPU IRQ handling contexts (thread information and stack)
21387 */
21388 union irq_ctx {
21389 - struct thread_info tinfo;
21390 - u32 stack[THREAD_SIZE/sizeof(u32)];
21391 + unsigned long previous_esp;
21392 + u32 stack[THREAD_SIZE/sizeof(u32)];
21393 } __attribute__((aligned(THREAD_SIZE)));
21394
21395 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21396 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21397 static inline int
21398 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21399 {
21400 - union irq_ctx *curctx, *irqctx;
21401 + union irq_ctx *irqctx;
21402 u32 *isp, arg1, arg2;
21403
21404 - curctx = (union irq_ctx *) current_thread_info();
21405 irqctx = __this_cpu_read(hardirq_ctx);
21406
21407 /*
21408 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21409 * handler) we can't do that and just have to keep using the
21410 * current stack (which is the irq stack already after all)
21411 */
21412 - if (unlikely(curctx == irqctx))
21413 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21414 return 0;
21415
21416 /* build the stack frame on the IRQ stack */
21417 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21418 - irqctx->tinfo.task = curctx->tinfo.task;
21419 - irqctx->tinfo.previous_esp = current_stack_pointer;
21420 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21421 + irqctx->previous_esp = current_stack_pointer;
21422
21423 - /* Copy the preempt_count so that the [soft]irq checks work. */
21424 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21425 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21426 + __set_fs(MAKE_MM_SEG(0));
21427 +#endif
21428
21429 if (unlikely(overflow))
21430 call_on_stack(print_stack_overflow, isp);
21431 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21432 : "0" (irq), "1" (desc), "2" (isp),
21433 "D" (desc->handle_irq)
21434 : "memory", "cc", "ecx");
21435 +
21436 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21437 + __set_fs(current_thread_info()->addr_limit);
21438 +#endif
21439 +
21440 return 1;
21441 }
21442
21443 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21444 */
21445 void __cpuinit irq_ctx_init(int cpu)
21446 {
21447 - union irq_ctx *irqctx;
21448 -
21449 if (per_cpu(hardirq_ctx, cpu))
21450 return;
21451
21452 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21453 - THREADINFO_GFP,
21454 - THREAD_SIZE_ORDER));
21455 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21456 - irqctx->tinfo.cpu = cpu;
21457 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21458 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21459 -
21460 - per_cpu(hardirq_ctx, cpu) = irqctx;
21461 -
21462 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21463 - THREADINFO_GFP,
21464 - THREAD_SIZE_ORDER));
21465 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21466 - irqctx->tinfo.cpu = cpu;
21467 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21468 -
21469 - per_cpu(softirq_ctx, cpu) = irqctx;
21470 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21471 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21472 +
21473 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21474 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21475
21476 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21477 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21478 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21479 asmlinkage void do_softirq(void)
21480 {
21481 unsigned long flags;
21482 - struct thread_info *curctx;
21483 union irq_ctx *irqctx;
21484 u32 *isp;
21485
21486 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21487 local_irq_save(flags);
21488
21489 if (local_softirq_pending()) {
21490 - curctx = current_thread_info();
21491 irqctx = __this_cpu_read(softirq_ctx);
21492 - irqctx->tinfo.task = curctx->task;
21493 - irqctx->tinfo.previous_esp = current_stack_pointer;
21494 + irqctx->previous_esp = current_stack_pointer;
21495
21496 /* build the stack frame on the softirq stack */
21497 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21498 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21499 +
21500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21501 + __set_fs(MAKE_MM_SEG(0));
21502 +#endif
21503
21504 call_on_stack(__do_softirq, isp);
21505 +
21506 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21507 + __set_fs(current_thread_info()->addr_limit);
21508 +#endif
21509 +
21510 /*
21511 * Shouldn't happen, we returned above if in_interrupt():
21512 */
21513 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21514 if (unlikely(!desc))
21515 return false;
21516
21517 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21518 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21519 if (unlikely(overflow))
21520 print_stack_overflow();
21521 desc->handle_irq(irq, desc);
21522 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21523 index d04d3ec..ea4b374 100644
21524 --- a/arch/x86/kernel/irq_64.c
21525 +++ b/arch/x86/kernel/irq_64.c
21526 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21527 u64 estack_top, estack_bottom;
21528 u64 curbase = (u64)task_stack_page(current);
21529
21530 - if (user_mode_vm(regs))
21531 + if (user_mode(regs))
21532 return;
21533
21534 if (regs->sp >= curbase + sizeof(struct thread_info) +
21535 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21536 index dc1404b..bbc43e7 100644
21537 --- a/arch/x86/kernel/kdebugfs.c
21538 +++ b/arch/x86/kernel/kdebugfs.c
21539 @@ -27,7 +27,7 @@ struct setup_data_node {
21540 u32 len;
21541 };
21542
21543 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21544 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21545 size_t count, loff_t *ppos)
21546 {
21547 struct setup_data_node *node = file->private_data;
21548 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21549 index 836f832..a8bda67 100644
21550 --- a/arch/x86/kernel/kgdb.c
21551 +++ b/arch/x86/kernel/kgdb.c
21552 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21553 #ifdef CONFIG_X86_32
21554 switch (regno) {
21555 case GDB_SS:
21556 - if (!user_mode_vm(regs))
21557 + if (!user_mode(regs))
21558 *(unsigned long *)mem = __KERNEL_DS;
21559 break;
21560 case GDB_SP:
21561 - if (!user_mode_vm(regs))
21562 + if (!user_mode(regs))
21563 *(unsigned long *)mem = kernel_stack_pointer(regs);
21564 break;
21565 case GDB_GS:
21566 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21567 bp->attr.bp_addr = breakinfo[breakno].addr;
21568 bp->attr.bp_len = breakinfo[breakno].len;
21569 bp->attr.bp_type = breakinfo[breakno].type;
21570 - info->address = breakinfo[breakno].addr;
21571 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21572 + info->address = ktla_ktva(breakinfo[breakno].addr);
21573 + else
21574 + info->address = breakinfo[breakno].addr;
21575 info->len = breakinfo[breakno].len;
21576 info->type = breakinfo[breakno].type;
21577 val = arch_install_hw_breakpoint(bp);
21578 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21579 case 'k':
21580 /* clear the trace bit */
21581 linux_regs->flags &= ~X86_EFLAGS_TF;
21582 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21583 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21584
21585 /* set the trace bit if we're stepping */
21586 if (remcomInBuffer[0] == 's') {
21587 linux_regs->flags |= X86_EFLAGS_TF;
21588 - atomic_set(&kgdb_cpu_doing_single_step,
21589 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21590 raw_smp_processor_id());
21591 }
21592
21593 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21594
21595 switch (cmd) {
21596 case DIE_DEBUG:
21597 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21598 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21599 if (user_mode(regs))
21600 return single_step_cont(regs, args);
21601 break;
21602 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21603 #endif /* CONFIG_DEBUG_RODATA */
21604
21605 bpt->type = BP_BREAKPOINT;
21606 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21607 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21608 BREAK_INSTR_SIZE);
21609 if (err)
21610 return err;
21611 - err = probe_kernel_write((char *)bpt->bpt_addr,
21612 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21613 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21614 #ifdef CONFIG_DEBUG_RODATA
21615 if (!err)
21616 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21617 return -EBUSY;
21618 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21619 BREAK_INSTR_SIZE);
21620 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21621 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21622 if (err)
21623 return err;
21624 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21625 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21626 if (mutex_is_locked(&text_mutex))
21627 goto knl_write;
21628 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21629 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21630 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21631 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21632 goto knl_write;
21633 return err;
21634 knl_write:
21635 #endif /* CONFIG_DEBUG_RODATA */
21636 - return probe_kernel_write((char *)bpt->bpt_addr,
21637 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21638 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21639 }
21640
21641 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21642 index c5e410e..ed5a7f0 100644
21643 --- a/arch/x86/kernel/kprobes-opt.c
21644 +++ b/arch/x86/kernel/kprobes-opt.c
21645 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21646 * Verify if the address gap is in 2GB range, because this uses
21647 * a relative jump.
21648 */
21649 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21650 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21651 if (abs(rel) > 0x7fffffff)
21652 return -ERANGE;
21653
21654 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21655 op->optinsn.size = ret;
21656
21657 /* Copy arch-dep-instance from template */
21658 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21659 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21660
21661 /* Set probe information */
21662 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21663
21664 /* Set probe function call */
21665 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21666 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21667
21668 /* Set returning jmp instruction at the tail of out-of-line buffer */
21669 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21670 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21671 (u8 *)op->kp.addr + op->optinsn.size);
21672
21673 flush_icache_range((unsigned long) buf,
21674 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21675 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21676
21677 /* Backup instructions which will be replaced by jump address */
21678 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21679 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21680 RELATIVE_ADDR_SIZE);
21681
21682 insn_buf[0] = RELATIVEJUMP_OPCODE;
21683 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21684 /* This kprobe is really able to run optimized path. */
21685 op = container_of(p, struct optimized_kprobe, kp);
21686 /* Detour through copied instructions */
21687 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21688 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21689 if (!reenter)
21690 reset_current_kprobe();
21691 preempt_enable_no_resched();
21692 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21693 index 57916c0..9e0b9d0 100644
21694 --- a/arch/x86/kernel/kprobes.c
21695 +++ b/arch/x86/kernel/kprobes.c
21696 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21697 s32 raddr;
21698 } __attribute__((packed)) *insn;
21699
21700 - insn = (struct __arch_relative_insn *)from;
21701 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21702 +
21703 + pax_open_kernel();
21704 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21705 insn->op = op;
21706 + pax_close_kernel();
21707 }
21708
21709 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21710 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21711 kprobe_opcode_t opcode;
21712 kprobe_opcode_t *orig_opcodes = opcodes;
21713
21714 - if (search_exception_tables((unsigned long)opcodes))
21715 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21716 return 0; /* Page fault may occur on this address. */
21717
21718 retry:
21719 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21720 * for the first byte, we can recover the original instruction
21721 * from it and kp->opcode.
21722 */
21723 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21724 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21725 buf[0] = kp->opcode;
21726 - return (unsigned long)buf;
21727 + return ktva_ktla((unsigned long)buf);
21728 }
21729
21730 /*
21731 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21732 /* Another subsystem puts a breakpoint, failed to recover */
21733 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21734 return 0;
21735 + pax_open_kernel();
21736 memcpy(dest, insn.kaddr, insn.length);
21737 + pax_close_kernel();
21738
21739 #ifdef CONFIG_X86_64
21740 if (insn_rip_relative(&insn)) {
21741 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21742 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21743 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21744 disp = (u8 *) dest + insn_offset_displacement(&insn);
21745 + pax_open_kernel();
21746 *(s32 *) disp = (s32) newdisp;
21747 + pax_close_kernel();
21748 }
21749 #endif
21750 return insn.length;
21751 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21752 * nor set current_kprobe, because it doesn't use single
21753 * stepping.
21754 */
21755 - regs->ip = (unsigned long)p->ainsn.insn;
21756 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21757 preempt_enable_no_resched();
21758 return;
21759 }
21760 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21761 regs->flags &= ~X86_EFLAGS_IF;
21762 /* single step inline if the instruction is an int3 */
21763 if (p->opcode == BREAKPOINT_INSTRUCTION)
21764 - regs->ip = (unsigned long)p->addr;
21765 + regs->ip = ktla_ktva((unsigned long)p->addr);
21766 else
21767 - regs->ip = (unsigned long)p->ainsn.insn;
21768 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21769 }
21770
21771 /*
21772 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21773 setup_singlestep(p, regs, kcb, 0);
21774 return 1;
21775 }
21776 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21777 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21778 /*
21779 * The breakpoint instruction was removed right
21780 * after we hit it. Another cpu has removed
21781 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21782 " movq %rax, 152(%rsp)\n"
21783 RESTORE_REGS_STRING
21784 " popfq\n"
21785 +#ifdef KERNEXEC_PLUGIN
21786 + " btsq $63,(%rsp)\n"
21787 +#endif
21788 #else
21789 " pushf\n"
21790 SAVE_REGS_STRING
21791 @@ -788,7 +798,7 @@ static void __kprobes
21792 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21793 {
21794 unsigned long *tos = stack_addr(regs);
21795 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21796 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21797 unsigned long orig_ip = (unsigned long)p->addr;
21798 kprobe_opcode_t *insn = p->ainsn.insn;
21799
21800 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21801 struct die_args *args = data;
21802 int ret = NOTIFY_DONE;
21803
21804 - if (args->regs && user_mode_vm(args->regs))
21805 + if (args->regs && user_mode(args->regs))
21806 return ret;
21807
21808 switch (val) {
21809 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21810 index 9c2bd8b..bb1131c 100644
21811 --- a/arch/x86/kernel/kvm.c
21812 +++ b/arch/x86/kernel/kvm.c
21813 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21814 return NOTIFY_OK;
21815 }
21816
21817 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21818 +static struct notifier_block kvm_cpu_notifier = {
21819 .notifier_call = kvm_cpu_notify,
21820 };
21821 #endif
21822 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21823 index ebc9873..1b9724b 100644
21824 --- a/arch/x86/kernel/ldt.c
21825 +++ b/arch/x86/kernel/ldt.c
21826 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21827 if (reload) {
21828 #ifdef CONFIG_SMP
21829 preempt_disable();
21830 - load_LDT(pc);
21831 + load_LDT_nolock(pc);
21832 if (!cpumask_equal(mm_cpumask(current->mm),
21833 cpumask_of(smp_processor_id())))
21834 smp_call_function(flush_ldt, current->mm, 1);
21835 preempt_enable();
21836 #else
21837 - load_LDT(pc);
21838 + load_LDT_nolock(pc);
21839 #endif
21840 }
21841 if (oldsize) {
21842 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21843 return err;
21844
21845 for (i = 0; i < old->size; i++)
21846 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21847 + write_ldt_entry(new->ldt, i, old->ldt + i);
21848 return 0;
21849 }
21850
21851 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21852 retval = copy_ldt(&mm->context, &old_mm->context);
21853 mutex_unlock(&old_mm->context.lock);
21854 }
21855 +
21856 + if (tsk == current) {
21857 + mm->context.vdso = 0;
21858 +
21859 +#ifdef CONFIG_X86_32
21860 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21861 + mm->context.user_cs_base = 0UL;
21862 + mm->context.user_cs_limit = ~0UL;
21863 +
21864 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21865 + cpus_clear(mm->context.cpu_user_cs_mask);
21866 +#endif
21867 +
21868 +#endif
21869 +#endif
21870 +
21871 + }
21872 +
21873 return retval;
21874 }
21875
21876 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21877 }
21878 }
21879
21880 +#ifdef CONFIG_PAX_SEGMEXEC
21881 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21882 + error = -EINVAL;
21883 + goto out_unlock;
21884 + }
21885 +#endif
21886 +
21887 fill_ldt(&ldt, &ldt_info);
21888 if (oldmode)
21889 ldt.avl = 0;
21890 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21891 index 5b19e4d..6476a76 100644
21892 --- a/arch/x86/kernel/machine_kexec_32.c
21893 +++ b/arch/x86/kernel/machine_kexec_32.c
21894 @@ -26,7 +26,7 @@
21895 #include <asm/cacheflush.h>
21896 #include <asm/debugreg.h>
21897
21898 -static void set_idt(void *newidt, __u16 limit)
21899 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21900 {
21901 struct desc_ptr curidt;
21902
21903 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21904 }
21905
21906
21907 -static void set_gdt(void *newgdt, __u16 limit)
21908 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21909 {
21910 struct desc_ptr curgdt;
21911
21912 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21913 }
21914
21915 control_page = page_address(image->control_code_page);
21916 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21917 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21918
21919 relocate_kernel_ptr = control_page;
21920 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21921 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21922 index 3a04b22..1d2eb09 100644
21923 --- a/arch/x86/kernel/microcode_core.c
21924 +++ b/arch/x86/kernel/microcode_core.c
21925 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21926 return NOTIFY_OK;
21927 }
21928
21929 -static struct notifier_block __refdata mc_cpu_notifier = {
21930 +static struct notifier_block mc_cpu_notifier = {
21931 .notifier_call = mc_cpu_callback,
21932 };
21933
21934 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21935 index 3544aed..01ddc1c 100644
21936 --- a/arch/x86/kernel/microcode_intel.c
21937 +++ b/arch/x86/kernel/microcode_intel.c
21938 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21939
21940 static int get_ucode_user(void *to, const void *from, size_t n)
21941 {
21942 - return copy_from_user(to, from, n);
21943 + return copy_from_user(to, (const void __force_user *)from, n);
21944 }
21945
21946 static enum ucode_state
21947 request_microcode_user(int cpu, const void __user *buf, size_t size)
21948 {
21949 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21950 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21951 }
21952
21953 static void microcode_fini_cpu(int cpu)
21954 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21955 index 216a4d7..228255a 100644
21956 --- a/arch/x86/kernel/module.c
21957 +++ b/arch/x86/kernel/module.c
21958 @@ -43,15 +43,60 @@ do { \
21959 } while (0)
21960 #endif
21961
21962 -void *module_alloc(unsigned long size)
21963 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21964 {
21965 - if (PAGE_ALIGN(size) > MODULES_LEN)
21966 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21967 return NULL;
21968 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21969 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21970 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21971 -1, __builtin_return_address(0));
21972 }
21973
21974 +void *module_alloc(unsigned long size)
21975 +{
21976 +
21977 +#ifdef CONFIG_PAX_KERNEXEC
21978 + return __module_alloc(size, PAGE_KERNEL);
21979 +#else
21980 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21981 +#endif
21982 +
21983 +}
21984 +
21985 +#ifdef CONFIG_PAX_KERNEXEC
21986 +#ifdef CONFIG_X86_32
21987 +void *module_alloc_exec(unsigned long size)
21988 +{
21989 + struct vm_struct *area;
21990 +
21991 + if (size == 0)
21992 + return NULL;
21993 +
21994 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21995 + return area ? area->addr : NULL;
21996 +}
21997 +EXPORT_SYMBOL(module_alloc_exec);
21998 +
21999 +void module_free_exec(struct module *mod, void *module_region)
22000 +{
22001 + vunmap(module_region);
22002 +}
22003 +EXPORT_SYMBOL(module_free_exec);
22004 +#else
22005 +void module_free_exec(struct module *mod, void *module_region)
22006 +{
22007 + module_free(mod, module_region);
22008 +}
22009 +EXPORT_SYMBOL(module_free_exec);
22010 +
22011 +void *module_alloc_exec(unsigned long size)
22012 +{
22013 + return __module_alloc(size, PAGE_KERNEL_RX);
22014 +}
22015 +EXPORT_SYMBOL(module_alloc_exec);
22016 +#endif
22017 +#endif
22018 +
22019 #ifdef CONFIG_X86_32
22020 int apply_relocate(Elf32_Shdr *sechdrs,
22021 const char *strtab,
22022 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22023 unsigned int i;
22024 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
22025 Elf32_Sym *sym;
22026 - uint32_t *location;
22027 + uint32_t *plocation, location;
22028
22029 DEBUGP("Applying relocate section %u to %u\n",
22030 relsec, sechdrs[relsec].sh_info);
22031 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
22032 /* This is where to make the change */
22033 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
22034 - + rel[i].r_offset;
22035 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
22036 + location = (uint32_t)plocation;
22037 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
22038 + plocation = ktla_ktva((void *)plocation);
22039 /* This is the symbol it is referring to. Note that all
22040 undefined symbols have been resolved. */
22041 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
22042 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
22043 switch (ELF32_R_TYPE(rel[i].r_info)) {
22044 case R_386_32:
22045 /* We add the value into the location given */
22046 - *location += sym->st_value;
22047 + pax_open_kernel();
22048 + *plocation += sym->st_value;
22049 + pax_close_kernel();
22050 break;
22051 case R_386_PC32:
22052 /* Add the value, subtract its position */
22053 - *location += sym->st_value - (uint32_t)location;
22054 + pax_open_kernel();
22055 + *plocation += sym->st_value - location;
22056 + pax_close_kernel();
22057 break;
22058 default:
22059 pr_err("%s: Unknown relocation: %u\n",
22060 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
22061 case R_X86_64_NONE:
22062 break;
22063 case R_X86_64_64:
22064 + pax_open_kernel();
22065 *(u64 *)loc = val;
22066 + pax_close_kernel();
22067 break;
22068 case R_X86_64_32:
22069 + pax_open_kernel();
22070 *(u32 *)loc = val;
22071 + pax_close_kernel();
22072 if (val != *(u32 *)loc)
22073 goto overflow;
22074 break;
22075 case R_X86_64_32S:
22076 + pax_open_kernel();
22077 *(s32 *)loc = val;
22078 + pax_close_kernel();
22079 if ((s64)val != *(s32 *)loc)
22080 goto overflow;
22081 break;
22082 case R_X86_64_PC32:
22083 val -= (u64)loc;
22084 + pax_open_kernel();
22085 *(u32 *)loc = val;
22086 + pax_close_kernel();
22087 +
22088 #if 0
22089 if ((s64)val != *(s32 *)loc)
22090 goto overflow;
22091 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
22092 index 4929502..686c291 100644
22093 --- a/arch/x86/kernel/msr.c
22094 +++ b/arch/x86/kernel/msr.c
22095 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
22096 return notifier_from_errno(err);
22097 }
22098
22099 -static struct notifier_block __refdata msr_class_cpu_notifier = {
22100 +static struct notifier_block msr_class_cpu_notifier = {
22101 .notifier_call = msr_class_cpu_callback,
22102 };
22103
22104 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
22105 index f84f5c5..f404e81 100644
22106 --- a/arch/x86/kernel/nmi.c
22107 +++ b/arch/x86/kernel/nmi.c
22108 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22109 return handled;
22110 }
22111
22112 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22113 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22114 {
22115 struct nmi_desc *desc = nmi_to_desc(type);
22116 unsigned long flags;
22117 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22118 * event confuses some handlers (kdump uses this flag)
22119 */
22120 if (action->flags & NMI_FLAG_FIRST)
22121 - list_add_rcu(&action->list, &desc->head);
22122 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22123 else
22124 - list_add_tail_rcu(&action->list, &desc->head);
22125 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22126
22127 spin_unlock_irqrestore(&desc->lock, flags);
22128 return 0;
22129 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22130 if (!strcmp(n->name, name)) {
22131 WARN(in_nmi(),
22132 "Trying to free NMI (%s) from NMI context!\n", n->name);
22133 - list_del_rcu(&n->list);
22134 + pax_list_del_rcu((struct list_head *)&n->list);
22135 break;
22136 }
22137 }
22138 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22139 dotraplinkage notrace __kprobes void
22140 do_nmi(struct pt_regs *regs, long error_code)
22141 {
22142 +
22143 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22144 + if (!user_mode(regs)) {
22145 + unsigned long cs = regs->cs & 0xFFFF;
22146 + unsigned long ip = ktva_ktla(regs->ip);
22147 +
22148 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22149 + regs->ip = ip;
22150 + }
22151 +#endif
22152 +
22153 nmi_nesting_preprocess(regs);
22154
22155 nmi_enter();
22156 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22157 index 6d9582e..f746287 100644
22158 --- a/arch/x86/kernel/nmi_selftest.c
22159 +++ b/arch/x86/kernel/nmi_selftest.c
22160 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22161 {
22162 /* trap all the unknown NMIs we may generate */
22163 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22164 - __initdata);
22165 + __initconst);
22166 }
22167
22168 static void __init cleanup_nmi_testsuite(void)
22169 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22170 unsigned long timeout;
22171
22172 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22173 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22174 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22175 nmi_fail = FAILURE;
22176 return;
22177 }
22178 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22179 index 676b8c7..870ba04 100644
22180 --- a/arch/x86/kernel/paravirt-spinlocks.c
22181 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22182 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22183 arch_spin_lock(lock);
22184 }
22185
22186 -struct pv_lock_ops pv_lock_ops = {
22187 +struct pv_lock_ops pv_lock_ops __read_only = {
22188 #ifdef CONFIG_SMP
22189 .spin_is_locked = __ticket_spin_is_locked,
22190 .spin_is_contended = __ticket_spin_is_contended,
22191 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22192 index 8bfb335..c1463c6 100644
22193 --- a/arch/x86/kernel/paravirt.c
22194 +++ b/arch/x86/kernel/paravirt.c
22195 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22196 {
22197 return x;
22198 }
22199 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22200 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22201 +#endif
22202
22203 void __init default_banner(void)
22204 {
22205 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22206 if (opfunc == NULL)
22207 /* If there's no function, patch it with a ud2a (BUG) */
22208 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22209 - else if (opfunc == _paravirt_nop)
22210 + else if (opfunc == (void *)_paravirt_nop)
22211 /* If the operation is a nop, then nop the callsite */
22212 ret = paravirt_patch_nop();
22213
22214 /* identity functions just return their single argument */
22215 - else if (opfunc == _paravirt_ident_32)
22216 + else if (opfunc == (void *)_paravirt_ident_32)
22217 ret = paravirt_patch_ident_32(insnbuf, len);
22218 - else if (opfunc == _paravirt_ident_64)
22219 + else if (opfunc == (void *)_paravirt_ident_64)
22220 ret = paravirt_patch_ident_64(insnbuf, len);
22221 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22222 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22223 + ret = paravirt_patch_ident_64(insnbuf, len);
22224 +#endif
22225
22226 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22227 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22228 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22229 if (insn_len > len || start == NULL)
22230 insn_len = len;
22231 else
22232 - memcpy(insnbuf, start, insn_len);
22233 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22234
22235 return insn_len;
22236 }
22237 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
22238 return this_cpu_read(paravirt_lazy_mode);
22239 }
22240
22241 -struct pv_info pv_info = {
22242 +struct pv_info pv_info __read_only = {
22243 .name = "bare hardware",
22244 .paravirt_enabled = 0,
22245 .kernel_rpl = 0,
22246 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22247 #endif
22248 };
22249
22250 -struct pv_init_ops pv_init_ops = {
22251 +struct pv_init_ops pv_init_ops __read_only = {
22252 .patch = native_patch,
22253 };
22254
22255 -struct pv_time_ops pv_time_ops = {
22256 +struct pv_time_ops pv_time_ops __read_only = {
22257 .sched_clock = native_sched_clock,
22258 .steal_clock = native_steal_clock,
22259 };
22260
22261 -struct pv_irq_ops pv_irq_ops = {
22262 +struct pv_irq_ops pv_irq_ops __read_only = {
22263 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22264 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22265 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22266 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22267 #endif
22268 };
22269
22270 -struct pv_cpu_ops pv_cpu_ops = {
22271 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22272 .cpuid = native_cpuid,
22273 .get_debugreg = native_get_debugreg,
22274 .set_debugreg = native_set_debugreg,
22275 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22276 .end_context_switch = paravirt_nop,
22277 };
22278
22279 -struct pv_apic_ops pv_apic_ops = {
22280 +struct pv_apic_ops pv_apic_ops __read_only= {
22281 #ifdef CONFIG_X86_LOCAL_APIC
22282 .startup_ipi_hook = paravirt_nop,
22283 #endif
22284 };
22285
22286 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22287 +#ifdef CONFIG_X86_32
22288 +#ifdef CONFIG_X86_PAE
22289 +/* 64-bit pagetable entries */
22290 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22291 +#else
22292 /* 32-bit pagetable entries */
22293 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22294 +#endif
22295 #else
22296 /* 64-bit pagetable entries */
22297 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22298 #endif
22299
22300 -struct pv_mmu_ops pv_mmu_ops = {
22301 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22302
22303 .read_cr2 = native_read_cr2,
22304 .write_cr2 = native_write_cr2,
22305 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22306 .make_pud = PTE_IDENT,
22307
22308 .set_pgd = native_set_pgd,
22309 + .set_pgd_batched = native_set_pgd_batched,
22310 #endif
22311 #endif /* PAGETABLE_LEVELS >= 3 */
22312
22313 @@ -479,6 +492,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22314 },
22315
22316 .set_fixmap = native_set_fixmap,
22317 +
22318 +#ifdef CONFIG_PAX_KERNEXEC
22319 + .pax_open_kernel = native_pax_open_kernel,
22320 + .pax_close_kernel = native_pax_close_kernel,
22321 +#endif
22322 +
22323 };
22324
22325 EXPORT_SYMBOL_GPL(pv_time_ops);
22326 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
22327 index 299d493..2ccb0ee 100644
22328 --- a/arch/x86/kernel/pci-calgary_64.c
22329 +++ b/arch/x86/kernel/pci-calgary_64.c
22330 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
22331 tce_space = be64_to_cpu(readq(target));
22332 tce_space = tce_space & TAR_SW_BITS;
22333
22334 - tce_space = tce_space & (~specified_table_size);
22335 + tce_space = tce_space & (~(unsigned long)specified_table_size);
22336 info->tce_space = (u64 *)__va(tce_space);
22337 }
22338 }
22339 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22340 index 35ccf75..7a15747 100644
22341 --- a/arch/x86/kernel/pci-iommu_table.c
22342 +++ b/arch/x86/kernel/pci-iommu_table.c
22343 @@ -2,7 +2,7 @@
22344 #include <asm/iommu_table.h>
22345 #include <linux/string.h>
22346 #include <linux/kallsyms.h>
22347 -
22348 +#include <linux/sched.h>
22349
22350 #define DEBUG 1
22351
22352 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22353 index 6c483ba..d10ce2f 100644
22354 --- a/arch/x86/kernel/pci-swiotlb.c
22355 +++ b/arch/x86/kernel/pci-swiotlb.c
22356 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22357 void *vaddr, dma_addr_t dma_addr,
22358 struct dma_attrs *attrs)
22359 {
22360 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22361 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22362 }
22363
22364 static struct dma_map_ops swiotlb_dma_ops = {
22365 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22366 index 2ed787f..f70c9f6 100644
22367 --- a/arch/x86/kernel/process.c
22368 +++ b/arch/x86/kernel/process.c
22369 @@ -36,7 +36,8 @@
22370 * section. Since TSS's are completely CPU-local, we want them
22371 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22372 */
22373 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22374 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22375 +EXPORT_SYMBOL(init_tss);
22376
22377 #ifdef CONFIG_X86_64
22378 static DEFINE_PER_CPU(unsigned char, is_idle);
22379 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22380 task_xstate_cachep =
22381 kmem_cache_create("task_xstate", xstate_size,
22382 __alignof__(union thread_xstate),
22383 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22384 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22385 }
22386
22387 /*
22388 @@ -105,7 +106,7 @@ void exit_thread(void)
22389 unsigned long *bp = t->io_bitmap_ptr;
22390
22391 if (bp) {
22392 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22393 + struct tss_struct *tss = init_tss + get_cpu();
22394
22395 t->io_bitmap_ptr = NULL;
22396 clear_thread_flag(TIF_IO_BITMAP);
22397 @@ -136,7 +137,7 @@ void show_regs_common(void)
22398 board = dmi_get_system_info(DMI_BOARD_NAME);
22399
22400 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22401 - current->pid, current->comm, print_tainted(),
22402 + task_pid_nr(current), current->comm, print_tainted(),
22403 init_utsname()->release,
22404 (int)strcspn(init_utsname()->version, " "),
22405 init_utsname()->version,
22406 @@ -149,6 +150,9 @@ void flush_thread(void)
22407 {
22408 struct task_struct *tsk = current;
22409
22410 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22411 + loadsegment(gs, 0);
22412 +#endif
22413 flush_ptrace_hw_breakpoint(tsk);
22414 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22415 drop_init_fpu(tsk);
22416 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22417 void exit_idle(void)
22418 {
22419 /* idle loop has pid 0 */
22420 - if (current->pid)
22421 + if (task_pid_nr(current))
22422 return;
22423 __exit_idle();
22424 }
22425 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22426
22427 return ret;
22428 }
22429 -void stop_this_cpu(void *dummy)
22430 +__noreturn void stop_this_cpu(void *dummy)
22431 {
22432 local_irq_disable();
22433 /*
22434 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22435 }
22436 early_param("idle", idle_setup);
22437
22438 -unsigned long arch_align_stack(unsigned long sp)
22439 +#ifdef CONFIG_PAX_RANDKSTACK
22440 +void pax_randomize_kstack(struct pt_regs *regs)
22441 {
22442 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22443 - sp -= get_random_int() % 8192;
22444 - return sp & ~0xf;
22445 -}
22446 + struct thread_struct *thread = &current->thread;
22447 + unsigned long time;
22448
22449 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22450 -{
22451 - unsigned long range_end = mm->brk + 0x02000000;
22452 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22453 -}
22454 + if (!randomize_va_space)
22455 + return;
22456 +
22457 + if (v8086_mode(regs))
22458 + return;
22459
22460 + rdtscl(time);
22461 +
22462 + /* P4 seems to return a 0 LSB, ignore it */
22463 +#ifdef CONFIG_MPENTIUM4
22464 + time &= 0x3EUL;
22465 + time <<= 2;
22466 +#elif defined(CONFIG_X86_64)
22467 + time &= 0xFUL;
22468 + time <<= 4;
22469 +#else
22470 + time &= 0x1FUL;
22471 + time <<= 3;
22472 +#endif
22473 +
22474 + thread->sp0 ^= time;
22475 + load_sp0(init_tss + smp_processor_id(), thread);
22476 +
22477 +#ifdef CONFIG_X86_64
22478 + this_cpu_write(kernel_stack, thread->sp0);
22479 +#endif
22480 +}
22481 +#endif
22482 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22483 index b5a8905..d9cacac 100644
22484 --- a/arch/x86/kernel/process_32.c
22485 +++ b/arch/x86/kernel/process_32.c
22486 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22487 unsigned long thread_saved_pc(struct task_struct *tsk)
22488 {
22489 return ((unsigned long *)tsk->thread.sp)[3];
22490 +//XXX return tsk->thread.eip;
22491 }
22492
22493 void __show_regs(struct pt_regs *regs, int all)
22494 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22495 unsigned long sp;
22496 unsigned short ss, gs;
22497
22498 - if (user_mode_vm(regs)) {
22499 + if (user_mode(regs)) {
22500 sp = regs->sp;
22501 ss = regs->ss & 0xffff;
22502 - gs = get_user_gs(regs);
22503 } else {
22504 sp = kernel_stack_pointer(regs);
22505 savesegment(ss, ss);
22506 - savesegment(gs, gs);
22507 }
22508 + gs = get_user_gs(regs);
22509
22510 show_regs_common();
22511
22512 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22513 (u16)regs->cs, regs->ip, regs->flags,
22514 - smp_processor_id());
22515 + raw_smp_processor_id());
22516 print_symbol("EIP is at %s\n", regs->ip);
22517
22518 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22519 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22520 int copy_thread(unsigned long clone_flags, unsigned long sp,
22521 unsigned long arg, struct task_struct *p)
22522 {
22523 - struct pt_regs *childregs = task_pt_regs(p);
22524 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22525 struct task_struct *tsk;
22526 int err;
22527
22528 p->thread.sp = (unsigned long) childregs;
22529 p->thread.sp0 = (unsigned long) (childregs+1);
22530 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22531
22532 if (unlikely(p->flags & PF_KTHREAD)) {
22533 /* kernel thread */
22534 memset(childregs, 0, sizeof(struct pt_regs));
22535 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22536 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22537 - childregs->ds = __USER_DS;
22538 - childregs->es = __USER_DS;
22539 + savesegment(gs, childregs->gs);
22540 + childregs->ds = __KERNEL_DS;
22541 + childregs->es = __KERNEL_DS;
22542 childregs->fs = __KERNEL_PERCPU;
22543 childregs->bx = sp; /* function */
22544 childregs->bp = arg;
22545 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22546 struct thread_struct *prev = &prev_p->thread,
22547 *next = &next_p->thread;
22548 int cpu = smp_processor_id();
22549 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22550 + struct tss_struct *tss = init_tss + cpu;
22551 fpu_switch_t fpu;
22552
22553 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22554 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22555 */
22556 lazy_save_gs(prev->gs);
22557
22558 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22559 + __set_fs(task_thread_info(next_p)->addr_limit);
22560 +#endif
22561 +
22562 /*
22563 * Load the per-thread Thread-Local Storage descriptor.
22564 */
22565 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22566 */
22567 arch_end_context_switch(next_p);
22568
22569 + this_cpu_write(current_task, next_p);
22570 + this_cpu_write(current_tinfo, &next_p->tinfo);
22571 +
22572 /*
22573 * Restore %gs if needed (which is common)
22574 */
22575 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22576
22577 switch_fpu_finish(next_p, fpu);
22578
22579 - this_cpu_write(current_task, next_p);
22580 -
22581 return prev_p;
22582 }
22583
22584 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22585 } while (count++ < 16);
22586 return 0;
22587 }
22588 -
22589 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22590 index 6e68a61..955a9a5 100644
22591 --- a/arch/x86/kernel/process_64.c
22592 +++ b/arch/x86/kernel/process_64.c
22593 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22594 struct pt_regs *childregs;
22595 struct task_struct *me = current;
22596
22597 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22598 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22599 childregs = task_pt_regs(p);
22600 p->thread.sp = (unsigned long) childregs;
22601 p->thread.usersp = me->thread.usersp;
22602 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22603 set_tsk_thread_flag(p, TIF_FORK);
22604 p->fpu_counter = 0;
22605 p->thread.io_bitmap_ptr = NULL;
22606 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22607 struct thread_struct *prev = &prev_p->thread;
22608 struct thread_struct *next = &next_p->thread;
22609 int cpu = smp_processor_id();
22610 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22611 + struct tss_struct *tss = init_tss + cpu;
22612 unsigned fsindex, gsindex;
22613 fpu_switch_t fpu;
22614
22615 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22616 prev->usersp = this_cpu_read(old_rsp);
22617 this_cpu_write(old_rsp, next->usersp);
22618 this_cpu_write(current_task, next_p);
22619 + this_cpu_write(current_tinfo, &next_p->tinfo);
22620
22621 - this_cpu_write(kernel_stack,
22622 - (unsigned long)task_stack_page(next_p) +
22623 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22624 + this_cpu_write(kernel_stack, next->sp0);
22625
22626 /*
22627 * Now maybe reload the debug registers and handle I/O bitmaps
22628 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22629 if (!p || p == current || p->state == TASK_RUNNING)
22630 return 0;
22631 stack = (unsigned long)task_stack_page(p);
22632 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22633 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22634 return 0;
22635 fp = *(u64 *)(p->thread.sp);
22636 do {
22637 - if (fp < (unsigned long)stack ||
22638 - fp >= (unsigned long)stack+THREAD_SIZE)
22639 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22640 return 0;
22641 ip = *(u64 *)(fp+8);
22642 if (!in_sched_functions(ip))
22643 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22644 index b629bbe..0fa615a 100644
22645 --- a/arch/x86/kernel/ptrace.c
22646 +++ b/arch/x86/kernel/ptrace.c
22647 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22648 {
22649 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22650 unsigned long sp = (unsigned long)&regs->sp;
22651 - struct thread_info *tinfo;
22652
22653 - if (context == (sp & ~(THREAD_SIZE - 1)))
22654 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22655 return sp;
22656
22657 - tinfo = (struct thread_info *)context;
22658 - if (tinfo->previous_esp)
22659 - return tinfo->previous_esp;
22660 + sp = *(unsigned long *)context;
22661 + if (sp)
22662 + return sp;
22663
22664 return (unsigned long)regs;
22665 }
22666 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22667 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22668 {
22669 int i;
22670 - int dr7 = 0;
22671 + unsigned long dr7 = 0;
22672 struct arch_hw_breakpoint *info;
22673
22674 for (i = 0; i < HBP_NUM; i++) {
22675 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22676 unsigned long addr, unsigned long data)
22677 {
22678 int ret;
22679 - unsigned long __user *datap = (unsigned long __user *)data;
22680 + unsigned long __user *datap = (__force unsigned long __user *)data;
22681
22682 switch (request) {
22683 /* read the word at location addr in the USER area. */
22684 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22685 if ((int) addr < 0)
22686 return -EIO;
22687 ret = do_get_thread_area(child, addr,
22688 - (struct user_desc __user *)data);
22689 + (__force struct user_desc __user *) data);
22690 break;
22691
22692 case PTRACE_SET_THREAD_AREA:
22693 if ((int) addr < 0)
22694 return -EIO;
22695 ret = do_set_thread_area(child, addr,
22696 - (struct user_desc __user *)data, 0);
22697 + (__force struct user_desc __user *) data, 0);
22698 break;
22699 #endif
22700
22701 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22702
22703 #ifdef CONFIG_X86_64
22704
22705 -static struct user_regset x86_64_regsets[] __read_mostly = {
22706 +static user_regset_no_const x86_64_regsets[] __read_only = {
22707 [REGSET_GENERAL] = {
22708 .core_note_type = NT_PRSTATUS,
22709 .n = sizeof(struct user_regs_struct) / sizeof(long),
22710 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22711 #endif /* CONFIG_X86_64 */
22712
22713 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22714 -static struct user_regset x86_32_regsets[] __read_mostly = {
22715 +static user_regset_no_const x86_32_regsets[] __read_only = {
22716 [REGSET_GENERAL] = {
22717 .core_note_type = NT_PRSTATUS,
22718 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22719 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22720 */
22721 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22722
22723 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22724 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22725 {
22726 #ifdef CONFIG_X86_64
22727 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22728 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22729 memset(info, 0, sizeof(*info));
22730 info->si_signo = SIGTRAP;
22731 info->si_code = si_code;
22732 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22733 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22734 }
22735
22736 void user_single_step_siginfo(struct task_struct *tsk,
22737 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22738 # define IS_IA32 0
22739 #endif
22740
22741 +#ifdef CONFIG_GRKERNSEC_SETXID
22742 +extern void gr_delayed_cred_worker(void);
22743 +#endif
22744 +
22745 /*
22746 * We must return the syscall number to actually look up in the table.
22747 * This can be -1L to skip running any syscall at all.
22748 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22749
22750 user_exit();
22751
22752 +#ifdef CONFIG_GRKERNSEC_SETXID
22753 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22754 + gr_delayed_cred_worker();
22755 +#endif
22756 +
22757 /*
22758 * If we stepped into a sysenter/syscall insn, it trapped in
22759 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22760 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22761 */
22762 user_exit();
22763
22764 +#ifdef CONFIG_GRKERNSEC_SETXID
22765 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22766 + gr_delayed_cred_worker();
22767 +#endif
22768 +
22769 audit_syscall_exit(regs);
22770
22771 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22772 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22773 index 2cb9470..ff1fd80 100644
22774 --- a/arch/x86/kernel/pvclock.c
22775 +++ b/arch/x86/kernel/pvclock.c
22776 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22777 return pv_tsc_khz;
22778 }
22779
22780 -static atomic64_t last_value = ATOMIC64_INIT(0);
22781 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22782
22783 void pvclock_resume(void)
22784 {
22785 - atomic64_set(&last_value, 0);
22786 + atomic64_set_unchecked(&last_value, 0);
22787 }
22788
22789 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22790 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22791 * updating at the same time, and one of them could be slightly behind,
22792 * making the assumption that last_value always go forward fail to hold.
22793 */
22794 - last = atomic64_read(&last_value);
22795 + last = atomic64_read_unchecked(&last_value);
22796 do {
22797 if (ret < last)
22798 return last;
22799 - last = atomic64_cmpxchg(&last_value, last, ret);
22800 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22801 } while (unlikely(last != ret));
22802
22803 return ret;
22804 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22805 index 76fa1e9..abf09ea 100644
22806 --- a/arch/x86/kernel/reboot.c
22807 +++ b/arch/x86/kernel/reboot.c
22808 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22809 EXPORT_SYMBOL(pm_power_off);
22810
22811 static const struct desc_ptr no_idt = {};
22812 -static int reboot_mode;
22813 +static unsigned short reboot_mode;
22814 enum reboot_type reboot_type = BOOT_ACPI;
22815 int reboot_force;
22816
22817 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22818
22819 void __noreturn machine_real_restart(unsigned int type)
22820 {
22821 +
22822 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22823 + struct desc_struct *gdt;
22824 +#endif
22825 +
22826 local_irq_disable();
22827
22828 /*
22829 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22830
22831 /* Jump to the identity-mapped low memory code */
22832 #ifdef CONFIG_X86_32
22833 - asm volatile("jmpl *%0" : :
22834 +
22835 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22836 + gdt = get_cpu_gdt_table(smp_processor_id());
22837 + pax_open_kernel();
22838 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22839 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22840 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22841 + loadsegment(ds, __KERNEL_DS);
22842 + loadsegment(es, __KERNEL_DS);
22843 + loadsegment(ss, __KERNEL_DS);
22844 +#endif
22845 +#ifdef CONFIG_PAX_KERNEXEC
22846 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22847 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22848 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22849 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22850 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22851 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22852 +#endif
22853 + pax_close_kernel();
22854 +#endif
22855 +
22856 + asm volatile("ljmpl *%0" : :
22857 "rm" (real_mode_header->machine_real_restart_asm),
22858 "a" (type));
22859 #else
22860 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22861 * try to force a triple fault and then cycle between hitting the keyboard
22862 * controller and doing that
22863 */
22864 -static void native_machine_emergency_restart(void)
22865 +static void __noreturn native_machine_emergency_restart(void)
22866 {
22867 int i;
22868 int attempt = 0;
22869 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22870 #endif
22871 }
22872
22873 -static void __machine_emergency_restart(int emergency)
22874 +static void __noreturn __machine_emergency_restart(int emergency)
22875 {
22876 reboot_emergency = emergency;
22877 machine_ops.emergency_restart();
22878 }
22879
22880 -static void native_machine_restart(char *__unused)
22881 +static void __noreturn native_machine_restart(char *__unused)
22882 {
22883 pr_notice("machine restart\n");
22884
22885 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22886 __machine_emergency_restart(0);
22887 }
22888
22889 -static void native_machine_halt(void)
22890 +static void __noreturn native_machine_halt(void)
22891 {
22892 /* Stop other cpus and apics */
22893 machine_shutdown();
22894 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22895 stop_this_cpu(NULL);
22896 }
22897
22898 -static void native_machine_power_off(void)
22899 +static void __noreturn native_machine_power_off(void)
22900 {
22901 if (pm_power_off) {
22902 if (!reboot_force)
22903 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22904 }
22905 /* A fallback in case there is no PM info available */
22906 tboot_shutdown(TB_SHUTDOWN_HALT);
22907 + unreachable();
22908 }
22909
22910 -struct machine_ops machine_ops = {
22911 +struct machine_ops machine_ops __read_only = {
22912 .power_off = native_machine_power_off,
22913 .shutdown = native_machine_shutdown,
22914 .emergency_restart = native_machine_emergency_restart,
22915 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22916 index 7a6f3b3..bed145d7 100644
22917 --- a/arch/x86/kernel/relocate_kernel_64.S
22918 +++ b/arch/x86/kernel/relocate_kernel_64.S
22919 @@ -11,6 +11,7 @@
22920 #include <asm/kexec.h>
22921 #include <asm/processor-flags.h>
22922 #include <asm/pgtable_types.h>
22923 +#include <asm/alternative-asm.h>
22924
22925 /*
22926 * Must be relocatable PIC code callable as a C function
22927 @@ -160,13 +161,14 @@ identity_mapped:
22928 xorq %rbp, %rbp
22929 xorq %r8, %r8
22930 xorq %r9, %r9
22931 - xorq %r10, %r9
22932 + xorq %r10, %r10
22933 xorq %r11, %r11
22934 xorq %r12, %r12
22935 xorq %r13, %r13
22936 xorq %r14, %r14
22937 xorq %r15, %r15
22938
22939 + pax_force_retaddr 0, 1
22940 ret
22941
22942 1:
22943 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22944 index 8b24289..d37b58b 100644
22945 --- a/arch/x86/kernel/setup.c
22946 +++ b/arch/x86/kernel/setup.c
22947 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22948
22949 switch (data->type) {
22950 case SETUP_E820_EXT:
22951 - parse_e820_ext(data);
22952 + parse_e820_ext((struct setup_data __force_kernel *)data);
22953 break;
22954 case SETUP_DTB:
22955 add_dtb(pa_data);
22956 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22957 * area (640->1Mb) as ram even though it is not.
22958 * take them out.
22959 */
22960 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22961 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22962
22963 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22964 }
22965 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22966
22967 if (!boot_params.hdr.root_flags)
22968 root_mountflags &= ~MS_RDONLY;
22969 - init_mm.start_code = (unsigned long) _text;
22970 - init_mm.end_code = (unsigned long) _etext;
22971 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22972 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22973 init_mm.end_data = (unsigned long) _edata;
22974 init_mm.brk = _brk_end;
22975
22976 - code_resource.start = virt_to_phys(_text);
22977 - code_resource.end = virt_to_phys(_etext)-1;
22978 - data_resource.start = virt_to_phys(_etext);
22979 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22980 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22981 + data_resource.start = virt_to_phys(_sdata);
22982 data_resource.end = virt_to_phys(_edata)-1;
22983 bss_resource.start = virt_to_phys(&__bss_start);
22984 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22985 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22986 index 5cdff03..80fa283 100644
22987 --- a/arch/x86/kernel/setup_percpu.c
22988 +++ b/arch/x86/kernel/setup_percpu.c
22989 @@ -21,19 +21,17 @@
22990 #include <asm/cpu.h>
22991 #include <asm/stackprotector.h>
22992
22993 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22994 +#ifdef CONFIG_SMP
22995 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22996 EXPORT_PER_CPU_SYMBOL(cpu_number);
22997 +#endif
22998
22999 -#ifdef CONFIG_X86_64
23000 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
23001 -#else
23002 -#define BOOT_PERCPU_OFFSET 0
23003 -#endif
23004
23005 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
23006 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
23007
23008 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
23009 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
23010 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
23011 };
23012 EXPORT_SYMBOL(__per_cpu_offset);
23013 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
23014 {
23015 #ifdef CONFIG_NEED_MULTIPLE_NODES
23016 pg_data_t *last = NULL;
23017 - unsigned int cpu;
23018 + int cpu;
23019
23020 for_each_possible_cpu(cpu) {
23021 int node = early_cpu_to_node(cpu);
23022 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
23023 {
23024 #ifdef CONFIG_X86_32
23025 struct desc_struct gdt;
23026 + unsigned long base = per_cpu_offset(cpu);
23027
23028 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
23029 - 0x2 | DESCTYPE_S, 0x8);
23030 - gdt.s = 1;
23031 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
23032 + 0x83 | DESCTYPE_S, 0xC);
23033 write_gdt_entry(get_cpu_gdt_table(cpu),
23034 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
23035 #endif
23036 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
23037 /* alrighty, percpu areas up and running */
23038 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
23039 for_each_possible_cpu(cpu) {
23040 +#ifdef CONFIG_CC_STACKPROTECTOR
23041 +#ifdef CONFIG_X86_32
23042 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
23043 +#endif
23044 +#endif
23045 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
23046 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
23047 per_cpu(cpu_number, cpu) = cpu;
23048 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
23049 */
23050 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
23051 #endif
23052 +#ifdef CONFIG_CC_STACKPROTECTOR
23053 +#ifdef CONFIG_X86_32
23054 + if (!cpu)
23055 + per_cpu(stack_canary.canary, cpu) = canary;
23056 +#endif
23057 +#endif
23058 /*
23059 * Up to this point, the boot CPU has been using .init.data
23060 * area. Reload any changed state for the boot CPU.
23061 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
23062 index d6bf1f3..3ffce5a 100644
23063 --- a/arch/x86/kernel/signal.c
23064 +++ b/arch/x86/kernel/signal.c
23065 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
23066 * Align the stack pointer according to the i386 ABI,
23067 * i.e. so that on function entry ((sp + 4) & 15) == 0.
23068 */
23069 - sp = ((sp + 4) & -16ul) - 4;
23070 + sp = ((sp - 12) & -16ul) - 4;
23071 #else /* !CONFIG_X86_32 */
23072 sp = round_down(sp, 16) - 8;
23073 #endif
23074 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23075 }
23076
23077 if (current->mm->context.vdso)
23078 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23079 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
23080 else
23081 - restorer = &frame->retcode;
23082 + restorer = (void __user *)&frame->retcode;
23083 if (ka->sa.sa_flags & SA_RESTORER)
23084 restorer = ka->sa.sa_restorer;
23085
23086 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
23087 * reasons and because gdb uses it as a signature to notice
23088 * signal handler stack frames.
23089 */
23090 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
23091 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
23092
23093 if (err)
23094 return -EFAULT;
23095 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23096 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
23097
23098 /* Set up to return from userspace. */
23099 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23100 + if (current->mm->context.vdso)
23101 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
23102 + else
23103 + restorer = (void __user *)&frame->retcode;
23104 if (ka->sa.sa_flags & SA_RESTORER)
23105 restorer = ka->sa.sa_restorer;
23106 put_user_ex(restorer, &frame->pretcode);
23107 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23108 * reasons and because gdb uses it as a signature to notice
23109 * signal handler stack frames.
23110 */
23111 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
23112 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
23113 } put_user_catch(err);
23114
23115 err |= copy_siginfo_to_user(&frame->info, info);
23116 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
23117 index 48d2b7d..90d328a 100644
23118 --- a/arch/x86/kernel/smp.c
23119 +++ b/arch/x86/kernel/smp.c
23120 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23121
23122 __setup("nonmi_ipi", nonmi_ipi_setup);
23123
23124 -struct smp_ops smp_ops = {
23125 +struct smp_ops smp_ops __read_only = {
23126 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23127 .smp_prepare_cpus = native_smp_prepare_cpus,
23128 .smp_cpus_done = native_smp_cpus_done,
23129 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23130 index ed0fe38..87fc692 100644
23131 --- a/arch/x86/kernel/smpboot.c
23132 +++ b/arch/x86/kernel/smpboot.c
23133 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23134 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23135 (THREAD_SIZE + task_stack_page(idle))) - 1);
23136 per_cpu(current_task, cpu) = idle;
23137 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23138
23139 #ifdef CONFIG_X86_32
23140 /* Stack for startup_32 can be just as for start_secondary onwards */
23141 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23142 #else
23143 clear_tsk_thread_flag(idle, TIF_FORK);
23144 initial_gs = per_cpu_offset(cpu);
23145 - per_cpu(kernel_stack, cpu) =
23146 - (unsigned long)task_stack_page(idle) -
23147 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23148 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23149 #endif
23150 +
23151 + pax_open_kernel();
23152 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23153 + pax_close_kernel();
23154 +
23155 initial_code = (unsigned long)start_secondary;
23156 stack_start = idle->thread.sp;
23157
23158 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23159 /* the FPU context is blank, nobody can own it */
23160 __cpu_disable_lazy_restore(cpu);
23161
23162 +#ifdef CONFIG_PAX_PER_CPU_PGD
23163 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23164 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23165 + KERNEL_PGD_PTRS);
23166 +#endif
23167 +
23168 + /* the FPU context is blank, nobody can own it */
23169 + __cpu_disable_lazy_restore(cpu);
23170 +
23171 err = do_boot_cpu(apicid, cpu, tidle);
23172 if (err) {
23173 pr_debug("do_boot_cpu failed %d\n", err);
23174 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23175 index 9b4d51d..5d28b58 100644
23176 --- a/arch/x86/kernel/step.c
23177 +++ b/arch/x86/kernel/step.c
23178 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23179 struct desc_struct *desc;
23180 unsigned long base;
23181
23182 - seg &= ~7UL;
23183 + seg >>= 3;
23184
23185 mutex_lock(&child->mm->context.lock);
23186 - if (unlikely((seg >> 3) >= child->mm->context.size))
23187 + if (unlikely(seg >= child->mm->context.size))
23188 addr = -1L; /* bogus selector, access would fault */
23189 else {
23190 desc = child->mm->context.ldt + seg;
23191 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23192 addr += base;
23193 }
23194 mutex_unlock(&child->mm->context.lock);
23195 - }
23196 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23197 + addr = ktla_ktva(addr);
23198
23199 return addr;
23200 }
23201 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23202 unsigned char opcode[15];
23203 unsigned long addr = convert_ip_to_linear(child, regs);
23204
23205 + if (addr == -EINVAL)
23206 + return 0;
23207 +
23208 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23209 for (i = 0; i < copied; i++) {
23210 switch (opcode[i]) {
23211 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23212 new file mode 100644
23213 index 0000000..207bec6
23214 --- /dev/null
23215 +++ b/arch/x86/kernel/sys_i386_32.c
23216 @@ -0,0 +1,250 @@
23217 +/*
23218 + * This file contains various random system calls that
23219 + * have a non-standard calling sequence on the Linux/i386
23220 + * platform.
23221 + */
23222 +
23223 +#include <linux/errno.h>
23224 +#include <linux/sched.h>
23225 +#include <linux/mm.h>
23226 +#include <linux/fs.h>
23227 +#include <linux/smp.h>
23228 +#include <linux/sem.h>
23229 +#include <linux/msg.h>
23230 +#include <linux/shm.h>
23231 +#include <linux/stat.h>
23232 +#include <linux/syscalls.h>
23233 +#include <linux/mman.h>
23234 +#include <linux/file.h>
23235 +#include <linux/utsname.h>
23236 +#include <linux/ipc.h>
23237 +
23238 +#include <linux/uaccess.h>
23239 +#include <linux/unistd.h>
23240 +
23241 +#include <asm/syscalls.h>
23242 +
23243 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23244 +{
23245 + unsigned long pax_task_size = TASK_SIZE;
23246 +
23247 +#ifdef CONFIG_PAX_SEGMEXEC
23248 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23249 + pax_task_size = SEGMEXEC_TASK_SIZE;
23250 +#endif
23251 +
23252 + if (flags & MAP_FIXED)
23253 + if (len > pax_task_size || addr > pax_task_size - len)
23254 + return -EINVAL;
23255 +
23256 + return 0;
23257 +}
23258 +
23259 +unsigned long
23260 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23261 + unsigned long len, unsigned long pgoff, unsigned long flags)
23262 +{
23263 + struct mm_struct *mm = current->mm;
23264 + struct vm_area_struct *vma;
23265 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23266 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23267 +
23268 +#ifdef CONFIG_PAX_SEGMEXEC
23269 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23270 + pax_task_size = SEGMEXEC_TASK_SIZE;
23271 +#endif
23272 +
23273 + pax_task_size -= PAGE_SIZE;
23274 +
23275 + if (len > pax_task_size)
23276 + return -ENOMEM;
23277 +
23278 + if (flags & MAP_FIXED)
23279 + return addr;
23280 +
23281 +#ifdef CONFIG_PAX_RANDMMAP
23282 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23283 +#endif
23284 +
23285 + if (addr) {
23286 + addr = PAGE_ALIGN(addr);
23287 + if (pax_task_size - len >= addr) {
23288 + vma = find_vma(mm, addr);
23289 + if (check_heap_stack_gap(vma, addr, len, offset))
23290 + return addr;
23291 + }
23292 + }
23293 + if (len > mm->cached_hole_size) {
23294 + start_addr = addr = mm->free_area_cache;
23295 + } else {
23296 + start_addr = addr = mm->mmap_base;
23297 + mm->cached_hole_size = 0;
23298 + }
23299 +
23300 +#ifdef CONFIG_PAX_PAGEEXEC
23301 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23302 + start_addr = 0x00110000UL;
23303 +
23304 +#ifdef CONFIG_PAX_RANDMMAP
23305 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23306 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23307 +#endif
23308 +
23309 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23310 + start_addr = addr = mm->mmap_base;
23311 + else
23312 + addr = start_addr;
23313 + }
23314 +#endif
23315 +
23316 +full_search:
23317 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23318 + /* At this point: (!vma || addr < vma->vm_end). */
23319 + if (pax_task_size - len < addr) {
23320 + /*
23321 + * Start a new search - just in case we missed
23322 + * some holes.
23323 + */
23324 + if (start_addr != mm->mmap_base) {
23325 + start_addr = addr = mm->mmap_base;
23326 + mm->cached_hole_size = 0;
23327 + goto full_search;
23328 + }
23329 + return -ENOMEM;
23330 + }
23331 + if (check_heap_stack_gap(vma, addr, len, offset))
23332 + break;
23333 + if (addr + mm->cached_hole_size < vma->vm_start)
23334 + mm->cached_hole_size = vma->vm_start - addr;
23335 + addr = vma->vm_end;
23336 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23337 + start_addr = addr = mm->mmap_base;
23338 + mm->cached_hole_size = 0;
23339 + goto full_search;
23340 + }
23341 + }
23342 +
23343 + /*
23344 + * Remember the place where we stopped the search:
23345 + */
23346 + mm->free_area_cache = addr + len;
23347 + return addr;
23348 +}
23349 +
23350 +unsigned long
23351 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23352 + const unsigned long len, const unsigned long pgoff,
23353 + const unsigned long flags)
23354 +{
23355 + struct vm_area_struct *vma;
23356 + struct mm_struct *mm = current->mm;
23357 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23358 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23359 +
23360 +#ifdef CONFIG_PAX_SEGMEXEC
23361 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23362 + pax_task_size = SEGMEXEC_TASK_SIZE;
23363 +#endif
23364 +
23365 + pax_task_size -= PAGE_SIZE;
23366 +
23367 + /* requested length too big for entire address space */
23368 + if (len > pax_task_size)
23369 + return -ENOMEM;
23370 +
23371 + if (flags & MAP_FIXED)
23372 + return addr;
23373 +
23374 +#ifdef CONFIG_PAX_PAGEEXEC
23375 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23376 + goto bottomup;
23377 +#endif
23378 +
23379 +#ifdef CONFIG_PAX_RANDMMAP
23380 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23381 +#endif
23382 +
23383 + /* requesting a specific address */
23384 + if (addr) {
23385 + addr = PAGE_ALIGN(addr);
23386 + if (pax_task_size - len >= addr) {
23387 + vma = find_vma(mm, addr);
23388 + if (check_heap_stack_gap(vma, addr, len, offset))
23389 + return addr;
23390 + }
23391 + }
23392 +
23393 + /* check if free_area_cache is useful for us */
23394 + if (len <= mm->cached_hole_size) {
23395 + mm->cached_hole_size = 0;
23396 + mm->free_area_cache = mm->mmap_base;
23397 + }
23398 +
23399 + /* either no address requested or can't fit in requested address hole */
23400 + addr = mm->free_area_cache;
23401 +
23402 + /* make sure it can fit in the remaining address space */
23403 + if (addr > len) {
23404 + vma = find_vma(mm, addr-len);
23405 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23406 + /* remember the address as a hint for next time */
23407 + return (mm->free_area_cache = addr-len);
23408 + }
23409 +
23410 + if (mm->mmap_base < len)
23411 + goto bottomup;
23412 +
23413 + addr = mm->mmap_base-len;
23414 +
23415 + do {
23416 + /*
23417 + * Lookup failure means no vma is above this address,
23418 + * else if new region fits below vma->vm_start,
23419 + * return with success:
23420 + */
23421 + vma = find_vma(mm, addr);
23422 + if (check_heap_stack_gap(vma, addr, len, offset))
23423 + /* remember the address as a hint for next time */
23424 + return (mm->free_area_cache = addr);
23425 +
23426 + /* remember the largest hole we saw so far */
23427 + if (addr + mm->cached_hole_size < vma->vm_start)
23428 + mm->cached_hole_size = vma->vm_start - addr;
23429 +
23430 + /* try just below the current vma->vm_start */
23431 + addr = skip_heap_stack_gap(vma, len, offset);
23432 + } while (!IS_ERR_VALUE(addr));
23433 +
23434 +bottomup:
23435 + /*
23436 + * A failed mmap() very likely causes application failure,
23437 + * so fall back to the bottom-up function here. This scenario
23438 + * can happen with large stack limits and large mmap()
23439 + * allocations.
23440 + */
23441 +
23442 +#ifdef CONFIG_PAX_SEGMEXEC
23443 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23444 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23445 + else
23446 +#endif
23447 +
23448 + mm->mmap_base = TASK_UNMAPPED_BASE;
23449 +
23450 +#ifdef CONFIG_PAX_RANDMMAP
23451 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23452 + mm->mmap_base += mm->delta_mmap;
23453 +#endif
23454 +
23455 + mm->free_area_cache = mm->mmap_base;
23456 + mm->cached_hole_size = ~0UL;
23457 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23458 + /*
23459 + * Restore the topdown base:
23460 + */
23461 + mm->mmap_base = base;
23462 + mm->free_area_cache = base;
23463 + mm->cached_hole_size = ~0UL;
23464 +
23465 + return addr;
23466 +}
23467 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23468 index 97ef74b..57a1882 100644
23469 --- a/arch/x86/kernel/sys_x86_64.c
23470 +++ b/arch/x86/kernel/sys_x86_64.c
23471 @@ -81,8 +81,8 @@ out:
23472 return error;
23473 }
23474
23475 -static void find_start_end(unsigned long flags, unsigned long *begin,
23476 - unsigned long *end)
23477 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23478 + unsigned long *begin, unsigned long *end)
23479 {
23480 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23481 unsigned long new_begin;
23482 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23483 *begin = new_begin;
23484 }
23485 } else {
23486 - *begin = TASK_UNMAPPED_BASE;
23487 + *begin = mm->mmap_base;
23488 *end = TASK_SIZE;
23489 }
23490 }
23491 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23492 struct vm_area_struct *vma;
23493 struct vm_unmapped_area_info info;
23494 unsigned long begin, end;
23495 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23496
23497 if (flags & MAP_FIXED)
23498 return addr;
23499
23500 - find_start_end(flags, &begin, &end);
23501 + find_start_end(mm, flags, &begin, &end);
23502
23503 if (len > end)
23504 return -ENOMEM;
23505
23506 +#ifdef CONFIG_PAX_RANDMMAP
23507 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23508 +#endif
23509 +
23510 if (addr) {
23511 addr = PAGE_ALIGN(addr);
23512 vma = find_vma(mm, addr);
23513 - if (end - len >= addr &&
23514 - (!vma || addr + len <= vma->vm_start))
23515 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23516 return addr;
23517 }
23518
23519 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23520 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23521 goto bottomup;
23522
23523 +#ifdef CONFIG_PAX_RANDMMAP
23524 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23525 +#endif
23526 +
23527 /* requesting a specific address */
23528 if (addr) {
23529 addr = PAGE_ALIGN(addr);
23530 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23531 index f84fe00..f41d9f1 100644
23532 --- a/arch/x86/kernel/tboot.c
23533 +++ b/arch/x86/kernel/tboot.c
23534 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23535
23536 void tboot_shutdown(u32 shutdown_type)
23537 {
23538 - void (*shutdown)(void);
23539 + void (* __noreturn shutdown)(void);
23540
23541 if (!tboot_enabled())
23542 return;
23543 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23544
23545 switch_to_tboot_pt();
23546
23547 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23548 + shutdown = (void *)tboot->shutdown_entry;
23549 shutdown();
23550
23551 /* should not reach here */
23552 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23553 return 0;
23554 }
23555
23556 -static atomic_t ap_wfs_count;
23557 +static atomic_unchecked_t ap_wfs_count;
23558
23559 static int tboot_wait_for_aps(int num_aps)
23560 {
23561 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23562 {
23563 switch (action) {
23564 case CPU_DYING:
23565 - atomic_inc(&ap_wfs_count);
23566 + atomic_inc_unchecked(&ap_wfs_count);
23567 if (num_online_cpus() == 1)
23568 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23569 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23570 return NOTIFY_BAD;
23571 break;
23572 }
23573 return NOTIFY_OK;
23574 }
23575
23576 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23577 +static struct notifier_block tboot_cpu_notifier =
23578 {
23579 .notifier_call = tboot_cpu_callback,
23580 };
23581 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23582
23583 tboot_create_trampoline();
23584
23585 - atomic_set(&ap_wfs_count, 0);
23586 + atomic_set_unchecked(&ap_wfs_count, 0);
23587 register_hotcpu_notifier(&tboot_cpu_notifier);
23588
23589 acpi_os_set_prepare_sleep(&tboot_sleep);
23590 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23591 index 24d3c91..d06b473 100644
23592 --- a/arch/x86/kernel/time.c
23593 +++ b/arch/x86/kernel/time.c
23594 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23595 {
23596 unsigned long pc = instruction_pointer(regs);
23597
23598 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23599 + if (!user_mode(regs) && in_lock_functions(pc)) {
23600 #ifdef CONFIG_FRAME_POINTER
23601 - return *(unsigned long *)(regs->bp + sizeof(long));
23602 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23603 #else
23604 unsigned long *sp =
23605 (unsigned long *)kernel_stack_pointer(regs);
23606 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23607 * or above a saved flags. Eflags has bits 22-31 zero,
23608 * kernel addresses don't.
23609 */
23610 +
23611 +#ifdef CONFIG_PAX_KERNEXEC
23612 + return ktla_ktva(sp[0]);
23613 +#else
23614 if (sp[0] >> 22)
23615 return sp[0];
23616 if (sp[1] >> 22)
23617 return sp[1];
23618 #endif
23619 +
23620 +#endif
23621 }
23622 return pc;
23623 }
23624 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23625 index 9d9d2f9..cad418a 100644
23626 --- a/arch/x86/kernel/tls.c
23627 +++ b/arch/x86/kernel/tls.c
23628 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23629 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23630 return -EINVAL;
23631
23632 +#ifdef CONFIG_PAX_SEGMEXEC
23633 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23634 + return -EINVAL;
23635 +#endif
23636 +
23637 set_tls_desc(p, idx, &info, 1);
23638
23639 return 0;
23640 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23641
23642 if (kbuf)
23643 info = kbuf;
23644 - else if (__copy_from_user(infobuf, ubuf, count))
23645 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23646 return -EFAULT;
23647 else
23648 info = infobuf;
23649 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23650 index ecffca1..95c4d13 100644
23651 --- a/arch/x86/kernel/traps.c
23652 +++ b/arch/x86/kernel/traps.c
23653 @@ -68,12 +68,6 @@
23654 #include <asm/setup.h>
23655
23656 asmlinkage int system_call(void);
23657 -
23658 -/*
23659 - * The IDT has to be page-aligned to simplify the Pentium
23660 - * F0 0F bug workaround.
23661 - */
23662 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23663 #endif
23664
23665 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23666 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23667 }
23668
23669 static int __kprobes
23670 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23671 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23672 struct pt_regs *regs, long error_code)
23673 {
23674 #ifdef CONFIG_X86_32
23675 - if (regs->flags & X86_VM_MASK) {
23676 + if (v8086_mode(regs)) {
23677 /*
23678 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23679 * On nmi (interrupt 2), do_trap should not be called.
23680 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23681 return -1;
23682 }
23683 #endif
23684 - if (!user_mode(regs)) {
23685 + if (!user_mode_novm(regs)) {
23686 if (!fixup_exception(regs)) {
23687 tsk->thread.error_code = error_code;
23688 tsk->thread.trap_nr = trapnr;
23689 +
23690 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23691 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23692 + str = "PAX: suspicious stack segment fault";
23693 +#endif
23694 +
23695 die(str, regs, error_code);
23696 }
23697 +
23698 +#ifdef CONFIG_PAX_REFCOUNT
23699 + if (trapnr == 4)
23700 + pax_report_refcount_overflow(regs);
23701 +#endif
23702 +
23703 return 0;
23704 }
23705
23706 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23707 }
23708
23709 static void __kprobes
23710 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23711 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23712 long error_code, siginfo_t *info)
23713 {
23714 struct task_struct *tsk = current;
23715 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23716 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23717 printk_ratelimit()) {
23718 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23719 - tsk->comm, tsk->pid, str,
23720 + tsk->comm, task_pid_nr(tsk), str,
23721 regs->ip, regs->sp, error_code);
23722 print_vma_addr(" in ", regs->ip);
23723 pr_cont("\n");
23724 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23725 conditional_sti(regs);
23726
23727 #ifdef CONFIG_X86_32
23728 - if (regs->flags & X86_VM_MASK) {
23729 + if (v8086_mode(regs)) {
23730 local_irq_enable();
23731 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23732 goto exit;
23733 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23734 #endif
23735
23736 tsk = current;
23737 - if (!user_mode(regs)) {
23738 + if (!user_mode_novm(regs)) {
23739 if (fixup_exception(regs))
23740 goto exit;
23741
23742 tsk->thread.error_code = error_code;
23743 tsk->thread.trap_nr = X86_TRAP_GP;
23744 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23745 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23746 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23747 +
23748 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23749 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23750 + die("PAX: suspicious general protection fault", regs, error_code);
23751 + else
23752 +#endif
23753 +
23754 die("general protection fault", regs, error_code);
23755 + }
23756 goto exit;
23757 }
23758
23759 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23760 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23761 + struct mm_struct *mm = tsk->mm;
23762 + unsigned long limit;
23763 +
23764 + down_write(&mm->mmap_sem);
23765 + limit = mm->context.user_cs_limit;
23766 + if (limit < TASK_SIZE) {
23767 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23768 + up_write(&mm->mmap_sem);
23769 + return;
23770 + }
23771 + up_write(&mm->mmap_sem);
23772 + }
23773 +#endif
23774 +
23775 tsk->thread.error_code = error_code;
23776 tsk->thread.trap_nr = X86_TRAP_GP;
23777
23778 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23779 /* It's safe to allow irq's after DR6 has been saved */
23780 preempt_conditional_sti(regs);
23781
23782 - if (regs->flags & X86_VM_MASK) {
23783 + if (v8086_mode(regs)) {
23784 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23785 X86_TRAP_DB);
23786 preempt_conditional_cli(regs);
23787 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23788 * We already checked v86 mode above, so we can check for kernel mode
23789 * by just checking the CPL of CS.
23790 */
23791 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23792 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23793 tsk->thread.debugreg6 &= ~DR_STEP;
23794 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23795 regs->flags &= ~X86_EFLAGS_TF;
23796 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23797 return;
23798 conditional_sti(regs);
23799
23800 - if (!user_mode_vm(regs))
23801 + if (!user_mode(regs))
23802 {
23803 if (!fixup_exception(regs)) {
23804 task->thread.error_code = error_code;
23805 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23806 index c71025b..b117501 100644
23807 --- a/arch/x86/kernel/uprobes.c
23808 +++ b/arch/x86/kernel/uprobes.c
23809 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23810 int ret = NOTIFY_DONE;
23811
23812 /* We are only interested in userspace traps */
23813 - if (regs && !user_mode_vm(regs))
23814 + if (regs && !user_mode(regs))
23815 return NOTIFY_DONE;
23816
23817 switch (val) {
23818 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23819 index b9242ba..50c5edd 100644
23820 --- a/arch/x86/kernel/verify_cpu.S
23821 +++ b/arch/x86/kernel/verify_cpu.S
23822 @@ -20,6 +20,7 @@
23823 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23824 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23825 * arch/x86/kernel/head_32.S: processor startup
23826 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23827 *
23828 * verify_cpu, returns the status of longmode and SSE in register %eax.
23829 * 0: Success 1: Failure
23830 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23831 index 1dfe69c..a3df6f6 100644
23832 --- a/arch/x86/kernel/vm86_32.c
23833 +++ b/arch/x86/kernel/vm86_32.c
23834 @@ -43,6 +43,7 @@
23835 #include <linux/ptrace.h>
23836 #include <linux/audit.h>
23837 #include <linux/stddef.h>
23838 +#include <linux/grsecurity.h>
23839
23840 #include <asm/uaccess.h>
23841 #include <asm/io.h>
23842 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23843 do_exit(SIGSEGV);
23844 }
23845
23846 - tss = &per_cpu(init_tss, get_cpu());
23847 + tss = init_tss + get_cpu();
23848 current->thread.sp0 = current->thread.saved_sp0;
23849 current->thread.sysenter_cs = __KERNEL_CS;
23850 load_sp0(tss, &current->thread);
23851 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23852 struct task_struct *tsk;
23853 int tmp, ret = -EPERM;
23854
23855 +#ifdef CONFIG_GRKERNSEC_VM86
23856 + if (!capable(CAP_SYS_RAWIO)) {
23857 + gr_handle_vm86();
23858 + goto out;
23859 + }
23860 +#endif
23861 +
23862 tsk = current;
23863 if (tsk->thread.saved_sp0)
23864 goto out;
23865 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23866 int tmp, ret;
23867 struct vm86plus_struct __user *v86;
23868
23869 +#ifdef CONFIG_GRKERNSEC_VM86
23870 + if (!capable(CAP_SYS_RAWIO)) {
23871 + gr_handle_vm86();
23872 + ret = -EPERM;
23873 + goto out;
23874 + }
23875 +#endif
23876 +
23877 tsk = current;
23878 switch (cmd) {
23879 case VM86_REQUEST_IRQ:
23880 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23881 tsk->thread.saved_fs = info->regs32->fs;
23882 tsk->thread.saved_gs = get_user_gs(info->regs32);
23883
23884 - tss = &per_cpu(init_tss, get_cpu());
23885 + tss = init_tss + get_cpu();
23886 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23887 if (cpu_has_sep)
23888 tsk->thread.sysenter_cs = 0;
23889 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23890 goto cannot_handle;
23891 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23892 goto cannot_handle;
23893 - intr_ptr = (unsigned long __user *) (i << 2);
23894 + intr_ptr = (__force unsigned long __user *) (i << 2);
23895 if (get_user(segoffs, intr_ptr))
23896 goto cannot_handle;
23897 if ((segoffs >> 16) == BIOSSEG)
23898 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23899 index 22a1530..8fbaaad 100644
23900 --- a/arch/x86/kernel/vmlinux.lds.S
23901 +++ b/arch/x86/kernel/vmlinux.lds.S
23902 @@ -26,6 +26,13 @@
23903 #include <asm/page_types.h>
23904 #include <asm/cache.h>
23905 #include <asm/boot.h>
23906 +#include <asm/segment.h>
23907 +
23908 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23909 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23910 +#else
23911 +#define __KERNEL_TEXT_OFFSET 0
23912 +#endif
23913
23914 #undef i386 /* in case the preprocessor is a 32bit one */
23915
23916 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23917
23918 PHDRS {
23919 text PT_LOAD FLAGS(5); /* R_E */
23920 +#ifdef CONFIG_X86_32
23921 + module PT_LOAD FLAGS(5); /* R_E */
23922 +#endif
23923 +#ifdef CONFIG_XEN
23924 + rodata PT_LOAD FLAGS(5); /* R_E */
23925 +#else
23926 + rodata PT_LOAD FLAGS(4); /* R__ */
23927 +#endif
23928 data PT_LOAD FLAGS(6); /* RW_ */
23929 -#ifdef CONFIG_X86_64
23930 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23931 #ifdef CONFIG_SMP
23932 percpu PT_LOAD FLAGS(6); /* RW_ */
23933 #endif
23934 + text.init PT_LOAD FLAGS(5); /* R_E */
23935 + text.exit PT_LOAD FLAGS(5); /* R_E */
23936 init PT_LOAD FLAGS(7); /* RWE */
23937 -#endif
23938 note PT_NOTE FLAGS(0); /* ___ */
23939 }
23940
23941 SECTIONS
23942 {
23943 #ifdef CONFIG_X86_32
23944 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23945 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23946 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23947 #else
23948 - . = __START_KERNEL;
23949 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23950 + . = __START_KERNEL;
23951 #endif
23952
23953 /* Text and read-only data */
23954 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23955 - _text = .;
23956 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23957 /* bootstrapping code */
23958 +#ifdef CONFIG_X86_32
23959 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23960 +#else
23961 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23962 +#endif
23963 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23964 + _text = .;
23965 HEAD_TEXT
23966 #ifdef CONFIG_X86_32
23967 . = ALIGN(PAGE_SIZE);
23968 @@ -108,13 +128,48 @@ SECTIONS
23969 IRQENTRY_TEXT
23970 *(.fixup)
23971 *(.gnu.warning)
23972 - /* End of text section */
23973 - _etext = .;
23974 } :text = 0x9090
23975
23976 - NOTES :text :note
23977 + . += __KERNEL_TEXT_OFFSET;
23978
23979 - EXCEPTION_TABLE(16) :text = 0x9090
23980 +#ifdef CONFIG_X86_32
23981 + . = ALIGN(PAGE_SIZE);
23982 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23983 +
23984 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23985 + MODULES_EXEC_VADDR = .;
23986 + BYTE(0)
23987 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23988 + . = ALIGN(HPAGE_SIZE) - 1;
23989 + MODULES_EXEC_END = .;
23990 +#endif
23991 +
23992 + } :module
23993 +#endif
23994 +
23995 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23996 + /* End of text section */
23997 + BYTE(0)
23998 + _etext = . - __KERNEL_TEXT_OFFSET;
23999 + }
24000 +
24001 +#ifdef CONFIG_X86_32
24002 + . = ALIGN(PAGE_SIZE);
24003 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
24004 + *(.idt)
24005 + . = ALIGN(PAGE_SIZE);
24006 + *(.empty_zero_page)
24007 + *(.initial_pg_fixmap)
24008 + *(.initial_pg_pmd)
24009 + *(.initial_page_table)
24010 + *(.swapper_pg_dir)
24011 + } :rodata
24012 +#endif
24013 +
24014 + . = ALIGN(PAGE_SIZE);
24015 + NOTES :rodata :note
24016 +
24017 + EXCEPTION_TABLE(16) :rodata
24018
24019 #if defined(CONFIG_DEBUG_RODATA)
24020 /* .text should occupy whole number of pages */
24021 @@ -126,16 +181,20 @@ SECTIONS
24022
24023 /* Data */
24024 .data : AT(ADDR(.data) - LOAD_OFFSET) {
24025 +
24026 +#ifdef CONFIG_PAX_KERNEXEC
24027 + . = ALIGN(HPAGE_SIZE);
24028 +#else
24029 + . = ALIGN(PAGE_SIZE);
24030 +#endif
24031 +
24032 /* Start of data section */
24033 _sdata = .;
24034
24035 /* init_task */
24036 INIT_TASK_DATA(THREAD_SIZE)
24037
24038 -#ifdef CONFIG_X86_32
24039 - /* 32 bit has nosave before _edata */
24040 NOSAVE_DATA
24041 -#endif
24042
24043 PAGE_ALIGNED_DATA(PAGE_SIZE)
24044
24045 @@ -176,12 +235,19 @@ SECTIONS
24046 #endif /* CONFIG_X86_64 */
24047
24048 /* Init code and data - will be freed after init */
24049 - . = ALIGN(PAGE_SIZE);
24050 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
24051 + BYTE(0)
24052 +
24053 +#ifdef CONFIG_PAX_KERNEXEC
24054 + . = ALIGN(HPAGE_SIZE);
24055 +#else
24056 + . = ALIGN(PAGE_SIZE);
24057 +#endif
24058 +
24059 __init_begin = .; /* paired with __init_end */
24060 - }
24061 + } :init.begin
24062
24063 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
24064 +#ifdef CONFIG_SMP
24065 /*
24066 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
24067 * output PHDR, so the next output section - .init.text - should
24068 @@ -190,12 +256,27 @@ SECTIONS
24069 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
24070 #endif
24071
24072 - INIT_TEXT_SECTION(PAGE_SIZE)
24073 -#ifdef CONFIG_X86_64
24074 - :init
24075 -#endif
24076 + . = ALIGN(PAGE_SIZE);
24077 + init_begin = .;
24078 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
24079 + VMLINUX_SYMBOL(_sinittext) = .;
24080 + INIT_TEXT
24081 + VMLINUX_SYMBOL(_einittext) = .;
24082 + . = ALIGN(PAGE_SIZE);
24083 + } :text.init
24084
24085 - INIT_DATA_SECTION(16)
24086 + /*
24087 + * .exit.text is discard at runtime, not link time, to deal with
24088 + * references from .altinstructions and .eh_frame
24089 + */
24090 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
24091 + EXIT_TEXT
24092 + . = ALIGN(16);
24093 + } :text.exit
24094 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
24095 +
24096 + . = ALIGN(PAGE_SIZE);
24097 + INIT_DATA_SECTION(16) :init
24098
24099 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
24100 __x86_cpu_dev_start = .;
24101 @@ -257,19 +338,12 @@ SECTIONS
24102 }
24103
24104 . = ALIGN(8);
24105 - /*
24106 - * .exit.text is discard at runtime, not link time, to deal with
24107 - * references from .altinstructions and .eh_frame
24108 - */
24109 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
24110 - EXIT_TEXT
24111 - }
24112
24113 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
24114 EXIT_DATA
24115 }
24116
24117 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
24118 +#ifndef CONFIG_SMP
24119 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
24120 #endif
24121
24122 @@ -288,16 +362,10 @@ SECTIONS
24123 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24124 __smp_locks = .;
24125 *(.smp_locks)
24126 - . = ALIGN(PAGE_SIZE);
24127 __smp_locks_end = .;
24128 + . = ALIGN(PAGE_SIZE);
24129 }
24130
24131 -#ifdef CONFIG_X86_64
24132 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24133 - NOSAVE_DATA
24134 - }
24135 -#endif
24136 -
24137 /* BSS */
24138 . = ALIGN(PAGE_SIZE);
24139 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24140 @@ -313,6 +381,7 @@ SECTIONS
24141 __brk_base = .;
24142 . += 64 * 1024; /* 64k alignment slop space */
24143 *(.brk_reservation) /* areas brk users have reserved */
24144 + . = ALIGN(HPAGE_SIZE);
24145 __brk_limit = .;
24146 }
24147
24148 @@ -339,13 +408,12 @@ SECTIONS
24149 * for the boot processor.
24150 */
24151 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24152 -INIT_PER_CPU(gdt_page);
24153 INIT_PER_CPU(irq_stack_union);
24154
24155 /*
24156 * Build-time check on the image size:
24157 */
24158 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24159 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24160 "kernel image bigger than KERNEL_IMAGE_SIZE");
24161
24162 #ifdef CONFIG_SMP
24163 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24164 index 9a907a6..f83f921 100644
24165 --- a/arch/x86/kernel/vsyscall_64.c
24166 +++ b/arch/x86/kernel/vsyscall_64.c
24167 @@ -56,15 +56,13 @@
24168 DEFINE_VVAR(int, vgetcpu_mode);
24169 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24170
24171 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24172 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24173
24174 static int __init vsyscall_setup(char *str)
24175 {
24176 if (str) {
24177 if (!strcmp("emulate", str))
24178 vsyscall_mode = EMULATE;
24179 - else if (!strcmp("native", str))
24180 - vsyscall_mode = NATIVE;
24181 else if (!strcmp("none", str))
24182 vsyscall_mode = NONE;
24183 else
24184 @@ -323,8 +321,7 @@ do_ret:
24185 return true;
24186
24187 sigsegv:
24188 - force_sig(SIGSEGV, current);
24189 - return true;
24190 + do_group_exit(SIGKILL);
24191 }
24192
24193 /*
24194 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24195 extern char __vvar_page;
24196 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24197
24198 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24199 - vsyscall_mode == NATIVE
24200 - ? PAGE_KERNEL_VSYSCALL
24201 - : PAGE_KERNEL_VVAR);
24202 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24203 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24204 (unsigned long)VSYSCALL_START);
24205
24206 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24207 index 1330dd1..d220b99 100644
24208 --- a/arch/x86/kernel/x8664_ksyms_64.c
24209 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24210 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24211 EXPORT_SYMBOL(copy_user_generic_unrolled);
24212 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24213 EXPORT_SYMBOL(__copy_user_nocache);
24214 -EXPORT_SYMBOL(_copy_from_user);
24215 -EXPORT_SYMBOL(_copy_to_user);
24216
24217 EXPORT_SYMBOL(copy_page);
24218 EXPORT_SYMBOL(clear_page);
24219 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24220 index 7a3d075..6cb373d 100644
24221 --- a/arch/x86/kernel/x86_init.c
24222 +++ b/arch/x86/kernel/x86_init.c
24223 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24224 },
24225 };
24226
24227 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24228 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24229 .early_percpu_clock_init = x86_init_noop,
24230 .setup_percpu_clockev = setup_secondary_APIC_clock,
24231 };
24232 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24233 static void default_nmi_init(void) { };
24234 static int default_i8042_detect(void) { return 1; };
24235
24236 -struct x86_platform_ops x86_platform = {
24237 +struct x86_platform_ops x86_platform __read_only = {
24238 .calibrate_tsc = native_calibrate_tsc,
24239 .get_wallclock = mach_get_cmos_time,
24240 .set_wallclock = mach_set_rtc_mmss,
24241 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24242 };
24243
24244 EXPORT_SYMBOL_GPL(x86_platform);
24245 -struct x86_msi_ops x86_msi = {
24246 +struct x86_msi_ops x86_msi __read_only = {
24247 .setup_msi_irqs = native_setup_msi_irqs,
24248 .teardown_msi_irq = native_teardown_msi_irq,
24249 .teardown_msi_irqs = default_teardown_msi_irqs,
24250 .restore_msi_irqs = default_restore_msi_irqs,
24251 };
24252
24253 -struct x86_io_apic_ops x86_io_apic_ops = {
24254 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24255 .init = native_io_apic_init_mappings,
24256 .read = native_io_apic_read,
24257 .write = native_io_apic_write,
24258 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24259 index ada87a3..afea76d 100644
24260 --- a/arch/x86/kernel/xsave.c
24261 +++ b/arch/x86/kernel/xsave.c
24262 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24263 {
24264 int err;
24265
24266 + buf = (struct xsave_struct __user *)____m(buf);
24267 if (use_xsave())
24268 err = xsave_user(buf);
24269 else if (use_fxsr())
24270 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24271 */
24272 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24273 {
24274 + buf = (void __user *)____m(buf);
24275 if (use_xsave()) {
24276 if ((unsigned long)buf % 64 || fx_only) {
24277 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24278 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24279 index a20ecb5..d0e2194 100644
24280 --- a/arch/x86/kvm/cpuid.c
24281 +++ b/arch/x86/kvm/cpuid.c
24282 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24283 struct kvm_cpuid2 *cpuid,
24284 struct kvm_cpuid_entry2 __user *entries)
24285 {
24286 - int r;
24287 + int r, i;
24288
24289 r = -E2BIG;
24290 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24291 goto out;
24292 r = -EFAULT;
24293 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24294 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24295 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24296 goto out;
24297 + for (i = 0; i < cpuid->nent; ++i) {
24298 + struct kvm_cpuid_entry2 cpuid_entry;
24299 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24300 + goto out;
24301 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24302 + }
24303 vcpu->arch.cpuid_nent = cpuid->nent;
24304 kvm_apic_set_version(vcpu);
24305 kvm_x86_ops->cpuid_update(vcpu);
24306 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24307 struct kvm_cpuid2 *cpuid,
24308 struct kvm_cpuid_entry2 __user *entries)
24309 {
24310 - int r;
24311 + int r, i;
24312
24313 r = -E2BIG;
24314 if (cpuid->nent < vcpu->arch.cpuid_nent)
24315 goto out;
24316 r = -EFAULT;
24317 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24318 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24319 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24320 goto out;
24321 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24322 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24323 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24324 + goto out;
24325 + }
24326 return 0;
24327
24328 out:
24329 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24330 index d330b3c..101a42b 100644
24331 --- a/arch/x86/kvm/emulate.c
24332 +++ b/arch/x86/kvm/emulate.c
24333 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24334
24335 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24336 do { \
24337 + unsigned long _tmp; \
24338 __asm__ __volatile__ ( \
24339 _PRE_EFLAGS("0", "4", "2") \
24340 _op _suffix " %"_x"3,%1; " \
24341 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24342 /* Raw emulation: instruction has two explicit operands. */
24343 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24344 do { \
24345 - unsigned long _tmp; \
24346 - \
24347 switch ((ctxt)->dst.bytes) { \
24348 case 2: \
24349 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24350 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24351
24352 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24353 do { \
24354 - unsigned long _tmp; \
24355 switch ((ctxt)->dst.bytes) { \
24356 case 1: \
24357 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24358 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24359 index a2f492c..899e107 100644
24360 --- a/arch/x86/kvm/lapic.c
24361 +++ b/arch/x86/kvm/lapic.c
24362 @@ -55,7 +55,7 @@
24363 #define APIC_BUS_CYCLE_NS 1
24364
24365 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24366 -#define apic_debug(fmt, arg...)
24367 +#define apic_debug(fmt, arg...) do {} while (0)
24368
24369 #define APIC_LVT_NUM 6
24370 /* 14 is the version for Xeon and Pentium 8.4.8*/
24371 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24372 index 891eb6d..e027900 100644
24373 --- a/arch/x86/kvm/paging_tmpl.h
24374 +++ b/arch/x86/kvm/paging_tmpl.h
24375 @@ -208,7 +208,7 @@ retry_walk:
24376 if (unlikely(kvm_is_error_hva(host_addr)))
24377 goto error;
24378
24379 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24380 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24381 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24382 goto error;
24383 walker->ptep_user[walker->level - 1] = ptep_user;
24384 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24385 index d29d3cd..ec9d522 100644
24386 --- a/arch/x86/kvm/svm.c
24387 +++ b/arch/x86/kvm/svm.c
24388 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24389 int cpu = raw_smp_processor_id();
24390
24391 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24392 +
24393 + pax_open_kernel();
24394 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24395 + pax_close_kernel();
24396 +
24397 load_TR_desc();
24398 }
24399
24400 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24401 #endif
24402 #endif
24403
24404 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24405 + __set_fs(current_thread_info()->addr_limit);
24406 +#endif
24407 +
24408 reload_tss(vcpu);
24409
24410 local_irq_disable();
24411 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24412 index 9120ae1..aca46d0 100644
24413 --- a/arch/x86/kvm/vmx.c
24414 +++ b/arch/x86/kvm/vmx.c
24415 @@ -1164,12 +1164,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24416 #endif
24417 }
24418
24419 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24420 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24421 {
24422 vmcs_writel(field, vmcs_readl(field) & ~mask);
24423 }
24424
24425 -static void vmcs_set_bits(unsigned long field, u32 mask)
24426 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24427 {
24428 vmcs_writel(field, vmcs_readl(field) | mask);
24429 }
24430 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24431 struct desc_struct *descs;
24432
24433 descs = (void *)gdt->address;
24434 +
24435 + pax_open_kernel();
24436 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24437 + pax_close_kernel();
24438 +
24439 load_TR_desc();
24440 }
24441
24442 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24443 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24444 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24445
24446 +#ifdef CONFIG_PAX_PER_CPU_PGD
24447 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24448 +#endif
24449 +
24450 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24451 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24452 vmx->loaded_vmcs->cpu = cpu;
24453 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24454 if (!cpu_has_vmx_flexpriority())
24455 flexpriority_enabled = 0;
24456
24457 - if (!cpu_has_vmx_tpr_shadow())
24458 - kvm_x86_ops->update_cr8_intercept = NULL;
24459 + if (!cpu_has_vmx_tpr_shadow()) {
24460 + pax_open_kernel();
24461 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24462 + pax_close_kernel();
24463 + }
24464
24465 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24466 kvm_disable_largepages();
24467 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24468
24469 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24470 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24471 +
24472 +#ifndef CONFIG_PAX_PER_CPU_PGD
24473 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24474 +#endif
24475
24476 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24477 #ifdef CONFIG_X86_64
24478 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24479 native_store_idt(&dt);
24480 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24481
24482 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24483 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24484
24485 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24486 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24487 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24488 "jmp 2f \n\t"
24489 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24490 "2: "
24491 +
24492 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24493 + "ljmp %[cs],$3f\n\t"
24494 + "3: "
24495 +#endif
24496 +
24497 /* Save guest registers, load host registers, keep flags */
24498 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24499 "pop %0 \n\t"
24500 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24501 #endif
24502 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24503 [wordsize]"i"(sizeof(ulong))
24504 +
24505 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24506 + ,[cs]"i"(__KERNEL_CS)
24507 +#endif
24508 +
24509 : "cc", "memory"
24510 #ifdef CONFIG_X86_64
24511 , "rax", "rbx", "rdi", "rsi"
24512 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24513 if (debugctlmsr)
24514 update_debugctlmsr(debugctlmsr);
24515
24516 -#ifndef CONFIG_X86_64
24517 +#ifdef CONFIG_X86_32
24518 /*
24519 * The sysexit path does not restore ds/es, so we must set them to
24520 * a reasonable value ourselves.
24521 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24522 * may be executed in interrupt context, which saves and restore segments
24523 * around it, nullifying its effect.
24524 */
24525 - loadsegment(ds, __USER_DS);
24526 - loadsegment(es, __USER_DS);
24527 + loadsegment(ds, __KERNEL_DS);
24528 + loadsegment(es, __KERNEL_DS);
24529 + loadsegment(ss, __KERNEL_DS);
24530 +
24531 +#ifdef CONFIG_PAX_KERNEXEC
24532 + loadsegment(fs, __KERNEL_PERCPU);
24533 +#endif
24534 +
24535 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24536 + __set_fs(current_thread_info()->addr_limit);
24537 +#endif
24538 +
24539 #endif
24540
24541 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24542 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24543 index 9a51121..f739a79 100644
24544 --- a/arch/x86/kvm/x86.c
24545 +++ b/arch/x86/kvm/x86.c
24546 @@ -1688,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24547 {
24548 struct kvm *kvm = vcpu->kvm;
24549 int lm = is_long_mode(vcpu);
24550 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24551 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24552 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24553 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24554 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24555 : kvm->arch.xen_hvm_config.blob_size_32;
24556 u32 page_num = data & ~PAGE_MASK;
24557 @@ -2567,6 +2567,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24558 if (n < msr_list.nmsrs)
24559 goto out;
24560 r = -EFAULT;
24561 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24562 + goto out;
24563 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24564 num_msrs_to_save * sizeof(u32)))
24565 goto out;
24566 @@ -2696,7 +2698,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24567 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24568 struct kvm_interrupt *irq)
24569 {
24570 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24571 + if (irq->irq >= KVM_NR_INTERRUPTS)
24572 return -EINVAL;
24573 if (irqchip_in_kernel(vcpu->kvm))
24574 return -ENXIO;
24575 @@ -5209,7 +5211,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24576 };
24577 #endif
24578
24579 -int kvm_arch_init(void *opaque)
24580 +int kvm_arch_init(const void *opaque)
24581 {
24582 int r;
24583 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24584 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24585 index 20a4fd4..d806083 100644
24586 --- a/arch/x86/lguest/boot.c
24587 +++ b/arch/x86/lguest/boot.c
24588 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24589 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24590 * Launcher to reboot us.
24591 */
24592 -static void lguest_restart(char *reason)
24593 +static __noreturn void lguest_restart(char *reason)
24594 {
24595 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24596 + BUG();
24597 }
24598
24599 /*G:050
24600 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24601 index 00933d5..3a64af9 100644
24602 --- a/arch/x86/lib/atomic64_386_32.S
24603 +++ b/arch/x86/lib/atomic64_386_32.S
24604 @@ -48,6 +48,10 @@ BEGIN(read)
24605 movl (v), %eax
24606 movl 4(v), %edx
24607 RET_ENDP
24608 +BEGIN(read_unchecked)
24609 + movl (v), %eax
24610 + movl 4(v), %edx
24611 +RET_ENDP
24612 #undef v
24613
24614 #define v %esi
24615 @@ -55,6 +59,10 @@ BEGIN(set)
24616 movl %ebx, (v)
24617 movl %ecx, 4(v)
24618 RET_ENDP
24619 +BEGIN(set_unchecked)
24620 + movl %ebx, (v)
24621 + movl %ecx, 4(v)
24622 +RET_ENDP
24623 #undef v
24624
24625 #define v %esi
24626 @@ -70,6 +78,20 @@ RET_ENDP
24627 BEGIN(add)
24628 addl %eax, (v)
24629 adcl %edx, 4(v)
24630 +
24631 +#ifdef CONFIG_PAX_REFCOUNT
24632 + jno 0f
24633 + subl %eax, (v)
24634 + sbbl %edx, 4(v)
24635 + int $4
24636 +0:
24637 + _ASM_EXTABLE(0b, 0b)
24638 +#endif
24639 +
24640 +RET_ENDP
24641 +BEGIN(add_unchecked)
24642 + addl %eax, (v)
24643 + adcl %edx, 4(v)
24644 RET_ENDP
24645 #undef v
24646
24647 @@ -77,6 +99,24 @@ RET_ENDP
24648 BEGIN(add_return)
24649 addl (v), %eax
24650 adcl 4(v), %edx
24651 +
24652 +#ifdef CONFIG_PAX_REFCOUNT
24653 + into
24654 +1234:
24655 + _ASM_EXTABLE(1234b, 2f)
24656 +#endif
24657 +
24658 + movl %eax, (v)
24659 + movl %edx, 4(v)
24660 +
24661 +#ifdef CONFIG_PAX_REFCOUNT
24662 +2:
24663 +#endif
24664 +
24665 +RET_ENDP
24666 +BEGIN(add_return_unchecked)
24667 + addl (v), %eax
24668 + adcl 4(v), %edx
24669 movl %eax, (v)
24670 movl %edx, 4(v)
24671 RET_ENDP
24672 @@ -86,6 +126,20 @@ RET_ENDP
24673 BEGIN(sub)
24674 subl %eax, (v)
24675 sbbl %edx, 4(v)
24676 +
24677 +#ifdef CONFIG_PAX_REFCOUNT
24678 + jno 0f
24679 + addl %eax, (v)
24680 + adcl %edx, 4(v)
24681 + int $4
24682 +0:
24683 + _ASM_EXTABLE(0b, 0b)
24684 +#endif
24685 +
24686 +RET_ENDP
24687 +BEGIN(sub_unchecked)
24688 + subl %eax, (v)
24689 + sbbl %edx, 4(v)
24690 RET_ENDP
24691 #undef v
24692
24693 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24694 sbbl $0, %edx
24695 addl (v), %eax
24696 adcl 4(v), %edx
24697 +
24698 +#ifdef CONFIG_PAX_REFCOUNT
24699 + into
24700 +1234:
24701 + _ASM_EXTABLE(1234b, 2f)
24702 +#endif
24703 +
24704 + movl %eax, (v)
24705 + movl %edx, 4(v)
24706 +
24707 +#ifdef CONFIG_PAX_REFCOUNT
24708 +2:
24709 +#endif
24710 +
24711 +RET_ENDP
24712 +BEGIN(sub_return_unchecked)
24713 + negl %edx
24714 + negl %eax
24715 + sbbl $0, %edx
24716 + addl (v), %eax
24717 + adcl 4(v), %edx
24718 movl %eax, (v)
24719 movl %edx, 4(v)
24720 RET_ENDP
24721 @@ -105,6 +180,20 @@ RET_ENDP
24722 BEGIN(inc)
24723 addl $1, (v)
24724 adcl $0, 4(v)
24725 +
24726 +#ifdef CONFIG_PAX_REFCOUNT
24727 + jno 0f
24728 + subl $1, (v)
24729 + sbbl $0, 4(v)
24730 + int $4
24731 +0:
24732 + _ASM_EXTABLE(0b, 0b)
24733 +#endif
24734 +
24735 +RET_ENDP
24736 +BEGIN(inc_unchecked)
24737 + addl $1, (v)
24738 + adcl $0, 4(v)
24739 RET_ENDP
24740 #undef v
24741
24742 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24743 movl 4(v), %edx
24744 addl $1, %eax
24745 adcl $0, %edx
24746 +
24747 +#ifdef CONFIG_PAX_REFCOUNT
24748 + into
24749 +1234:
24750 + _ASM_EXTABLE(1234b, 2f)
24751 +#endif
24752 +
24753 + movl %eax, (v)
24754 + movl %edx, 4(v)
24755 +
24756 +#ifdef CONFIG_PAX_REFCOUNT
24757 +2:
24758 +#endif
24759 +
24760 +RET_ENDP
24761 +BEGIN(inc_return_unchecked)
24762 + movl (v), %eax
24763 + movl 4(v), %edx
24764 + addl $1, %eax
24765 + adcl $0, %edx
24766 movl %eax, (v)
24767 movl %edx, 4(v)
24768 RET_ENDP
24769 @@ -123,6 +232,20 @@ RET_ENDP
24770 BEGIN(dec)
24771 subl $1, (v)
24772 sbbl $0, 4(v)
24773 +
24774 +#ifdef CONFIG_PAX_REFCOUNT
24775 + jno 0f
24776 + addl $1, (v)
24777 + adcl $0, 4(v)
24778 + int $4
24779 +0:
24780 + _ASM_EXTABLE(0b, 0b)
24781 +#endif
24782 +
24783 +RET_ENDP
24784 +BEGIN(dec_unchecked)
24785 + subl $1, (v)
24786 + sbbl $0, 4(v)
24787 RET_ENDP
24788 #undef v
24789
24790 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24791 movl 4(v), %edx
24792 subl $1, %eax
24793 sbbl $0, %edx
24794 +
24795 +#ifdef CONFIG_PAX_REFCOUNT
24796 + into
24797 +1234:
24798 + _ASM_EXTABLE(1234b, 2f)
24799 +#endif
24800 +
24801 + movl %eax, (v)
24802 + movl %edx, 4(v)
24803 +
24804 +#ifdef CONFIG_PAX_REFCOUNT
24805 +2:
24806 +#endif
24807 +
24808 +RET_ENDP
24809 +BEGIN(dec_return_unchecked)
24810 + movl (v), %eax
24811 + movl 4(v), %edx
24812 + subl $1, %eax
24813 + sbbl $0, %edx
24814 movl %eax, (v)
24815 movl %edx, 4(v)
24816 RET_ENDP
24817 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24818 adcl %edx, %edi
24819 addl (v), %eax
24820 adcl 4(v), %edx
24821 +
24822 +#ifdef CONFIG_PAX_REFCOUNT
24823 + into
24824 +1234:
24825 + _ASM_EXTABLE(1234b, 2f)
24826 +#endif
24827 +
24828 cmpl %eax, %ecx
24829 je 3f
24830 1:
24831 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24832 1:
24833 addl $1, %eax
24834 adcl $0, %edx
24835 +
24836 +#ifdef CONFIG_PAX_REFCOUNT
24837 + into
24838 +1234:
24839 + _ASM_EXTABLE(1234b, 2f)
24840 +#endif
24841 +
24842 movl %eax, (v)
24843 movl %edx, 4(v)
24844 movl $1, %eax
24845 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24846 movl 4(v), %edx
24847 subl $1, %eax
24848 sbbl $0, %edx
24849 +
24850 +#ifdef CONFIG_PAX_REFCOUNT
24851 + into
24852 +1234:
24853 + _ASM_EXTABLE(1234b, 1f)
24854 +#endif
24855 +
24856 js 1f
24857 movl %eax, (v)
24858 movl %edx, 4(v)
24859 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24860 index f5cc9eb..51fa319 100644
24861 --- a/arch/x86/lib/atomic64_cx8_32.S
24862 +++ b/arch/x86/lib/atomic64_cx8_32.S
24863 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24864 CFI_STARTPROC
24865
24866 read64 %ecx
24867 + pax_force_retaddr
24868 ret
24869 CFI_ENDPROC
24870 ENDPROC(atomic64_read_cx8)
24871
24872 +ENTRY(atomic64_read_unchecked_cx8)
24873 + CFI_STARTPROC
24874 +
24875 + read64 %ecx
24876 + pax_force_retaddr
24877 + ret
24878 + CFI_ENDPROC
24879 +ENDPROC(atomic64_read_unchecked_cx8)
24880 +
24881 ENTRY(atomic64_set_cx8)
24882 CFI_STARTPROC
24883
24884 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24885 cmpxchg8b (%esi)
24886 jne 1b
24887
24888 + pax_force_retaddr
24889 ret
24890 CFI_ENDPROC
24891 ENDPROC(atomic64_set_cx8)
24892
24893 +ENTRY(atomic64_set_unchecked_cx8)
24894 + CFI_STARTPROC
24895 +
24896 +1:
24897 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24898 + * are atomic on 586 and newer */
24899 + cmpxchg8b (%esi)
24900 + jne 1b
24901 +
24902 + pax_force_retaddr
24903 + ret
24904 + CFI_ENDPROC
24905 +ENDPROC(atomic64_set_unchecked_cx8)
24906 +
24907 ENTRY(atomic64_xchg_cx8)
24908 CFI_STARTPROC
24909
24910 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24911 cmpxchg8b (%esi)
24912 jne 1b
24913
24914 + pax_force_retaddr
24915 ret
24916 CFI_ENDPROC
24917 ENDPROC(atomic64_xchg_cx8)
24918
24919 -.macro addsub_return func ins insc
24920 -ENTRY(atomic64_\func\()_return_cx8)
24921 +.macro addsub_return func ins insc unchecked=""
24922 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24923 CFI_STARTPROC
24924 SAVE ebp
24925 SAVE ebx
24926 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24927 movl %edx, %ecx
24928 \ins\()l %esi, %ebx
24929 \insc\()l %edi, %ecx
24930 +
24931 +.ifb \unchecked
24932 +#ifdef CONFIG_PAX_REFCOUNT
24933 + into
24934 +2:
24935 + _ASM_EXTABLE(2b, 3f)
24936 +#endif
24937 +.endif
24938 +
24939 LOCK_PREFIX
24940 cmpxchg8b (%ebp)
24941 jne 1b
24942 -
24943 -10:
24944 movl %ebx, %eax
24945 movl %ecx, %edx
24946 +
24947 +.ifb \unchecked
24948 +#ifdef CONFIG_PAX_REFCOUNT
24949 +3:
24950 +#endif
24951 +.endif
24952 +
24953 RESTORE edi
24954 RESTORE esi
24955 RESTORE ebx
24956 RESTORE ebp
24957 + pax_force_retaddr
24958 ret
24959 CFI_ENDPROC
24960 -ENDPROC(atomic64_\func\()_return_cx8)
24961 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24962 .endm
24963
24964 addsub_return add add adc
24965 addsub_return sub sub sbb
24966 +addsub_return add add adc _unchecked
24967 +addsub_return sub sub sbb _unchecked
24968
24969 -.macro incdec_return func ins insc
24970 -ENTRY(atomic64_\func\()_return_cx8)
24971 +.macro incdec_return func ins insc unchecked=""
24972 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24973 CFI_STARTPROC
24974 SAVE ebx
24975
24976 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24977 movl %edx, %ecx
24978 \ins\()l $1, %ebx
24979 \insc\()l $0, %ecx
24980 +
24981 +.ifb \unchecked
24982 +#ifdef CONFIG_PAX_REFCOUNT
24983 + into
24984 +2:
24985 + _ASM_EXTABLE(2b, 3f)
24986 +#endif
24987 +.endif
24988 +
24989 LOCK_PREFIX
24990 cmpxchg8b (%esi)
24991 jne 1b
24992
24993 -10:
24994 movl %ebx, %eax
24995 movl %ecx, %edx
24996 +
24997 +.ifb \unchecked
24998 +#ifdef CONFIG_PAX_REFCOUNT
24999 +3:
25000 +#endif
25001 +.endif
25002 +
25003 RESTORE ebx
25004 + pax_force_retaddr
25005 ret
25006 CFI_ENDPROC
25007 -ENDPROC(atomic64_\func\()_return_cx8)
25008 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
25009 .endm
25010
25011 incdec_return inc add adc
25012 incdec_return dec sub sbb
25013 +incdec_return inc add adc _unchecked
25014 +incdec_return dec sub sbb _unchecked
25015
25016 ENTRY(atomic64_dec_if_positive_cx8)
25017 CFI_STARTPROC
25018 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
25019 movl %edx, %ecx
25020 subl $1, %ebx
25021 sbb $0, %ecx
25022 +
25023 +#ifdef CONFIG_PAX_REFCOUNT
25024 + into
25025 +1234:
25026 + _ASM_EXTABLE(1234b, 2f)
25027 +#endif
25028 +
25029 js 2f
25030 LOCK_PREFIX
25031 cmpxchg8b (%esi)
25032 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
25033 movl %ebx, %eax
25034 movl %ecx, %edx
25035 RESTORE ebx
25036 + pax_force_retaddr
25037 ret
25038 CFI_ENDPROC
25039 ENDPROC(atomic64_dec_if_positive_cx8)
25040 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
25041 movl %edx, %ecx
25042 addl %ebp, %ebx
25043 adcl %edi, %ecx
25044 +
25045 +#ifdef CONFIG_PAX_REFCOUNT
25046 + into
25047 +1234:
25048 + _ASM_EXTABLE(1234b, 3f)
25049 +#endif
25050 +
25051 LOCK_PREFIX
25052 cmpxchg8b (%esi)
25053 jne 1b
25054 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25055 CFI_ADJUST_CFA_OFFSET -8
25056 RESTORE ebx
25057 RESTORE ebp
25058 + pax_force_retaddr
25059 ret
25060 4:
25061 cmpl %edx, 4(%esp)
25062 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25063 xorl %ecx, %ecx
25064 addl $1, %ebx
25065 adcl %edx, %ecx
25066 +
25067 +#ifdef CONFIG_PAX_REFCOUNT
25068 + into
25069 +1234:
25070 + _ASM_EXTABLE(1234b, 3f)
25071 +#endif
25072 +
25073 LOCK_PREFIX
25074 cmpxchg8b (%esi)
25075 jne 1b
25076 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25077 movl $1, %eax
25078 3:
25079 RESTORE ebx
25080 + pax_force_retaddr
25081 ret
25082 CFI_ENDPROC
25083 ENDPROC(atomic64_inc_not_zero_cx8)
25084 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25085 index 2af5df3..62b1a5a 100644
25086 --- a/arch/x86/lib/checksum_32.S
25087 +++ b/arch/x86/lib/checksum_32.S
25088 @@ -29,7 +29,8 @@
25089 #include <asm/dwarf2.h>
25090 #include <asm/errno.h>
25091 #include <asm/asm.h>
25092 -
25093 +#include <asm/segment.h>
25094 +
25095 /*
25096 * computes a partial checksum, e.g. for TCP/UDP fragments
25097 */
25098 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25099
25100 #define ARGBASE 16
25101 #define FP 12
25102 -
25103 -ENTRY(csum_partial_copy_generic)
25104 +
25105 +ENTRY(csum_partial_copy_generic_to_user)
25106 CFI_STARTPROC
25107 +
25108 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25109 + pushl_cfi %gs
25110 + popl_cfi %es
25111 + jmp csum_partial_copy_generic
25112 +#endif
25113 +
25114 +ENTRY(csum_partial_copy_generic_from_user)
25115 +
25116 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25117 + pushl_cfi %gs
25118 + popl_cfi %ds
25119 +#endif
25120 +
25121 +ENTRY(csum_partial_copy_generic)
25122 subl $4,%esp
25123 CFI_ADJUST_CFA_OFFSET 4
25124 pushl_cfi %edi
25125 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25126 jmp 4f
25127 SRC(1: movw (%esi), %bx )
25128 addl $2, %esi
25129 -DST( movw %bx, (%edi) )
25130 +DST( movw %bx, %es:(%edi) )
25131 addl $2, %edi
25132 addw %bx, %ax
25133 adcl $0, %eax
25134 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25135 SRC(1: movl (%esi), %ebx )
25136 SRC( movl 4(%esi), %edx )
25137 adcl %ebx, %eax
25138 -DST( movl %ebx, (%edi) )
25139 +DST( movl %ebx, %es:(%edi) )
25140 adcl %edx, %eax
25141 -DST( movl %edx, 4(%edi) )
25142 +DST( movl %edx, %es:4(%edi) )
25143
25144 SRC( movl 8(%esi), %ebx )
25145 SRC( movl 12(%esi), %edx )
25146 adcl %ebx, %eax
25147 -DST( movl %ebx, 8(%edi) )
25148 +DST( movl %ebx, %es:8(%edi) )
25149 adcl %edx, %eax
25150 -DST( movl %edx, 12(%edi) )
25151 +DST( movl %edx, %es:12(%edi) )
25152
25153 SRC( movl 16(%esi), %ebx )
25154 SRC( movl 20(%esi), %edx )
25155 adcl %ebx, %eax
25156 -DST( movl %ebx, 16(%edi) )
25157 +DST( movl %ebx, %es:16(%edi) )
25158 adcl %edx, %eax
25159 -DST( movl %edx, 20(%edi) )
25160 +DST( movl %edx, %es:20(%edi) )
25161
25162 SRC( movl 24(%esi), %ebx )
25163 SRC( movl 28(%esi), %edx )
25164 adcl %ebx, %eax
25165 -DST( movl %ebx, 24(%edi) )
25166 +DST( movl %ebx, %es:24(%edi) )
25167 adcl %edx, %eax
25168 -DST( movl %edx, 28(%edi) )
25169 +DST( movl %edx, %es:28(%edi) )
25170
25171 lea 32(%esi), %esi
25172 lea 32(%edi), %edi
25173 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25174 shrl $2, %edx # This clears CF
25175 SRC(3: movl (%esi), %ebx )
25176 adcl %ebx, %eax
25177 -DST( movl %ebx, (%edi) )
25178 +DST( movl %ebx, %es:(%edi) )
25179 lea 4(%esi), %esi
25180 lea 4(%edi), %edi
25181 dec %edx
25182 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25183 jb 5f
25184 SRC( movw (%esi), %cx )
25185 leal 2(%esi), %esi
25186 -DST( movw %cx, (%edi) )
25187 +DST( movw %cx, %es:(%edi) )
25188 leal 2(%edi), %edi
25189 je 6f
25190 shll $16,%ecx
25191 SRC(5: movb (%esi), %cl )
25192 -DST( movb %cl, (%edi) )
25193 +DST( movb %cl, %es:(%edi) )
25194 6: addl %ecx, %eax
25195 adcl $0, %eax
25196 7:
25197 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25198
25199 6001:
25200 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25201 - movl $-EFAULT, (%ebx)
25202 + movl $-EFAULT, %ss:(%ebx)
25203
25204 # zero the complete destination - computing the rest
25205 # is too much work
25206 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25207
25208 6002:
25209 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25210 - movl $-EFAULT,(%ebx)
25211 + movl $-EFAULT,%ss:(%ebx)
25212 jmp 5000b
25213
25214 .previous
25215
25216 + pushl_cfi %ss
25217 + popl_cfi %ds
25218 + pushl_cfi %ss
25219 + popl_cfi %es
25220 popl_cfi %ebx
25221 CFI_RESTORE ebx
25222 popl_cfi %esi
25223 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25224 popl_cfi %ecx # equivalent to addl $4,%esp
25225 ret
25226 CFI_ENDPROC
25227 -ENDPROC(csum_partial_copy_generic)
25228 +ENDPROC(csum_partial_copy_generic_to_user)
25229
25230 #else
25231
25232 /* Version for PentiumII/PPro */
25233
25234 #define ROUND1(x) \
25235 + nop; nop; nop; \
25236 SRC(movl x(%esi), %ebx ) ; \
25237 addl %ebx, %eax ; \
25238 - DST(movl %ebx, x(%edi) ) ;
25239 + DST(movl %ebx, %es:x(%edi)) ;
25240
25241 #define ROUND(x) \
25242 + nop; nop; nop; \
25243 SRC(movl x(%esi), %ebx ) ; \
25244 adcl %ebx, %eax ; \
25245 - DST(movl %ebx, x(%edi) ) ;
25246 + DST(movl %ebx, %es:x(%edi)) ;
25247
25248 #define ARGBASE 12
25249 -
25250 -ENTRY(csum_partial_copy_generic)
25251 +
25252 +ENTRY(csum_partial_copy_generic_to_user)
25253 CFI_STARTPROC
25254 +
25255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25256 + pushl_cfi %gs
25257 + popl_cfi %es
25258 + jmp csum_partial_copy_generic
25259 +#endif
25260 +
25261 +ENTRY(csum_partial_copy_generic_from_user)
25262 +
25263 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25264 + pushl_cfi %gs
25265 + popl_cfi %ds
25266 +#endif
25267 +
25268 +ENTRY(csum_partial_copy_generic)
25269 pushl_cfi %ebx
25270 CFI_REL_OFFSET ebx, 0
25271 pushl_cfi %edi
25272 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25273 subl %ebx, %edi
25274 lea -1(%esi),%edx
25275 andl $-32,%edx
25276 - lea 3f(%ebx,%ebx), %ebx
25277 + lea 3f(%ebx,%ebx,2), %ebx
25278 testl %esi, %esi
25279 jmp *%ebx
25280 1: addl $64,%esi
25281 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25282 jb 5f
25283 SRC( movw (%esi), %dx )
25284 leal 2(%esi), %esi
25285 -DST( movw %dx, (%edi) )
25286 +DST( movw %dx, %es:(%edi) )
25287 leal 2(%edi), %edi
25288 je 6f
25289 shll $16,%edx
25290 5:
25291 SRC( movb (%esi), %dl )
25292 -DST( movb %dl, (%edi) )
25293 +DST( movb %dl, %es:(%edi) )
25294 6: addl %edx, %eax
25295 adcl $0, %eax
25296 7:
25297 .section .fixup, "ax"
25298 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25299 - movl $-EFAULT, (%ebx)
25300 + movl $-EFAULT, %ss:(%ebx)
25301 # zero the complete destination (computing the rest is too much work)
25302 movl ARGBASE+8(%esp),%edi # dst
25303 movl ARGBASE+12(%esp),%ecx # len
25304 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25305 rep; stosb
25306 jmp 7b
25307 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25308 - movl $-EFAULT, (%ebx)
25309 + movl $-EFAULT, %ss:(%ebx)
25310 jmp 7b
25311 .previous
25312
25313 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25314 + pushl_cfi %ss
25315 + popl_cfi %ds
25316 + pushl_cfi %ss
25317 + popl_cfi %es
25318 +#endif
25319 +
25320 popl_cfi %esi
25321 CFI_RESTORE esi
25322 popl_cfi %edi
25323 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25324 CFI_RESTORE ebx
25325 ret
25326 CFI_ENDPROC
25327 -ENDPROC(csum_partial_copy_generic)
25328 +ENDPROC(csum_partial_copy_generic_to_user)
25329
25330 #undef ROUND
25331 #undef ROUND1
25332 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25333 index f2145cf..cea889d 100644
25334 --- a/arch/x86/lib/clear_page_64.S
25335 +++ b/arch/x86/lib/clear_page_64.S
25336 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25337 movl $4096/8,%ecx
25338 xorl %eax,%eax
25339 rep stosq
25340 + pax_force_retaddr
25341 ret
25342 CFI_ENDPROC
25343 ENDPROC(clear_page_c)
25344 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25345 movl $4096,%ecx
25346 xorl %eax,%eax
25347 rep stosb
25348 + pax_force_retaddr
25349 ret
25350 CFI_ENDPROC
25351 ENDPROC(clear_page_c_e)
25352 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25353 leaq 64(%rdi),%rdi
25354 jnz .Lloop
25355 nop
25356 + pax_force_retaddr
25357 ret
25358 CFI_ENDPROC
25359 .Lclear_page_end:
25360 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25361
25362 #include <asm/cpufeature.h>
25363
25364 - .section .altinstr_replacement,"ax"
25365 + .section .altinstr_replacement,"a"
25366 1: .byte 0xeb /* jmp <disp8> */
25367 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25368 2: .byte 0xeb /* jmp <disp8> */
25369 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25370 index 1e572c5..2a162cd 100644
25371 --- a/arch/x86/lib/cmpxchg16b_emu.S
25372 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25373 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25374
25375 popf
25376 mov $1, %al
25377 + pax_force_retaddr
25378 ret
25379
25380 not_same:
25381 popf
25382 xor %al,%al
25383 + pax_force_retaddr
25384 ret
25385
25386 CFI_ENDPROC
25387 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25388 index 176cca6..1166c50 100644
25389 --- a/arch/x86/lib/copy_page_64.S
25390 +++ b/arch/x86/lib/copy_page_64.S
25391 @@ -9,6 +9,7 @@ copy_page_rep:
25392 CFI_STARTPROC
25393 movl $4096/8, %ecx
25394 rep movsq
25395 + pax_force_retaddr
25396 ret
25397 CFI_ENDPROC
25398 ENDPROC(copy_page_rep)
25399 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25400
25401 ENTRY(copy_page)
25402 CFI_STARTPROC
25403 - subq $2*8, %rsp
25404 - CFI_ADJUST_CFA_OFFSET 2*8
25405 + subq $3*8, %rsp
25406 + CFI_ADJUST_CFA_OFFSET 3*8
25407 movq %rbx, (%rsp)
25408 CFI_REL_OFFSET rbx, 0
25409 movq %r12, 1*8(%rsp)
25410 CFI_REL_OFFSET r12, 1*8
25411 + movq %r13, 2*8(%rsp)
25412 + CFI_REL_OFFSET r13, 2*8
25413
25414 movl $(4096/64)-5, %ecx
25415 .p2align 4
25416 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25417 movq 0x8*2(%rsi), %rdx
25418 movq 0x8*3(%rsi), %r8
25419 movq 0x8*4(%rsi), %r9
25420 - movq 0x8*5(%rsi), %r10
25421 + movq 0x8*5(%rsi), %r13
25422 movq 0x8*6(%rsi), %r11
25423 movq 0x8*7(%rsi), %r12
25424
25425 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25426 movq %rdx, 0x8*2(%rdi)
25427 movq %r8, 0x8*3(%rdi)
25428 movq %r9, 0x8*4(%rdi)
25429 - movq %r10, 0x8*5(%rdi)
25430 + movq %r13, 0x8*5(%rdi)
25431 movq %r11, 0x8*6(%rdi)
25432 movq %r12, 0x8*7(%rdi)
25433
25434 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25435 movq 0x8*2(%rsi), %rdx
25436 movq 0x8*3(%rsi), %r8
25437 movq 0x8*4(%rsi), %r9
25438 - movq 0x8*5(%rsi), %r10
25439 + movq 0x8*5(%rsi), %r13
25440 movq 0x8*6(%rsi), %r11
25441 movq 0x8*7(%rsi), %r12
25442
25443 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25444 movq %rdx, 0x8*2(%rdi)
25445 movq %r8, 0x8*3(%rdi)
25446 movq %r9, 0x8*4(%rdi)
25447 - movq %r10, 0x8*5(%rdi)
25448 + movq %r13, 0x8*5(%rdi)
25449 movq %r11, 0x8*6(%rdi)
25450 movq %r12, 0x8*7(%rdi)
25451
25452 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25453 CFI_RESTORE rbx
25454 movq 1*8(%rsp), %r12
25455 CFI_RESTORE r12
25456 - addq $2*8, %rsp
25457 - CFI_ADJUST_CFA_OFFSET -2*8
25458 + movq 2*8(%rsp), %r13
25459 + CFI_RESTORE r13
25460 + addq $3*8, %rsp
25461 + CFI_ADJUST_CFA_OFFSET -3*8
25462 + pax_force_retaddr
25463 ret
25464 .Lcopy_page_end:
25465 CFI_ENDPROC
25466 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25467
25468 #include <asm/cpufeature.h>
25469
25470 - .section .altinstr_replacement,"ax"
25471 + .section .altinstr_replacement,"a"
25472 1: .byte 0xeb /* jmp <disp8> */
25473 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25474 2:
25475 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25476 index a30ca15..d25fab6 100644
25477 --- a/arch/x86/lib/copy_user_64.S
25478 +++ b/arch/x86/lib/copy_user_64.S
25479 @@ -18,6 +18,7 @@
25480 #include <asm/alternative-asm.h>
25481 #include <asm/asm.h>
25482 #include <asm/smap.h>
25483 +#include <asm/pgtable.h>
25484
25485 /*
25486 * By placing feature2 after feature1 in altinstructions section, we logically
25487 @@ -31,7 +32,7 @@
25488 .byte 0xe9 /* 32bit jump */
25489 .long \orig-1f /* by default jump to orig */
25490 1:
25491 - .section .altinstr_replacement,"ax"
25492 + .section .altinstr_replacement,"a"
25493 2: .byte 0xe9 /* near jump with 32bit immediate */
25494 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25495 3: .byte 0xe9 /* near jump with 32bit immediate */
25496 @@ -70,47 +71,20 @@
25497 #endif
25498 .endm
25499
25500 -/* Standard copy_to_user with segment limit checking */
25501 -ENTRY(_copy_to_user)
25502 - CFI_STARTPROC
25503 - GET_THREAD_INFO(%rax)
25504 - movq %rdi,%rcx
25505 - addq %rdx,%rcx
25506 - jc bad_to_user
25507 - cmpq TI_addr_limit(%rax),%rcx
25508 - ja bad_to_user
25509 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25510 - copy_user_generic_unrolled,copy_user_generic_string, \
25511 - copy_user_enhanced_fast_string
25512 - CFI_ENDPROC
25513 -ENDPROC(_copy_to_user)
25514 -
25515 -/* Standard copy_from_user with segment limit checking */
25516 -ENTRY(_copy_from_user)
25517 - CFI_STARTPROC
25518 - GET_THREAD_INFO(%rax)
25519 - movq %rsi,%rcx
25520 - addq %rdx,%rcx
25521 - jc bad_from_user
25522 - cmpq TI_addr_limit(%rax),%rcx
25523 - ja bad_from_user
25524 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25525 - copy_user_generic_unrolled,copy_user_generic_string, \
25526 - copy_user_enhanced_fast_string
25527 - CFI_ENDPROC
25528 -ENDPROC(_copy_from_user)
25529 -
25530 .section .fixup,"ax"
25531 /* must zero dest */
25532 ENTRY(bad_from_user)
25533 bad_from_user:
25534 CFI_STARTPROC
25535 + testl %edx,%edx
25536 + js bad_to_user
25537 movl %edx,%ecx
25538 xorl %eax,%eax
25539 rep
25540 stosb
25541 bad_to_user:
25542 movl %edx,%eax
25543 + pax_force_retaddr
25544 ret
25545 CFI_ENDPROC
25546 ENDPROC(bad_from_user)
25547 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25548 jz 17f
25549 1: movq (%rsi),%r8
25550 2: movq 1*8(%rsi),%r9
25551 -3: movq 2*8(%rsi),%r10
25552 +3: movq 2*8(%rsi),%rax
25553 4: movq 3*8(%rsi),%r11
25554 5: movq %r8,(%rdi)
25555 6: movq %r9,1*8(%rdi)
25556 -7: movq %r10,2*8(%rdi)
25557 +7: movq %rax,2*8(%rdi)
25558 8: movq %r11,3*8(%rdi)
25559 9: movq 4*8(%rsi),%r8
25560 10: movq 5*8(%rsi),%r9
25561 -11: movq 6*8(%rsi),%r10
25562 +11: movq 6*8(%rsi),%rax
25563 12: movq 7*8(%rsi),%r11
25564 13: movq %r8,4*8(%rdi)
25565 14: movq %r9,5*8(%rdi)
25566 -15: movq %r10,6*8(%rdi)
25567 +15: movq %rax,6*8(%rdi)
25568 16: movq %r11,7*8(%rdi)
25569 leaq 64(%rsi),%rsi
25570 leaq 64(%rdi),%rdi
25571 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25572 jnz 21b
25573 23: xor %eax,%eax
25574 ASM_CLAC
25575 + pax_force_retaddr
25576 ret
25577
25578 .section .fixup,"ax"
25579 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25580 movsb
25581 4: xorl %eax,%eax
25582 ASM_CLAC
25583 + pax_force_retaddr
25584 ret
25585
25586 .section .fixup,"ax"
25587 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25588 movsb
25589 2: xorl %eax,%eax
25590 ASM_CLAC
25591 + pax_force_retaddr
25592 ret
25593
25594 .section .fixup,"ax"
25595 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25596 index 6a4f43c..f5f9e26 100644
25597 --- a/arch/x86/lib/copy_user_nocache_64.S
25598 +++ b/arch/x86/lib/copy_user_nocache_64.S
25599 @@ -8,6 +8,7 @@
25600
25601 #include <linux/linkage.h>
25602 #include <asm/dwarf2.h>
25603 +#include <asm/alternative-asm.h>
25604
25605 #define FIX_ALIGNMENT 1
25606
25607 @@ -16,6 +17,7 @@
25608 #include <asm/thread_info.h>
25609 #include <asm/asm.h>
25610 #include <asm/smap.h>
25611 +#include <asm/pgtable.h>
25612
25613 .macro ALIGN_DESTINATION
25614 #ifdef FIX_ALIGNMENT
25615 @@ -49,6 +51,15 @@
25616 */
25617 ENTRY(__copy_user_nocache)
25618 CFI_STARTPROC
25619 +
25620 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25621 + mov $PAX_USER_SHADOW_BASE,%rcx
25622 + cmp %rcx,%rsi
25623 + jae 1f
25624 + add %rcx,%rsi
25625 +1:
25626 +#endif
25627 +
25628 ASM_STAC
25629 cmpl $8,%edx
25630 jb 20f /* less then 8 bytes, go to byte copy loop */
25631 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25632 jz 17f
25633 1: movq (%rsi),%r8
25634 2: movq 1*8(%rsi),%r9
25635 -3: movq 2*8(%rsi),%r10
25636 +3: movq 2*8(%rsi),%rax
25637 4: movq 3*8(%rsi),%r11
25638 5: movnti %r8,(%rdi)
25639 6: movnti %r9,1*8(%rdi)
25640 -7: movnti %r10,2*8(%rdi)
25641 +7: movnti %rax,2*8(%rdi)
25642 8: movnti %r11,3*8(%rdi)
25643 9: movq 4*8(%rsi),%r8
25644 10: movq 5*8(%rsi),%r9
25645 -11: movq 6*8(%rsi),%r10
25646 +11: movq 6*8(%rsi),%rax
25647 12: movq 7*8(%rsi),%r11
25648 13: movnti %r8,4*8(%rdi)
25649 14: movnti %r9,5*8(%rdi)
25650 -15: movnti %r10,6*8(%rdi)
25651 +15: movnti %rax,6*8(%rdi)
25652 16: movnti %r11,7*8(%rdi)
25653 leaq 64(%rsi),%rsi
25654 leaq 64(%rdi),%rdi
25655 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25656 23: xorl %eax,%eax
25657 ASM_CLAC
25658 sfence
25659 + pax_force_retaddr
25660 ret
25661
25662 .section .fixup,"ax"
25663 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25664 index 2419d5f..953ee51 100644
25665 --- a/arch/x86/lib/csum-copy_64.S
25666 +++ b/arch/x86/lib/csum-copy_64.S
25667 @@ -9,6 +9,7 @@
25668 #include <asm/dwarf2.h>
25669 #include <asm/errno.h>
25670 #include <asm/asm.h>
25671 +#include <asm/alternative-asm.h>
25672
25673 /*
25674 * Checksum copy with exception handling.
25675 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25676 CFI_RESTORE rbp
25677 addq $7*8, %rsp
25678 CFI_ADJUST_CFA_OFFSET -7*8
25679 + pax_force_retaddr 0, 1
25680 ret
25681 CFI_RESTORE_STATE
25682
25683 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25684 index 25b7ae8..169fafc 100644
25685 --- a/arch/x86/lib/csum-wrappers_64.c
25686 +++ b/arch/x86/lib/csum-wrappers_64.c
25687 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25688 len -= 2;
25689 }
25690 }
25691 - isum = csum_partial_copy_generic((__force const void *)src,
25692 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25693 dst, len, isum, errp, NULL);
25694 if (unlikely(*errp))
25695 goto out_err;
25696 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25697 }
25698
25699 *errp = 0;
25700 - return csum_partial_copy_generic(src, (void __force *)dst,
25701 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25702 len, isum, NULL, errp);
25703 }
25704 EXPORT_SYMBOL(csum_partial_copy_to_user);
25705 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25706 index 156b9c8..b144132 100644
25707 --- a/arch/x86/lib/getuser.S
25708 +++ b/arch/x86/lib/getuser.S
25709 @@ -34,17 +34,40 @@
25710 #include <asm/thread_info.h>
25711 #include <asm/asm.h>
25712 #include <asm/smap.h>
25713 +#include <asm/segment.h>
25714 +#include <asm/pgtable.h>
25715 +#include <asm/alternative-asm.h>
25716 +
25717 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25718 +#define __copyuser_seg gs;
25719 +#else
25720 +#define __copyuser_seg
25721 +#endif
25722
25723 .text
25724 ENTRY(__get_user_1)
25725 CFI_STARTPROC
25726 +
25727 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25728 GET_THREAD_INFO(%_ASM_DX)
25729 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25730 jae bad_get_user
25731 ASM_STAC
25732 -1: movzb (%_ASM_AX),%edx
25733 +
25734 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25735 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25736 + cmp %_ASM_DX,%_ASM_AX
25737 + jae 1234f
25738 + add %_ASM_DX,%_ASM_AX
25739 +1234:
25740 +#endif
25741 +
25742 +#endif
25743 +
25744 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25745 xor %eax,%eax
25746 ASM_CLAC
25747 + pax_force_retaddr
25748 ret
25749 CFI_ENDPROC
25750 ENDPROC(__get_user_1)
25751 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25752 ENTRY(__get_user_2)
25753 CFI_STARTPROC
25754 add $1,%_ASM_AX
25755 +
25756 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25757 jc bad_get_user
25758 GET_THREAD_INFO(%_ASM_DX)
25759 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25760 jae bad_get_user
25761 ASM_STAC
25762 -2: movzwl -1(%_ASM_AX),%edx
25763 +
25764 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25765 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25766 + cmp %_ASM_DX,%_ASM_AX
25767 + jae 1234f
25768 + add %_ASM_DX,%_ASM_AX
25769 +1234:
25770 +#endif
25771 +
25772 +#endif
25773 +
25774 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25775 xor %eax,%eax
25776 ASM_CLAC
25777 + pax_force_retaddr
25778 ret
25779 CFI_ENDPROC
25780 ENDPROC(__get_user_2)
25781 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25782 ENTRY(__get_user_4)
25783 CFI_STARTPROC
25784 add $3,%_ASM_AX
25785 +
25786 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25787 jc bad_get_user
25788 GET_THREAD_INFO(%_ASM_DX)
25789 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25790 jae bad_get_user
25791 ASM_STAC
25792 -3: mov -3(%_ASM_AX),%edx
25793 +
25794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25795 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25796 + cmp %_ASM_DX,%_ASM_AX
25797 + jae 1234f
25798 + add %_ASM_DX,%_ASM_AX
25799 +1234:
25800 +#endif
25801 +
25802 +#endif
25803 +
25804 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25805 xor %eax,%eax
25806 ASM_CLAC
25807 + pax_force_retaddr
25808 ret
25809 CFI_ENDPROC
25810 ENDPROC(__get_user_4)
25811 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25812 GET_THREAD_INFO(%_ASM_DX)
25813 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25814 jae bad_get_user
25815 +
25816 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25817 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25818 + cmp %_ASM_DX,%_ASM_AX
25819 + jae 1234f
25820 + add %_ASM_DX,%_ASM_AX
25821 +1234:
25822 +#endif
25823 +
25824 ASM_STAC
25825 4: movq -7(%_ASM_AX),%_ASM_DX
25826 xor %eax,%eax
25827 ASM_CLAC
25828 + pax_force_retaddr
25829 ret
25830 CFI_ENDPROC
25831 ENDPROC(__get_user_8)
25832 @@ -101,6 +162,7 @@ bad_get_user:
25833 xor %edx,%edx
25834 mov $(-EFAULT),%_ASM_AX
25835 ASM_CLAC
25836 + pax_force_retaddr
25837 ret
25838 CFI_ENDPROC
25839 END(bad_get_user)
25840 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25841 index 54fcffe..7be149e 100644
25842 --- a/arch/x86/lib/insn.c
25843 +++ b/arch/x86/lib/insn.c
25844 @@ -20,8 +20,10 @@
25845
25846 #ifdef __KERNEL__
25847 #include <linux/string.h>
25848 +#include <asm/pgtable_types.h>
25849 #else
25850 #include <string.h>
25851 +#define ktla_ktva(addr) addr
25852 #endif
25853 #include <asm/inat.h>
25854 #include <asm/insn.h>
25855 @@ -53,8 +55,8 @@
25856 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25857 {
25858 memset(insn, 0, sizeof(*insn));
25859 - insn->kaddr = kaddr;
25860 - insn->next_byte = kaddr;
25861 + insn->kaddr = ktla_ktva(kaddr);
25862 + insn->next_byte = ktla_ktva(kaddr);
25863 insn->x86_64 = x86_64 ? 1 : 0;
25864 insn->opnd_bytes = 4;
25865 if (x86_64)
25866 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25867 index 05a95e7..326f2fa 100644
25868 --- a/arch/x86/lib/iomap_copy_64.S
25869 +++ b/arch/x86/lib/iomap_copy_64.S
25870 @@ -17,6 +17,7 @@
25871
25872 #include <linux/linkage.h>
25873 #include <asm/dwarf2.h>
25874 +#include <asm/alternative-asm.h>
25875
25876 /*
25877 * override generic version in lib/iomap_copy.c
25878 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25879 CFI_STARTPROC
25880 movl %edx,%ecx
25881 rep movsd
25882 + pax_force_retaddr
25883 ret
25884 CFI_ENDPROC
25885 ENDPROC(__iowrite32_copy)
25886 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25887 index 1c273be..da9cc0e 100644
25888 --- a/arch/x86/lib/memcpy_64.S
25889 +++ b/arch/x86/lib/memcpy_64.S
25890 @@ -33,6 +33,7 @@
25891 rep movsq
25892 movl %edx, %ecx
25893 rep movsb
25894 + pax_force_retaddr
25895 ret
25896 .Lmemcpy_e:
25897 .previous
25898 @@ -49,6 +50,7 @@
25899 movq %rdi, %rax
25900 movq %rdx, %rcx
25901 rep movsb
25902 + pax_force_retaddr
25903 ret
25904 .Lmemcpy_e_e:
25905 .previous
25906 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25907 */
25908 movq 0*8(%rsi), %r8
25909 movq 1*8(%rsi), %r9
25910 - movq 2*8(%rsi), %r10
25911 + movq 2*8(%rsi), %rcx
25912 movq 3*8(%rsi), %r11
25913 leaq 4*8(%rsi), %rsi
25914
25915 movq %r8, 0*8(%rdi)
25916 movq %r9, 1*8(%rdi)
25917 - movq %r10, 2*8(%rdi)
25918 + movq %rcx, 2*8(%rdi)
25919 movq %r11, 3*8(%rdi)
25920 leaq 4*8(%rdi), %rdi
25921 jae .Lcopy_forward_loop
25922 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25923 subq $0x20, %rdx
25924 movq -1*8(%rsi), %r8
25925 movq -2*8(%rsi), %r9
25926 - movq -3*8(%rsi), %r10
25927 + movq -3*8(%rsi), %rcx
25928 movq -4*8(%rsi), %r11
25929 leaq -4*8(%rsi), %rsi
25930 movq %r8, -1*8(%rdi)
25931 movq %r9, -2*8(%rdi)
25932 - movq %r10, -3*8(%rdi)
25933 + movq %rcx, -3*8(%rdi)
25934 movq %r11, -4*8(%rdi)
25935 leaq -4*8(%rdi), %rdi
25936 jae .Lcopy_backward_loop
25937 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25938 */
25939 movq 0*8(%rsi), %r8
25940 movq 1*8(%rsi), %r9
25941 - movq -2*8(%rsi, %rdx), %r10
25942 + movq -2*8(%rsi, %rdx), %rcx
25943 movq -1*8(%rsi, %rdx), %r11
25944 movq %r8, 0*8(%rdi)
25945 movq %r9, 1*8(%rdi)
25946 - movq %r10, -2*8(%rdi, %rdx)
25947 + movq %rcx, -2*8(%rdi, %rdx)
25948 movq %r11, -1*8(%rdi, %rdx)
25949 + pax_force_retaddr
25950 retq
25951 .p2align 4
25952 .Lless_16bytes:
25953 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25954 movq -1*8(%rsi, %rdx), %r9
25955 movq %r8, 0*8(%rdi)
25956 movq %r9, -1*8(%rdi, %rdx)
25957 + pax_force_retaddr
25958 retq
25959 .p2align 4
25960 .Lless_8bytes:
25961 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25962 movl -4(%rsi, %rdx), %r8d
25963 movl %ecx, (%rdi)
25964 movl %r8d, -4(%rdi, %rdx)
25965 + pax_force_retaddr
25966 retq
25967 .p2align 4
25968 .Lless_3bytes:
25969 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25970 movb %cl, (%rdi)
25971
25972 .Lend:
25973 + pax_force_retaddr
25974 retq
25975 CFI_ENDPROC
25976 ENDPROC(memcpy)
25977 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25978 index ee16461..c39c199 100644
25979 --- a/arch/x86/lib/memmove_64.S
25980 +++ b/arch/x86/lib/memmove_64.S
25981 @@ -61,13 +61,13 @@ ENTRY(memmove)
25982 5:
25983 sub $0x20, %rdx
25984 movq 0*8(%rsi), %r11
25985 - movq 1*8(%rsi), %r10
25986 + movq 1*8(%rsi), %rcx
25987 movq 2*8(%rsi), %r9
25988 movq 3*8(%rsi), %r8
25989 leaq 4*8(%rsi), %rsi
25990
25991 movq %r11, 0*8(%rdi)
25992 - movq %r10, 1*8(%rdi)
25993 + movq %rcx, 1*8(%rdi)
25994 movq %r9, 2*8(%rdi)
25995 movq %r8, 3*8(%rdi)
25996 leaq 4*8(%rdi), %rdi
25997 @@ -81,10 +81,10 @@ ENTRY(memmove)
25998 4:
25999 movq %rdx, %rcx
26000 movq -8(%rsi, %rdx), %r11
26001 - lea -8(%rdi, %rdx), %r10
26002 + lea -8(%rdi, %rdx), %r9
26003 shrq $3, %rcx
26004 rep movsq
26005 - movq %r11, (%r10)
26006 + movq %r11, (%r9)
26007 jmp 13f
26008 .Lmemmove_end_forward:
26009
26010 @@ -95,14 +95,14 @@ ENTRY(memmove)
26011 7:
26012 movq %rdx, %rcx
26013 movq (%rsi), %r11
26014 - movq %rdi, %r10
26015 + movq %rdi, %r9
26016 leaq -8(%rsi, %rdx), %rsi
26017 leaq -8(%rdi, %rdx), %rdi
26018 shrq $3, %rcx
26019 std
26020 rep movsq
26021 cld
26022 - movq %r11, (%r10)
26023 + movq %r11, (%r9)
26024 jmp 13f
26025
26026 /*
26027 @@ -127,13 +127,13 @@ ENTRY(memmove)
26028 8:
26029 subq $0x20, %rdx
26030 movq -1*8(%rsi), %r11
26031 - movq -2*8(%rsi), %r10
26032 + movq -2*8(%rsi), %rcx
26033 movq -3*8(%rsi), %r9
26034 movq -4*8(%rsi), %r8
26035 leaq -4*8(%rsi), %rsi
26036
26037 movq %r11, -1*8(%rdi)
26038 - movq %r10, -2*8(%rdi)
26039 + movq %rcx, -2*8(%rdi)
26040 movq %r9, -3*8(%rdi)
26041 movq %r8, -4*8(%rdi)
26042 leaq -4*8(%rdi), %rdi
26043 @@ -151,11 +151,11 @@ ENTRY(memmove)
26044 * Move data from 16 bytes to 31 bytes.
26045 */
26046 movq 0*8(%rsi), %r11
26047 - movq 1*8(%rsi), %r10
26048 + movq 1*8(%rsi), %rcx
26049 movq -2*8(%rsi, %rdx), %r9
26050 movq -1*8(%rsi, %rdx), %r8
26051 movq %r11, 0*8(%rdi)
26052 - movq %r10, 1*8(%rdi)
26053 + movq %rcx, 1*8(%rdi)
26054 movq %r9, -2*8(%rdi, %rdx)
26055 movq %r8, -1*8(%rdi, %rdx)
26056 jmp 13f
26057 @@ -167,9 +167,9 @@ ENTRY(memmove)
26058 * Move data from 8 bytes to 15 bytes.
26059 */
26060 movq 0*8(%rsi), %r11
26061 - movq -1*8(%rsi, %rdx), %r10
26062 + movq -1*8(%rsi, %rdx), %r9
26063 movq %r11, 0*8(%rdi)
26064 - movq %r10, -1*8(%rdi, %rdx)
26065 + movq %r9, -1*8(%rdi, %rdx)
26066 jmp 13f
26067 10:
26068 cmpq $4, %rdx
26069 @@ -178,9 +178,9 @@ ENTRY(memmove)
26070 * Move data from 4 bytes to 7 bytes.
26071 */
26072 movl (%rsi), %r11d
26073 - movl -4(%rsi, %rdx), %r10d
26074 + movl -4(%rsi, %rdx), %r9d
26075 movl %r11d, (%rdi)
26076 - movl %r10d, -4(%rdi, %rdx)
26077 + movl %r9d, -4(%rdi, %rdx)
26078 jmp 13f
26079 11:
26080 cmp $2, %rdx
26081 @@ -189,9 +189,9 @@ ENTRY(memmove)
26082 * Move data from 2 bytes to 3 bytes.
26083 */
26084 movw (%rsi), %r11w
26085 - movw -2(%rsi, %rdx), %r10w
26086 + movw -2(%rsi, %rdx), %r9w
26087 movw %r11w, (%rdi)
26088 - movw %r10w, -2(%rdi, %rdx)
26089 + movw %r9w, -2(%rdi, %rdx)
26090 jmp 13f
26091 12:
26092 cmp $1, %rdx
26093 @@ -202,6 +202,7 @@ ENTRY(memmove)
26094 movb (%rsi), %r11b
26095 movb %r11b, (%rdi)
26096 13:
26097 + pax_force_retaddr
26098 retq
26099 CFI_ENDPROC
26100
26101 @@ -210,6 +211,7 @@ ENTRY(memmove)
26102 /* Forward moving data. */
26103 movq %rdx, %rcx
26104 rep movsb
26105 + pax_force_retaddr
26106 retq
26107 .Lmemmove_end_forward_efs:
26108 .previous
26109 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26110 index 2dcb380..963660a 100644
26111 --- a/arch/x86/lib/memset_64.S
26112 +++ b/arch/x86/lib/memset_64.S
26113 @@ -30,6 +30,7 @@
26114 movl %edx,%ecx
26115 rep stosb
26116 movq %r9,%rax
26117 + pax_force_retaddr
26118 ret
26119 .Lmemset_e:
26120 .previous
26121 @@ -52,6 +53,7 @@
26122 movq %rdx,%rcx
26123 rep stosb
26124 movq %r9,%rax
26125 + pax_force_retaddr
26126 ret
26127 .Lmemset_e_e:
26128 .previous
26129 @@ -59,7 +61,7 @@
26130 ENTRY(memset)
26131 ENTRY(__memset)
26132 CFI_STARTPROC
26133 - movq %rdi,%r10
26134 + movq %rdi,%r11
26135
26136 /* expand byte value */
26137 movzbl %sil,%ecx
26138 @@ -117,7 +119,8 @@ ENTRY(__memset)
26139 jnz .Lloop_1
26140
26141 .Lende:
26142 - movq %r10,%rax
26143 + movq %r11,%rax
26144 + pax_force_retaddr
26145 ret
26146
26147 CFI_RESTORE_STATE
26148 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26149 index c9f2d9b..e7fd2c0 100644
26150 --- a/arch/x86/lib/mmx_32.c
26151 +++ b/arch/x86/lib/mmx_32.c
26152 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26153 {
26154 void *p;
26155 int i;
26156 + unsigned long cr0;
26157
26158 if (unlikely(in_interrupt()))
26159 return __memcpy(to, from, len);
26160 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26161 kernel_fpu_begin();
26162
26163 __asm__ __volatile__ (
26164 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26165 - " prefetch 64(%0)\n"
26166 - " prefetch 128(%0)\n"
26167 - " prefetch 192(%0)\n"
26168 - " prefetch 256(%0)\n"
26169 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26170 + " prefetch 64(%1)\n"
26171 + " prefetch 128(%1)\n"
26172 + " prefetch 192(%1)\n"
26173 + " prefetch 256(%1)\n"
26174 "2: \n"
26175 ".section .fixup, \"ax\"\n"
26176 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26177 + "3: \n"
26178 +
26179 +#ifdef CONFIG_PAX_KERNEXEC
26180 + " movl %%cr0, %0\n"
26181 + " movl %0, %%eax\n"
26182 + " andl $0xFFFEFFFF, %%eax\n"
26183 + " movl %%eax, %%cr0\n"
26184 +#endif
26185 +
26186 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26187 +
26188 +#ifdef CONFIG_PAX_KERNEXEC
26189 + " movl %0, %%cr0\n"
26190 +#endif
26191 +
26192 " jmp 2b\n"
26193 ".previous\n"
26194 _ASM_EXTABLE(1b, 3b)
26195 - : : "r" (from));
26196 + : "=&r" (cr0) : "r" (from) : "ax");
26197
26198 for ( ; i > 5; i--) {
26199 __asm__ __volatile__ (
26200 - "1: prefetch 320(%0)\n"
26201 - "2: movq (%0), %%mm0\n"
26202 - " movq 8(%0), %%mm1\n"
26203 - " movq 16(%0), %%mm2\n"
26204 - " movq 24(%0), %%mm3\n"
26205 - " movq %%mm0, (%1)\n"
26206 - " movq %%mm1, 8(%1)\n"
26207 - " movq %%mm2, 16(%1)\n"
26208 - " movq %%mm3, 24(%1)\n"
26209 - " movq 32(%0), %%mm0\n"
26210 - " movq 40(%0), %%mm1\n"
26211 - " movq 48(%0), %%mm2\n"
26212 - " movq 56(%0), %%mm3\n"
26213 - " movq %%mm0, 32(%1)\n"
26214 - " movq %%mm1, 40(%1)\n"
26215 - " movq %%mm2, 48(%1)\n"
26216 - " movq %%mm3, 56(%1)\n"
26217 + "1: prefetch 320(%1)\n"
26218 + "2: movq (%1), %%mm0\n"
26219 + " movq 8(%1), %%mm1\n"
26220 + " movq 16(%1), %%mm2\n"
26221 + " movq 24(%1), %%mm3\n"
26222 + " movq %%mm0, (%2)\n"
26223 + " movq %%mm1, 8(%2)\n"
26224 + " movq %%mm2, 16(%2)\n"
26225 + " movq %%mm3, 24(%2)\n"
26226 + " movq 32(%1), %%mm0\n"
26227 + " movq 40(%1), %%mm1\n"
26228 + " movq 48(%1), %%mm2\n"
26229 + " movq 56(%1), %%mm3\n"
26230 + " movq %%mm0, 32(%2)\n"
26231 + " movq %%mm1, 40(%2)\n"
26232 + " movq %%mm2, 48(%2)\n"
26233 + " movq %%mm3, 56(%2)\n"
26234 ".section .fixup, \"ax\"\n"
26235 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26236 + "3:\n"
26237 +
26238 +#ifdef CONFIG_PAX_KERNEXEC
26239 + " movl %%cr0, %0\n"
26240 + " movl %0, %%eax\n"
26241 + " andl $0xFFFEFFFF, %%eax\n"
26242 + " movl %%eax, %%cr0\n"
26243 +#endif
26244 +
26245 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26246 +
26247 +#ifdef CONFIG_PAX_KERNEXEC
26248 + " movl %0, %%cr0\n"
26249 +#endif
26250 +
26251 " jmp 2b\n"
26252 ".previous\n"
26253 _ASM_EXTABLE(1b, 3b)
26254 - : : "r" (from), "r" (to) : "memory");
26255 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26256
26257 from += 64;
26258 to += 64;
26259 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26260 static void fast_copy_page(void *to, void *from)
26261 {
26262 int i;
26263 + unsigned long cr0;
26264
26265 kernel_fpu_begin();
26266
26267 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26268 * but that is for later. -AV
26269 */
26270 __asm__ __volatile__(
26271 - "1: prefetch (%0)\n"
26272 - " prefetch 64(%0)\n"
26273 - " prefetch 128(%0)\n"
26274 - " prefetch 192(%0)\n"
26275 - " prefetch 256(%0)\n"
26276 + "1: prefetch (%1)\n"
26277 + " prefetch 64(%1)\n"
26278 + " prefetch 128(%1)\n"
26279 + " prefetch 192(%1)\n"
26280 + " prefetch 256(%1)\n"
26281 "2: \n"
26282 ".section .fixup, \"ax\"\n"
26283 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26284 + "3: \n"
26285 +
26286 +#ifdef CONFIG_PAX_KERNEXEC
26287 + " movl %%cr0, %0\n"
26288 + " movl %0, %%eax\n"
26289 + " andl $0xFFFEFFFF, %%eax\n"
26290 + " movl %%eax, %%cr0\n"
26291 +#endif
26292 +
26293 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26294 +
26295 +#ifdef CONFIG_PAX_KERNEXEC
26296 + " movl %0, %%cr0\n"
26297 +#endif
26298 +
26299 " jmp 2b\n"
26300 ".previous\n"
26301 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26302 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26303
26304 for (i = 0; i < (4096-320)/64; i++) {
26305 __asm__ __volatile__ (
26306 - "1: prefetch 320(%0)\n"
26307 - "2: movq (%0), %%mm0\n"
26308 - " movntq %%mm0, (%1)\n"
26309 - " movq 8(%0), %%mm1\n"
26310 - " movntq %%mm1, 8(%1)\n"
26311 - " movq 16(%0), %%mm2\n"
26312 - " movntq %%mm2, 16(%1)\n"
26313 - " movq 24(%0), %%mm3\n"
26314 - " movntq %%mm3, 24(%1)\n"
26315 - " movq 32(%0), %%mm4\n"
26316 - " movntq %%mm4, 32(%1)\n"
26317 - " movq 40(%0), %%mm5\n"
26318 - " movntq %%mm5, 40(%1)\n"
26319 - " movq 48(%0), %%mm6\n"
26320 - " movntq %%mm6, 48(%1)\n"
26321 - " movq 56(%0), %%mm7\n"
26322 - " movntq %%mm7, 56(%1)\n"
26323 + "1: prefetch 320(%1)\n"
26324 + "2: movq (%1), %%mm0\n"
26325 + " movntq %%mm0, (%2)\n"
26326 + " movq 8(%1), %%mm1\n"
26327 + " movntq %%mm1, 8(%2)\n"
26328 + " movq 16(%1), %%mm2\n"
26329 + " movntq %%mm2, 16(%2)\n"
26330 + " movq 24(%1), %%mm3\n"
26331 + " movntq %%mm3, 24(%2)\n"
26332 + " movq 32(%1), %%mm4\n"
26333 + " movntq %%mm4, 32(%2)\n"
26334 + " movq 40(%1), %%mm5\n"
26335 + " movntq %%mm5, 40(%2)\n"
26336 + " movq 48(%1), %%mm6\n"
26337 + " movntq %%mm6, 48(%2)\n"
26338 + " movq 56(%1), %%mm7\n"
26339 + " movntq %%mm7, 56(%2)\n"
26340 ".section .fixup, \"ax\"\n"
26341 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26342 + "3:\n"
26343 +
26344 +#ifdef CONFIG_PAX_KERNEXEC
26345 + " movl %%cr0, %0\n"
26346 + " movl %0, %%eax\n"
26347 + " andl $0xFFFEFFFF, %%eax\n"
26348 + " movl %%eax, %%cr0\n"
26349 +#endif
26350 +
26351 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26352 +
26353 +#ifdef CONFIG_PAX_KERNEXEC
26354 + " movl %0, %%cr0\n"
26355 +#endif
26356 +
26357 " jmp 2b\n"
26358 ".previous\n"
26359 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26360 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26361
26362 from += 64;
26363 to += 64;
26364 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26365 static void fast_copy_page(void *to, void *from)
26366 {
26367 int i;
26368 + unsigned long cr0;
26369
26370 kernel_fpu_begin();
26371
26372 __asm__ __volatile__ (
26373 - "1: prefetch (%0)\n"
26374 - " prefetch 64(%0)\n"
26375 - " prefetch 128(%0)\n"
26376 - " prefetch 192(%0)\n"
26377 - " prefetch 256(%0)\n"
26378 + "1: prefetch (%1)\n"
26379 + " prefetch 64(%1)\n"
26380 + " prefetch 128(%1)\n"
26381 + " prefetch 192(%1)\n"
26382 + " prefetch 256(%1)\n"
26383 "2: \n"
26384 ".section .fixup, \"ax\"\n"
26385 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26386 + "3: \n"
26387 +
26388 +#ifdef CONFIG_PAX_KERNEXEC
26389 + " movl %%cr0, %0\n"
26390 + " movl %0, %%eax\n"
26391 + " andl $0xFFFEFFFF, %%eax\n"
26392 + " movl %%eax, %%cr0\n"
26393 +#endif
26394 +
26395 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26396 +
26397 +#ifdef CONFIG_PAX_KERNEXEC
26398 + " movl %0, %%cr0\n"
26399 +#endif
26400 +
26401 " jmp 2b\n"
26402 ".previous\n"
26403 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26404 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26405
26406 for (i = 0; i < 4096/64; i++) {
26407 __asm__ __volatile__ (
26408 - "1: prefetch 320(%0)\n"
26409 - "2: movq (%0), %%mm0\n"
26410 - " movq 8(%0), %%mm1\n"
26411 - " movq 16(%0), %%mm2\n"
26412 - " movq 24(%0), %%mm3\n"
26413 - " movq %%mm0, (%1)\n"
26414 - " movq %%mm1, 8(%1)\n"
26415 - " movq %%mm2, 16(%1)\n"
26416 - " movq %%mm3, 24(%1)\n"
26417 - " movq 32(%0), %%mm0\n"
26418 - " movq 40(%0), %%mm1\n"
26419 - " movq 48(%0), %%mm2\n"
26420 - " movq 56(%0), %%mm3\n"
26421 - " movq %%mm0, 32(%1)\n"
26422 - " movq %%mm1, 40(%1)\n"
26423 - " movq %%mm2, 48(%1)\n"
26424 - " movq %%mm3, 56(%1)\n"
26425 + "1: prefetch 320(%1)\n"
26426 + "2: movq (%1), %%mm0\n"
26427 + " movq 8(%1), %%mm1\n"
26428 + " movq 16(%1), %%mm2\n"
26429 + " movq 24(%1), %%mm3\n"
26430 + " movq %%mm0, (%2)\n"
26431 + " movq %%mm1, 8(%2)\n"
26432 + " movq %%mm2, 16(%2)\n"
26433 + " movq %%mm3, 24(%2)\n"
26434 + " movq 32(%1), %%mm0\n"
26435 + " movq 40(%1), %%mm1\n"
26436 + " movq 48(%1), %%mm2\n"
26437 + " movq 56(%1), %%mm3\n"
26438 + " movq %%mm0, 32(%2)\n"
26439 + " movq %%mm1, 40(%2)\n"
26440 + " movq %%mm2, 48(%2)\n"
26441 + " movq %%mm3, 56(%2)\n"
26442 ".section .fixup, \"ax\"\n"
26443 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26444 + "3:\n"
26445 +
26446 +#ifdef CONFIG_PAX_KERNEXEC
26447 + " movl %%cr0, %0\n"
26448 + " movl %0, %%eax\n"
26449 + " andl $0xFFFEFFFF, %%eax\n"
26450 + " movl %%eax, %%cr0\n"
26451 +#endif
26452 +
26453 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26454 +
26455 +#ifdef CONFIG_PAX_KERNEXEC
26456 + " movl %0, %%cr0\n"
26457 +#endif
26458 +
26459 " jmp 2b\n"
26460 ".previous\n"
26461 _ASM_EXTABLE(1b, 3b)
26462 - : : "r" (from), "r" (to) : "memory");
26463 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26464
26465 from += 64;
26466 to += 64;
26467 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26468 index f6d13ee..aca5f0b 100644
26469 --- a/arch/x86/lib/msr-reg.S
26470 +++ b/arch/x86/lib/msr-reg.S
26471 @@ -3,6 +3,7 @@
26472 #include <asm/dwarf2.h>
26473 #include <asm/asm.h>
26474 #include <asm/msr.h>
26475 +#include <asm/alternative-asm.h>
26476
26477 #ifdef CONFIG_X86_64
26478 /*
26479 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26480 CFI_STARTPROC
26481 pushq_cfi %rbx
26482 pushq_cfi %rbp
26483 - movq %rdi, %r10 /* Save pointer */
26484 + movq %rdi, %r9 /* Save pointer */
26485 xorl %r11d, %r11d /* Return value */
26486 movl (%rdi), %eax
26487 movl 4(%rdi), %ecx
26488 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26489 movl 28(%rdi), %edi
26490 CFI_REMEMBER_STATE
26491 1: \op
26492 -2: movl %eax, (%r10)
26493 +2: movl %eax, (%r9)
26494 movl %r11d, %eax /* Return value */
26495 - movl %ecx, 4(%r10)
26496 - movl %edx, 8(%r10)
26497 - movl %ebx, 12(%r10)
26498 - movl %ebp, 20(%r10)
26499 - movl %esi, 24(%r10)
26500 - movl %edi, 28(%r10)
26501 + movl %ecx, 4(%r9)
26502 + movl %edx, 8(%r9)
26503 + movl %ebx, 12(%r9)
26504 + movl %ebp, 20(%r9)
26505 + movl %esi, 24(%r9)
26506 + movl %edi, 28(%r9)
26507 popq_cfi %rbp
26508 popq_cfi %rbx
26509 + pax_force_retaddr
26510 ret
26511 3:
26512 CFI_RESTORE_STATE
26513 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26514 index fc6ba17..04471c5 100644
26515 --- a/arch/x86/lib/putuser.S
26516 +++ b/arch/x86/lib/putuser.S
26517 @@ -16,7 +16,9 @@
26518 #include <asm/errno.h>
26519 #include <asm/asm.h>
26520 #include <asm/smap.h>
26521 -
26522 +#include <asm/segment.h>
26523 +#include <asm/pgtable.h>
26524 +#include <asm/alternative-asm.h>
26525
26526 /*
26527 * __put_user_X
26528 @@ -30,57 +32,125 @@
26529 * as they get called from within inline assembly.
26530 */
26531
26532 -#define ENTER CFI_STARTPROC ; \
26533 - GET_THREAD_INFO(%_ASM_BX)
26534 -#define EXIT ASM_CLAC ; \
26535 - ret ; \
26536 +#define ENTER CFI_STARTPROC
26537 +#define EXIT ASM_CLAC ; \
26538 + pax_force_retaddr ; \
26539 + ret ; \
26540 CFI_ENDPROC
26541
26542 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26543 +#define _DEST %_ASM_CX,%_ASM_BX
26544 +#else
26545 +#define _DEST %_ASM_CX
26546 +#endif
26547 +
26548 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26549 +#define __copyuser_seg gs;
26550 +#else
26551 +#define __copyuser_seg
26552 +#endif
26553 +
26554 .text
26555 ENTRY(__put_user_1)
26556 ENTER
26557 +
26558 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26559 + GET_THREAD_INFO(%_ASM_BX)
26560 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26561 jae bad_put_user
26562 ASM_STAC
26563 -1: movb %al,(%_ASM_CX)
26564 +
26565 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26566 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26567 + cmp %_ASM_BX,%_ASM_CX
26568 + jb 1234f
26569 + xor %ebx,%ebx
26570 +1234:
26571 +#endif
26572 +
26573 +#endif
26574 +
26575 +1: __copyuser_seg movb %al,(_DEST)
26576 xor %eax,%eax
26577 EXIT
26578 ENDPROC(__put_user_1)
26579
26580 ENTRY(__put_user_2)
26581 ENTER
26582 +
26583 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26584 + GET_THREAD_INFO(%_ASM_BX)
26585 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26586 sub $1,%_ASM_BX
26587 cmp %_ASM_BX,%_ASM_CX
26588 jae bad_put_user
26589 ASM_STAC
26590 -2: movw %ax,(%_ASM_CX)
26591 +
26592 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26593 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26594 + cmp %_ASM_BX,%_ASM_CX
26595 + jb 1234f
26596 + xor %ebx,%ebx
26597 +1234:
26598 +#endif
26599 +
26600 +#endif
26601 +
26602 +2: __copyuser_seg movw %ax,(_DEST)
26603 xor %eax,%eax
26604 EXIT
26605 ENDPROC(__put_user_2)
26606
26607 ENTRY(__put_user_4)
26608 ENTER
26609 +
26610 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26611 + GET_THREAD_INFO(%_ASM_BX)
26612 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26613 sub $3,%_ASM_BX
26614 cmp %_ASM_BX,%_ASM_CX
26615 jae bad_put_user
26616 ASM_STAC
26617 -3: movl %eax,(%_ASM_CX)
26618 +
26619 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26620 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26621 + cmp %_ASM_BX,%_ASM_CX
26622 + jb 1234f
26623 + xor %ebx,%ebx
26624 +1234:
26625 +#endif
26626 +
26627 +#endif
26628 +
26629 +3: __copyuser_seg movl %eax,(_DEST)
26630 xor %eax,%eax
26631 EXIT
26632 ENDPROC(__put_user_4)
26633
26634 ENTRY(__put_user_8)
26635 ENTER
26636 +
26637 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26638 + GET_THREAD_INFO(%_ASM_BX)
26639 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26640 sub $7,%_ASM_BX
26641 cmp %_ASM_BX,%_ASM_CX
26642 jae bad_put_user
26643 ASM_STAC
26644 -4: mov %_ASM_AX,(%_ASM_CX)
26645 +
26646 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26647 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26648 + cmp %_ASM_BX,%_ASM_CX
26649 + jb 1234f
26650 + xor %ebx,%ebx
26651 +1234:
26652 +#endif
26653 +
26654 +#endif
26655 +
26656 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26657 #ifdef CONFIG_X86_32
26658 -5: movl %edx,4(%_ASM_CX)
26659 +5: __copyuser_seg movl %edx,4(_DEST)
26660 #endif
26661 xor %eax,%eax
26662 EXIT
26663 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26664 index 1cad221..de671ee 100644
26665 --- a/arch/x86/lib/rwlock.S
26666 +++ b/arch/x86/lib/rwlock.S
26667 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26668 FRAME
26669 0: LOCK_PREFIX
26670 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26671 +
26672 +#ifdef CONFIG_PAX_REFCOUNT
26673 + jno 1234f
26674 + LOCK_PREFIX
26675 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26676 + int $4
26677 +1234:
26678 + _ASM_EXTABLE(1234b, 1234b)
26679 +#endif
26680 +
26681 1: rep; nop
26682 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26683 jne 1b
26684 LOCK_PREFIX
26685 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26686 +
26687 +#ifdef CONFIG_PAX_REFCOUNT
26688 + jno 1234f
26689 + LOCK_PREFIX
26690 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26691 + int $4
26692 +1234:
26693 + _ASM_EXTABLE(1234b, 1234b)
26694 +#endif
26695 +
26696 jnz 0b
26697 ENDFRAME
26698 + pax_force_retaddr
26699 ret
26700 CFI_ENDPROC
26701 END(__write_lock_failed)
26702 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26703 FRAME
26704 0: LOCK_PREFIX
26705 READ_LOCK_SIZE(inc) (%__lock_ptr)
26706 +
26707 +#ifdef CONFIG_PAX_REFCOUNT
26708 + jno 1234f
26709 + LOCK_PREFIX
26710 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26711 + int $4
26712 +1234:
26713 + _ASM_EXTABLE(1234b, 1234b)
26714 +#endif
26715 +
26716 1: rep; nop
26717 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26718 js 1b
26719 LOCK_PREFIX
26720 READ_LOCK_SIZE(dec) (%__lock_ptr)
26721 +
26722 +#ifdef CONFIG_PAX_REFCOUNT
26723 + jno 1234f
26724 + LOCK_PREFIX
26725 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26726 + int $4
26727 +1234:
26728 + _ASM_EXTABLE(1234b, 1234b)
26729 +#endif
26730 +
26731 js 0b
26732 ENDFRAME
26733 + pax_force_retaddr
26734 ret
26735 CFI_ENDPROC
26736 END(__read_lock_failed)
26737 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26738 index 5dff5f0..cadebf4 100644
26739 --- a/arch/x86/lib/rwsem.S
26740 +++ b/arch/x86/lib/rwsem.S
26741 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26742 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26743 CFI_RESTORE __ASM_REG(dx)
26744 restore_common_regs
26745 + pax_force_retaddr
26746 ret
26747 CFI_ENDPROC
26748 ENDPROC(call_rwsem_down_read_failed)
26749 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26750 movq %rax,%rdi
26751 call rwsem_down_write_failed
26752 restore_common_regs
26753 + pax_force_retaddr
26754 ret
26755 CFI_ENDPROC
26756 ENDPROC(call_rwsem_down_write_failed)
26757 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26758 movq %rax,%rdi
26759 call rwsem_wake
26760 restore_common_regs
26761 -1: ret
26762 +1: pax_force_retaddr
26763 + ret
26764 CFI_ENDPROC
26765 ENDPROC(call_rwsem_wake)
26766
26767 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26768 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26769 CFI_RESTORE __ASM_REG(dx)
26770 restore_common_regs
26771 + pax_force_retaddr
26772 ret
26773 CFI_ENDPROC
26774 ENDPROC(call_rwsem_downgrade_wake)
26775 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26776 index a63efd6..ccecad8 100644
26777 --- a/arch/x86/lib/thunk_64.S
26778 +++ b/arch/x86/lib/thunk_64.S
26779 @@ -8,6 +8,7 @@
26780 #include <linux/linkage.h>
26781 #include <asm/dwarf2.h>
26782 #include <asm/calling.h>
26783 +#include <asm/alternative-asm.h>
26784
26785 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26786 .macro THUNK name, func, put_ret_addr_in_rdi=0
26787 @@ -41,5 +42,6 @@
26788 SAVE_ARGS
26789 restore:
26790 RESTORE_ARGS
26791 + pax_force_retaddr
26792 ret
26793 CFI_ENDPROC
26794 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26795 index f0312d7..9c39d63 100644
26796 --- a/arch/x86/lib/usercopy_32.c
26797 +++ b/arch/x86/lib/usercopy_32.c
26798 @@ -42,11 +42,13 @@ do { \
26799 int __d0; \
26800 might_fault(); \
26801 __asm__ __volatile__( \
26802 + __COPYUSER_SET_ES \
26803 ASM_STAC "\n" \
26804 "0: rep; stosl\n" \
26805 " movl %2,%0\n" \
26806 "1: rep; stosb\n" \
26807 "2: " ASM_CLAC "\n" \
26808 + __COPYUSER_RESTORE_ES \
26809 ".section .fixup,\"ax\"\n" \
26810 "3: lea 0(%2,%0,4),%0\n" \
26811 " jmp 2b\n" \
26812 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26813
26814 #ifdef CONFIG_X86_INTEL_USERCOPY
26815 static unsigned long
26816 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26817 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26818 {
26819 int d0, d1;
26820 __asm__ __volatile__(
26821 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26822 " .align 2,0x90\n"
26823 "3: movl 0(%4), %%eax\n"
26824 "4: movl 4(%4), %%edx\n"
26825 - "5: movl %%eax, 0(%3)\n"
26826 - "6: movl %%edx, 4(%3)\n"
26827 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26828 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26829 "7: movl 8(%4), %%eax\n"
26830 "8: movl 12(%4),%%edx\n"
26831 - "9: movl %%eax, 8(%3)\n"
26832 - "10: movl %%edx, 12(%3)\n"
26833 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26834 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26835 "11: movl 16(%4), %%eax\n"
26836 "12: movl 20(%4), %%edx\n"
26837 - "13: movl %%eax, 16(%3)\n"
26838 - "14: movl %%edx, 20(%3)\n"
26839 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26840 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26841 "15: movl 24(%4), %%eax\n"
26842 "16: movl 28(%4), %%edx\n"
26843 - "17: movl %%eax, 24(%3)\n"
26844 - "18: movl %%edx, 28(%3)\n"
26845 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26846 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26847 "19: movl 32(%4), %%eax\n"
26848 "20: movl 36(%4), %%edx\n"
26849 - "21: movl %%eax, 32(%3)\n"
26850 - "22: movl %%edx, 36(%3)\n"
26851 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26852 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26853 "23: movl 40(%4), %%eax\n"
26854 "24: movl 44(%4), %%edx\n"
26855 - "25: movl %%eax, 40(%3)\n"
26856 - "26: movl %%edx, 44(%3)\n"
26857 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26858 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26859 "27: movl 48(%4), %%eax\n"
26860 "28: movl 52(%4), %%edx\n"
26861 - "29: movl %%eax, 48(%3)\n"
26862 - "30: movl %%edx, 52(%3)\n"
26863 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26864 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26865 "31: movl 56(%4), %%eax\n"
26866 "32: movl 60(%4), %%edx\n"
26867 - "33: movl %%eax, 56(%3)\n"
26868 - "34: movl %%edx, 60(%3)\n"
26869 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26870 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26871 " addl $-64, %0\n"
26872 " addl $64, %4\n"
26873 " addl $64, %3\n"
26874 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26875 " shrl $2, %0\n"
26876 " andl $3, %%eax\n"
26877 " cld\n"
26878 + __COPYUSER_SET_ES
26879 "99: rep; movsl\n"
26880 "36: movl %%eax, %0\n"
26881 "37: rep; movsb\n"
26882 "100:\n"
26883 + __COPYUSER_RESTORE_ES
26884 ".section .fixup,\"ax\"\n"
26885 "101: lea 0(%%eax,%0,4),%0\n"
26886 " jmp 100b\n"
26887 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26888 }
26889
26890 static unsigned long
26891 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26892 +{
26893 + int d0, d1;
26894 + __asm__ __volatile__(
26895 + " .align 2,0x90\n"
26896 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26897 + " cmpl $67, %0\n"
26898 + " jbe 3f\n"
26899 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26900 + " .align 2,0x90\n"
26901 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26902 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26903 + "5: movl %%eax, 0(%3)\n"
26904 + "6: movl %%edx, 4(%3)\n"
26905 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26906 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26907 + "9: movl %%eax, 8(%3)\n"
26908 + "10: movl %%edx, 12(%3)\n"
26909 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26910 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26911 + "13: movl %%eax, 16(%3)\n"
26912 + "14: movl %%edx, 20(%3)\n"
26913 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26914 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26915 + "17: movl %%eax, 24(%3)\n"
26916 + "18: movl %%edx, 28(%3)\n"
26917 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26918 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26919 + "21: movl %%eax, 32(%3)\n"
26920 + "22: movl %%edx, 36(%3)\n"
26921 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26922 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26923 + "25: movl %%eax, 40(%3)\n"
26924 + "26: movl %%edx, 44(%3)\n"
26925 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26926 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26927 + "29: movl %%eax, 48(%3)\n"
26928 + "30: movl %%edx, 52(%3)\n"
26929 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26930 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26931 + "33: movl %%eax, 56(%3)\n"
26932 + "34: movl %%edx, 60(%3)\n"
26933 + " addl $-64, %0\n"
26934 + " addl $64, %4\n"
26935 + " addl $64, %3\n"
26936 + " cmpl $63, %0\n"
26937 + " ja 1b\n"
26938 + "35: movl %0, %%eax\n"
26939 + " shrl $2, %0\n"
26940 + " andl $3, %%eax\n"
26941 + " cld\n"
26942 + "99: rep; "__copyuser_seg" movsl\n"
26943 + "36: movl %%eax, %0\n"
26944 + "37: rep; "__copyuser_seg" movsb\n"
26945 + "100:\n"
26946 + ".section .fixup,\"ax\"\n"
26947 + "101: lea 0(%%eax,%0,4),%0\n"
26948 + " jmp 100b\n"
26949 + ".previous\n"
26950 + _ASM_EXTABLE(1b,100b)
26951 + _ASM_EXTABLE(2b,100b)
26952 + _ASM_EXTABLE(3b,100b)
26953 + _ASM_EXTABLE(4b,100b)
26954 + _ASM_EXTABLE(5b,100b)
26955 + _ASM_EXTABLE(6b,100b)
26956 + _ASM_EXTABLE(7b,100b)
26957 + _ASM_EXTABLE(8b,100b)
26958 + _ASM_EXTABLE(9b,100b)
26959 + _ASM_EXTABLE(10b,100b)
26960 + _ASM_EXTABLE(11b,100b)
26961 + _ASM_EXTABLE(12b,100b)
26962 + _ASM_EXTABLE(13b,100b)
26963 + _ASM_EXTABLE(14b,100b)
26964 + _ASM_EXTABLE(15b,100b)
26965 + _ASM_EXTABLE(16b,100b)
26966 + _ASM_EXTABLE(17b,100b)
26967 + _ASM_EXTABLE(18b,100b)
26968 + _ASM_EXTABLE(19b,100b)
26969 + _ASM_EXTABLE(20b,100b)
26970 + _ASM_EXTABLE(21b,100b)
26971 + _ASM_EXTABLE(22b,100b)
26972 + _ASM_EXTABLE(23b,100b)
26973 + _ASM_EXTABLE(24b,100b)
26974 + _ASM_EXTABLE(25b,100b)
26975 + _ASM_EXTABLE(26b,100b)
26976 + _ASM_EXTABLE(27b,100b)
26977 + _ASM_EXTABLE(28b,100b)
26978 + _ASM_EXTABLE(29b,100b)
26979 + _ASM_EXTABLE(30b,100b)
26980 + _ASM_EXTABLE(31b,100b)
26981 + _ASM_EXTABLE(32b,100b)
26982 + _ASM_EXTABLE(33b,100b)
26983 + _ASM_EXTABLE(34b,100b)
26984 + _ASM_EXTABLE(35b,100b)
26985 + _ASM_EXTABLE(36b,100b)
26986 + _ASM_EXTABLE(37b,100b)
26987 + _ASM_EXTABLE(99b,101b)
26988 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26989 + : "1"(to), "2"(from), "0"(size)
26990 + : "eax", "edx", "memory");
26991 + return size;
26992 +}
26993 +
26994 +static unsigned long __size_overflow(3)
26995 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26996 {
26997 int d0, d1;
26998 __asm__ __volatile__(
26999 " .align 2,0x90\n"
27000 - "0: movl 32(%4), %%eax\n"
27001 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27002 " cmpl $67, %0\n"
27003 " jbe 2f\n"
27004 - "1: movl 64(%4), %%eax\n"
27005 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27006 " .align 2,0x90\n"
27007 - "2: movl 0(%4), %%eax\n"
27008 - "21: movl 4(%4), %%edx\n"
27009 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27010 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27011 " movl %%eax, 0(%3)\n"
27012 " movl %%edx, 4(%3)\n"
27013 - "3: movl 8(%4), %%eax\n"
27014 - "31: movl 12(%4),%%edx\n"
27015 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27016 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27017 " movl %%eax, 8(%3)\n"
27018 " movl %%edx, 12(%3)\n"
27019 - "4: movl 16(%4), %%eax\n"
27020 - "41: movl 20(%4), %%edx\n"
27021 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27022 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27023 " movl %%eax, 16(%3)\n"
27024 " movl %%edx, 20(%3)\n"
27025 - "10: movl 24(%4), %%eax\n"
27026 - "51: movl 28(%4), %%edx\n"
27027 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27028 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27029 " movl %%eax, 24(%3)\n"
27030 " movl %%edx, 28(%3)\n"
27031 - "11: movl 32(%4), %%eax\n"
27032 - "61: movl 36(%4), %%edx\n"
27033 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27034 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27035 " movl %%eax, 32(%3)\n"
27036 " movl %%edx, 36(%3)\n"
27037 - "12: movl 40(%4), %%eax\n"
27038 - "71: movl 44(%4), %%edx\n"
27039 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27040 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27041 " movl %%eax, 40(%3)\n"
27042 " movl %%edx, 44(%3)\n"
27043 - "13: movl 48(%4), %%eax\n"
27044 - "81: movl 52(%4), %%edx\n"
27045 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27046 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27047 " movl %%eax, 48(%3)\n"
27048 " movl %%edx, 52(%3)\n"
27049 - "14: movl 56(%4), %%eax\n"
27050 - "91: movl 60(%4), %%edx\n"
27051 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27052 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27053 " movl %%eax, 56(%3)\n"
27054 " movl %%edx, 60(%3)\n"
27055 " addl $-64, %0\n"
27056 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27057 " shrl $2, %0\n"
27058 " andl $3, %%eax\n"
27059 " cld\n"
27060 - "6: rep; movsl\n"
27061 + "6: rep; "__copyuser_seg" movsl\n"
27062 " movl %%eax,%0\n"
27063 - "7: rep; movsb\n"
27064 + "7: rep; "__copyuser_seg" movsb\n"
27065 "8:\n"
27066 ".section .fixup,\"ax\"\n"
27067 "9: lea 0(%%eax,%0,4),%0\n"
27068 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27069 * hyoshiok@miraclelinux.com
27070 */
27071
27072 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27073 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27074 const void __user *from, unsigned long size)
27075 {
27076 int d0, d1;
27077
27078 __asm__ __volatile__(
27079 " .align 2,0x90\n"
27080 - "0: movl 32(%4), %%eax\n"
27081 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27082 " cmpl $67, %0\n"
27083 " jbe 2f\n"
27084 - "1: movl 64(%4), %%eax\n"
27085 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27086 " .align 2,0x90\n"
27087 - "2: movl 0(%4), %%eax\n"
27088 - "21: movl 4(%4), %%edx\n"
27089 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27090 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27091 " movnti %%eax, 0(%3)\n"
27092 " movnti %%edx, 4(%3)\n"
27093 - "3: movl 8(%4), %%eax\n"
27094 - "31: movl 12(%4),%%edx\n"
27095 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27096 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27097 " movnti %%eax, 8(%3)\n"
27098 " movnti %%edx, 12(%3)\n"
27099 - "4: movl 16(%4), %%eax\n"
27100 - "41: movl 20(%4), %%edx\n"
27101 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27102 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27103 " movnti %%eax, 16(%3)\n"
27104 " movnti %%edx, 20(%3)\n"
27105 - "10: movl 24(%4), %%eax\n"
27106 - "51: movl 28(%4), %%edx\n"
27107 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27108 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27109 " movnti %%eax, 24(%3)\n"
27110 " movnti %%edx, 28(%3)\n"
27111 - "11: movl 32(%4), %%eax\n"
27112 - "61: movl 36(%4), %%edx\n"
27113 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27114 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27115 " movnti %%eax, 32(%3)\n"
27116 " movnti %%edx, 36(%3)\n"
27117 - "12: movl 40(%4), %%eax\n"
27118 - "71: movl 44(%4), %%edx\n"
27119 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27120 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27121 " movnti %%eax, 40(%3)\n"
27122 " movnti %%edx, 44(%3)\n"
27123 - "13: movl 48(%4), %%eax\n"
27124 - "81: movl 52(%4), %%edx\n"
27125 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27126 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27127 " movnti %%eax, 48(%3)\n"
27128 " movnti %%edx, 52(%3)\n"
27129 - "14: movl 56(%4), %%eax\n"
27130 - "91: movl 60(%4), %%edx\n"
27131 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27132 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27133 " movnti %%eax, 56(%3)\n"
27134 " movnti %%edx, 60(%3)\n"
27135 " addl $-64, %0\n"
27136 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27137 " shrl $2, %0\n"
27138 " andl $3, %%eax\n"
27139 " cld\n"
27140 - "6: rep; movsl\n"
27141 + "6: rep; "__copyuser_seg" movsl\n"
27142 " movl %%eax,%0\n"
27143 - "7: rep; movsb\n"
27144 + "7: rep; "__copyuser_seg" movsb\n"
27145 "8:\n"
27146 ".section .fixup,\"ax\"\n"
27147 "9: lea 0(%%eax,%0,4),%0\n"
27148 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27149 return size;
27150 }
27151
27152 -static unsigned long __copy_user_intel_nocache(void *to,
27153 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27154 const void __user *from, unsigned long size)
27155 {
27156 int d0, d1;
27157
27158 __asm__ __volatile__(
27159 " .align 2,0x90\n"
27160 - "0: movl 32(%4), %%eax\n"
27161 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27162 " cmpl $67, %0\n"
27163 " jbe 2f\n"
27164 - "1: movl 64(%4), %%eax\n"
27165 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27166 " .align 2,0x90\n"
27167 - "2: movl 0(%4), %%eax\n"
27168 - "21: movl 4(%4), %%edx\n"
27169 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27170 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27171 " movnti %%eax, 0(%3)\n"
27172 " movnti %%edx, 4(%3)\n"
27173 - "3: movl 8(%4), %%eax\n"
27174 - "31: movl 12(%4),%%edx\n"
27175 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27176 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27177 " movnti %%eax, 8(%3)\n"
27178 " movnti %%edx, 12(%3)\n"
27179 - "4: movl 16(%4), %%eax\n"
27180 - "41: movl 20(%4), %%edx\n"
27181 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27182 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27183 " movnti %%eax, 16(%3)\n"
27184 " movnti %%edx, 20(%3)\n"
27185 - "10: movl 24(%4), %%eax\n"
27186 - "51: movl 28(%4), %%edx\n"
27187 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27188 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27189 " movnti %%eax, 24(%3)\n"
27190 " movnti %%edx, 28(%3)\n"
27191 - "11: movl 32(%4), %%eax\n"
27192 - "61: movl 36(%4), %%edx\n"
27193 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27194 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27195 " movnti %%eax, 32(%3)\n"
27196 " movnti %%edx, 36(%3)\n"
27197 - "12: movl 40(%4), %%eax\n"
27198 - "71: movl 44(%4), %%edx\n"
27199 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27200 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27201 " movnti %%eax, 40(%3)\n"
27202 " movnti %%edx, 44(%3)\n"
27203 - "13: movl 48(%4), %%eax\n"
27204 - "81: movl 52(%4), %%edx\n"
27205 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27206 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27207 " movnti %%eax, 48(%3)\n"
27208 " movnti %%edx, 52(%3)\n"
27209 - "14: movl 56(%4), %%eax\n"
27210 - "91: movl 60(%4), %%edx\n"
27211 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27212 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27213 " movnti %%eax, 56(%3)\n"
27214 " movnti %%edx, 60(%3)\n"
27215 " addl $-64, %0\n"
27216 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27217 " shrl $2, %0\n"
27218 " andl $3, %%eax\n"
27219 " cld\n"
27220 - "6: rep; movsl\n"
27221 + "6: rep; "__copyuser_seg" movsl\n"
27222 " movl %%eax,%0\n"
27223 - "7: rep; movsb\n"
27224 + "7: rep; "__copyuser_seg" movsb\n"
27225 "8:\n"
27226 ".section .fixup,\"ax\"\n"
27227 "9: lea 0(%%eax,%0,4),%0\n"
27228 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27229 */
27230 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27231 unsigned long size);
27232 -unsigned long __copy_user_intel(void __user *to, const void *from,
27233 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27234 + unsigned long size);
27235 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27236 unsigned long size);
27237 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27238 const void __user *from, unsigned long size);
27239 #endif /* CONFIG_X86_INTEL_USERCOPY */
27240
27241 /* Generic arbitrary sized copy. */
27242 -#define __copy_user(to, from, size) \
27243 +#define __copy_user(to, from, size, prefix, set, restore) \
27244 do { \
27245 int __d0, __d1, __d2; \
27246 __asm__ __volatile__( \
27247 + set \
27248 " cmp $7,%0\n" \
27249 " jbe 1f\n" \
27250 " movl %1,%0\n" \
27251 " negl %0\n" \
27252 " andl $7,%0\n" \
27253 " subl %0,%3\n" \
27254 - "4: rep; movsb\n" \
27255 + "4: rep; "prefix"movsb\n" \
27256 " movl %3,%0\n" \
27257 " shrl $2,%0\n" \
27258 " andl $3,%3\n" \
27259 " .align 2,0x90\n" \
27260 - "0: rep; movsl\n" \
27261 + "0: rep; "prefix"movsl\n" \
27262 " movl %3,%0\n" \
27263 - "1: rep; movsb\n" \
27264 + "1: rep; "prefix"movsb\n" \
27265 "2:\n" \
27266 + restore \
27267 ".section .fixup,\"ax\"\n" \
27268 "5: addl %3,%0\n" \
27269 " jmp 2b\n" \
27270 @@ -538,14 +650,14 @@ do { \
27271 " negl %0\n" \
27272 " andl $7,%0\n" \
27273 " subl %0,%3\n" \
27274 - "4: rep; movsb\n" \
27275 + "4: rep; "__copyuser_seg"movsb\n" \
27276 " movl %3,%0\n" \
27277 " shrl $2,%0\n" \
27278 " andl $3,%3\n" \
27279 " .align 2,0x90\n" \
27280 - "0: rep; movsl\n" \
27281 + "0: rep; "__copyuser_seg"movsl\n" \
27282 " movl %3,%0\n" \
27283 - "1: rep; movsb\n" \
27284 + "1: rep; "__copyuser_seg"movsb\n" \
27285 "2:\n" \
27286 ".section .fixup,\"ax\"\n" \
27287 "5: addl %3,%0\n" \
27288 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27289 {
27290 stac();
27291 if (movsl_is_ok(to, from, n))
27292 - __copy_user(to, from, n);
27293 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27294 else
27295 - n = __copy_user_intel(to, from, n);
27296 + n = __generic_copy_to_user_intel(to, from, n);
27297 clac();
27298 return n;
27299 }
27300 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27301 {
27302 stac();
27303 if (movsl_is_ok(to, from, n))
27304 - __copy_user(to, from, n);
27305 + __copy_user(to, from, n, __copyuser_seg, "", "");
27306 else
27307 - n = __copy_user_intel((void __user *)to,
27308 - (const void *)from, n);
27309 + n = __generic_copy_from_user_intel(to, from, n);
27310 clac();
27311 return n;
27312 }
27313 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27314 if (n > 64 && cpu_has_xmm2)
27315 n = __copy_user_intel_nocache(to, from, n);
27316 else
27317 - __copy_user(to, from, n);
27318 + __copy_user(to, from, n, __copyuser_seg, "", "");
27319 #else
27320 - __copy_user(to, from, n);
27321 + __copy_user(to, from, n, __copyuser_seg, "", "");
27322 #endif
27323 clac();
27324 return n;
27325 }
27326 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27327
27328 -/**
27329 - * copy_to_user: - Copy a block of data into user space.
27330 - * @to: Destination address, in user space.
27331 - * @from: Source address, in kernel space.
27332 - * @n: Number of bytes to copy.
27333 - *
27334 - * Context: User context only. This function may sleep.
27335 - *
27336 - * Copy data from kernel space to user space.
27337 - *
27338 - * Returns number of bytes that could not be copied.
27339 - * On success, this will be zero.
27340 - */
27341 -unsigned long
27342 -copy_to_user(void __user *to, const void *from, unsigned long n)
27343 -{
27344 - if (access_ok(VERIFY_WRITE, to, n))
27345 - n = __copy_to_user(to, from, n);
27346 - return n;
27347 -}
27348 -EXPORT_SYMBOL(copy_to_user);
27349 -
27350 -/**
27351 - * copy_from_user: - Copy a block of data from user space.
27352 - * @to: Destination address, in kernel space.
27353 - * @from: Source address, in user space.
27354 - * @n: Number of bytes to copy.
27355 - *
27356 - * Context: User context only. This function may sleep.
27357 - *
27358 - * Copy data from user space to kernel space.
27359 - *
27360 - * Returns number of bytes that could not be copied.
27361 - * On success, this will be zero.
27362 - *
27363 - * If some data could not be copied, this function will pad the copied
27364 - * data to the requested size using zero bytes.
27365 - */
27366 -unsigned long
27367 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27368 -{
27369 - if (access_ok(VERIFY_READ, from, n))
27370 - n = __copy_from_user(to, from, n);
27371 - else
27372 - memset(to, 0, n);
27373 - return n;
27374 -}
27375 -EXPORT_SYMBOL(_copy_from_user);
27376 -
27377 void copy_from_user_overflow(void)
27378 {
27379 WARN(1, "Buffer overflow detected!\n");
27380 }
27381 EXPORT_SYMBOL(copy_from_user_overflow);
27382 +
27383 +void copy_to_user_overflow(void)
27384 +{
27385 + WARN(1, "Buffer overflow detected!\n");
27386 +}
27387 +EXPORT_SYMBOL(copy_to_user_overflow);
27388 +
27389 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27390 +void __set_fs(mm_segment_t x)
27391 +{
27392 + switch (x.seg) {
27393 + case 0:
27394 + loadsegment(gs, 0);
27395 + break;
27396 + case TASK_SIZE_MAX:
27397 + loadsegment(gs, __USER_DS);
27398 + break;
27399 + case -1UL:
27400 + loadsegment(gs, __KERNEL_DS);
27401 + break;
27402 + default:
27403 + BUG();
27404 + }
27405 + return;
27406 +}
27407 +EXPORT_SYMBOL(__set_fs);
27408 +
27409 +void set_fs(mm_segment_t x)
27410 +{
27411 + current_thread_info()->addr_limit = x;
27412 + __set_fs(x);
27413 +}
27414 +EXPORT_SYMBOL(set_fs);
27415 +#endif
27416 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27417 index 906fea3..ee8a097 100644
27418 --- a/arch/x86/lib/usercopy_64.c
27419 +++ b/arch/x86/lib/usercopy_64.c
27420 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27421 _ASM_EXTABLE(0b,3b)
27422 _ASM_EXTABLE(1b,2b)
27423 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27424 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27425 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27426 [zero] "r" (0UL), [eight] "r" (8UL));
27427 clac();
27428 return size;
27429 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27430 }
27431 EXPORT_SYMBOL(clear_user);
27432
27433 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27434 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27435 {
27436 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27437 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27438 - }
27439 - return len;
27440 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27441 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27442 + return len;
27443 }
27444 EXPORT_SYMBOL(copy_in_user);
27445
27446 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27447 * it is not necessary to optimize tail handling.
27448 */
27449 unsigned long
27450 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27451 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27452 {
27453 char c;
27454 unsigned zero_len;
27455 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27456 clac();
27457 return len;
27458 }
27459 +
27460 +void copy_from_user_overflow(void)
27461 +{
27462 + WARN(1, "Buffer overflow detected!\n");
27463 +}
27464 +EXPORT_SYMBOL(copy_from_user_overflow);
27465 +
27466 +void copy_to_user_overflow(void)
27467 +{
27468 + WARN(1, "Buffer overflow detected!\n");
27469 +}
27470 +EXPORT_SYMBOL(copy_to_user_overflow);
27471 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27472 index 903ec1e..c4166b2 100644
27473 --- a/arch/x86/mm/extable.c
27474 +++ b/arch/x86/mm/extable.c
27475 @@ -6,12 +6,24 @@
27476 static inline unsigned long
27477 ex_insn_addr(const struct exception_table_entry *x)
27478 {
27479 - return (unsigned long)&x->insn + x->insn;
27480 + unsigned long reloc = 0;
27481 +
27482 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27483 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27484 +#endif
27485 +
27486 + return (unsigned long)&x->insn + x->insn + reloc;
27487 }
27488 static inline unsigned long
27489 ex_fixup_addr(const struct exception_table_entry *x)
27490 {
27491 - return (unsigned long)&x->fixup + x->fixup;
27492 + unsigned long reloc = 0;
27493 +
27494 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27495 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27496 +#endif
27497 +
27498 + return (unsigned long)&x->fixup + x->fixup + reloc;
27499 }
27500
27501 int fixup_exception(struct pt_regs *regs)
27502 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27503 unsigned long new_ip;
27504
27505 #ifdef CONFIG_PNPBIOS
27506 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27507 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27508 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27509 extern u32 pnp_bios_is_utter_crap;
27510 pnp_bios_is_utter_crap = 1;
27511 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27512 i += 4;
27513 p->fixup -= i;
27514 i += 4;
27515 +
27516 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27517 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27518 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27519 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27520 +#endif
27521 +
27522 }
27523 }
27524
27525 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27526 index 4f7d793..165a8be 100644
27527 --- a/arch/x86/mm/fault.c
27528 +++ b/arch/x86/mm/fault.c
27529 @@ -13,12 +13,19 @@
27530 #include <linux/perf_event.h> /* perf_sw_event */
27531 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27532 #include <linux/prefetch.h> /* prefetchw */
27533 +#include <linux/unistd.h>
27534 +#include <linux/compiler.h>
27535
27536 #include <asm/traps.h> /* dotraplinkage, ... */
27537 #include <asm/pgalloc.h> /* pgd_*(), ... */
27538 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27539 #include <asm/fixmap.h> /* VSYSCALL_START */
27540 #include <asm/context_tracking.h> /* exception_enter(), ... */
27541 +#include <asm/tlbflush.h>
27542 +
27543 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27544 +#include <asm/stacktrace.h>
27545 +#endif
27546
27547 /*
27548 * Page fault error code bits:
27549 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27550 int ret = 0;
27551
27552 /* kprobe_running() needs smp_processor_id() */
27553 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27554 + if (kprobes_built_in() && !user_mode(regs)) {
27555 preempt_disable();
27556 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27557 ret = 1;
27558 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27559 return !instr_lo || (instr_lo>>1) == 1;
27560 case 0x00:
27561 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27562 - if (probe_kernel_address(instr, opcode))
27563 + if (user_mode(regs)) {
27564 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27565 + return 0;
27566 + } else if (probe_kernel_address(instr, opcode))
27567 return 0;
27568
27569 *prefetch = (instr_lo == 0xF) &&
27570 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27571 while (instr < max_instr) {
27572 unsigned char opcode;
27573
27574 - if (probe_kernel_address(instr, opcode))
27575 + if (user_mode(regs)) {
27576 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27577 + break;
27578 + } else if (probe_kernel_address(instr, opcode))
27579 break;
27580
27581 instr++;
27582 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27583 force_sig_info(si_signo, &info, tsk);
27584 }
27585
27586 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27587 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27588 +#endif
27589 +
27590 +#ifdef CONFIG_PAX_EMUTRAMP
27591 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27592 +#endif
27593 +
27594 +#ifdef CONFIG_PAX_PAGEEXEC
27595 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27596 +{
27597 + pgd_t *pgd;
27598 + pud_t *pud;
27599 + pmd_t *pmd;
27600 +
27601 + pgd = pgd_offset(mm, address);
27602 + if (!pgd_present(*pgd))
27603 + return NULL;
27604 + pud = pud_offset(pgd, address);
27605 + if (!pud_present(*pud))
27606 + return NULL;
27607 + pmd = pmd_offset(pud, address);
27608 + if (!pmd_present(*pmd))
27609 + return NULL;
27610 + return pmd;
27611 +}
27612 +#endif
27613 +
27614 DEFINE_SPINLOCK(pgd_lock);
27615 LIST_HEAD(pgd_list);
27616
27617 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27618 for (address = VMALLOC_START & PMD_MASK;
27619 address >= TASK_SIZE && address < FIXADDR_TOP;
27620 address += PMD_SIZE) {
27621 +
27622 +#ifdef CONFIG_PAX_PER_CPU_PGD
27623 + unsigned long cpu;
27624 +#else
27625 struct page *page;
27626 +#endif
27627
27628 spin_lock(&pgd_lock);
27629 +
27630 +#ifdef CONFIG_PAX_PER_CPU_PGD
27631 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27632 + pgd_t *pgd = get_cpu_pgd(cpu);
27633 + pmd_t *ret;
27634 +#else
27635 list_for_each_entry(page, &pgd_list, lru) {
27636 + pgd_t *pgd;
27637 spinlock_t *pgt_lock;
27638 pmd_t *ret;
27639
27640 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27641 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27642
27643 spin_lock(pgt_lock);
27644 - ret = vmalloc_sync_one(page_address(page), address);
27645 + pgd = page_address(page);
27646 +#endif
27647 +
27648 + ret = vmalloc_sync_one(pgd, address);
27649 +
27650 +#ifndef CONFIG_PAX_PER_CPU_PGD
27651 spin_unlock(pgt_lock);
27652 +#endif
27653
27654 if (!ret)
27655 break;
27656 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27657 * an interrupt in the middle of a task switch..
27658 */
27659 pgd_paddr = read_cr3();
27660 +
27661 +#ifdef CONFIG_PAX_PER_CPU_PGD
27662 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27663 +#endif
27664 +
27665 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27666 if (!pmd_k)
27667 return -1;
27668 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27669 * happen within a race in page table update. In the later
27670 * case just flush:
27671 */
27672 +
27673 +#ifdef CONFIG_PAX_PER_CPU_PGD
27674 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27675 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27676 +#else
27677 pgd = pgd_offset(current->active_mm, address);
27678 +#endif
27679 +
27680 pgd_ref = pgd_offset_k(address);
27681 if (pgd_none(*pgd_ref))
27682 return -1;
27683 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27684 static int is_errata100(struct pt_regs *regs, unsigned long address)
27685 {
27686 #ifdef CONFIG_X86_64
27687 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27688 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27689 return 1;
27690 #endif
27691 return 0;
27692 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27693 }
27694
27695 static const char nx_warning[] = KERN_CRIT
27696 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27697 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27698
27699 static void
27700 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27701 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27702 if (!oops_may_print())
27703 return;
27704
27705 - if (error_code & PF_INSTR) {
27706 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27707 unsigned int level;
27708
27709 pte_t *pte = lookup_address(address, &level);
27710
27711 if (pte && pte_present(*pte) && !pte_exec(*pte))
27712 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27713 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27714 }
27715
27716 +#ifdef CONFIG_PAX_KERNEXEC
27717 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27718 + if (current->signal->curr_ip)
27719 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27720 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27721 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27722 + else
27723 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27724 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27725 + }
27726 +#endif
27727 +
27728 printk(KERN_ALERT "BUG: unable to handle kernel ");
27729 if (address < PAGE_SIZE)
27730 printk(KERN_CONT "NULL pointer dereference");
27731 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27732 return;
27733 }
27734 #endif
27735 +
27736 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27737 + if (pax_is_fetch_fault(regs, error_code, address)) {
27738 +
27739 +#ifdef CONFIG_PAX_EMUTRAMP
27740 + switch (pax_handle_fetch_fault(regs)) {
27741 + case 2:
27742 + return;
27743 + }
27744 +#endif
27745 +
27746 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27747 + do_group_exit(SIGKILL);
27748 + }
27749 +#endif
27750 +
27751 /* Kernel addresses are always protection faults: */
27752 if (address >= TASK_SIZE)
27753 error_code |= PF_PROT;
27754 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27755 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27756 printk(KERN_ERR
27757 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27758 - tsk->comm, tsk->pid, address);
27759 + tsk->comm, task_pid_nr(tsk), address);
27760 code = BUS_MCEERR_AR;
27761 }
27762 #endif
27763 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27764 return 1;
27765 }
27766
27767 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27768 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27769 +{
27770 + pte_t *pte;
27771 + pmd_t *pmd;
27772 + spinlock_t *ptl;
27773 + unsigned char pte_mask;
27774 +
27775 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27776 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27777 + return 0;
27778 +
27779 + /* PaX: it's our fault, let's handle it if we can */
27780 +
27781 + /* PaX: take a look at read faults before acquiring any locks */
27782 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27783 + /* instruction fetch attempt from a protected page in user mode */
27784 + up_read(&mm->mmap_sem);
27785 +
27786 +#ifdef CONFIG_PAX_EMUTRAMP
27787 + switch (pax_handle_fetch_fault(regs)) {
27788 + case 2:
27789 + return 1;
27790 + }
27791 +#endif
27792 +
27793 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27794 + do_group_exit(SIGKILL);
27795 + }
27796 +
27797 + pmd = pax_get_pmd(mm, address);
27798 + if (unlikely(!pmd))
27799 + return 0;
27800 +
27801 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27802 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27803 + pte_unmap_unlock(pte, ptl);
27804 + return 0;
27805 + }
27806 +
27807 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27808 + /* write attempt to a protected page in user mode */
27809 + pte_unmap_unlock(pte, ptl);
27810 + return 0;
27811 + }
27812 +
27813 +#ifdef CONFIG_SMP
27814 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27815 +#else
27816 + if (likely(address > get_limit(regs->cs)))
27817 +#endif
27818 + {
27819 + set_pte(pte, pte_mkread(*pte));
27820 + __flush_tlb_one(address);
27821 + pte_unmap_unlock(pte, ptl);
27822 + up_read(&mm->mmap_sem);
27823 + return 1;
27824 + }
27825 +
27826 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27827 +
27828 + /*
27829 + * PaX: fill DTLB with user rights and retry
27830 + */
27831 + __asm__ __volatile__ (
27832 + "orb %2,(%1)\n"
27833 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27834 +/*
27835 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27836 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27837 + * page fault when examined during a TLB load attempt. this is true not only
27838 + * for PTEs holding a non-present entry but also present entries that will
27839 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27840 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27841 + * for our target pages since their PTEs are simply not in the TLBs at all.
27842 +
27843 + * the best thing in omitting it is that we gain around 15-20% speed in the
27844 + * fast path of the page fault handler and can get rid of tracing since we
27845 + * can no longer flush unintended entries.
27846 + */
27847 + "invlpg (%0)\n"
27848 +#endif
27849 + __copyuser_seg"testb $0,(%0)\n"
27850 + "xorb %3,(%1)\n"
27851 + :
27852 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27853 + : "memory", "cc");
27854 + pte_unmap_unlock(pte, ptl);
27855 + up_read(&mm->mmap_sem);
27856 + return 1;
27857 +}
27858 +#endif
27859 +
27860 /*
27861 * Handle a spurious fault caused by a stale TLB entry.
27862 *
27863 @@ -970,6 +1162,9 @@ int show_unhandled_signals = 1;
27864 static inline int
27865 access_error(unsigned long error_code, struct vm_area_struct *vma)
27866 {
27867 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27868 + return 1;
27869 +
27870 if (error_code & PF_WRITE) {
27871 /* write, present and write, not present: */
27872 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27873 @@ -998,7 +1193,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27874 if (error_code & PF_USER)
27875 return false;
27876
27877 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27878 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27879 return false;
27880
27881 return true;
27882 @@ -1014,18 +1209,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27883 {
27884 struct vm_area_struct *vma;
27885 struct task_struct *tsk;
27886 - unsigned long address;
27887 struct mm_struct *mm;
27888 int fault;
27889 int write = error_code & PF_WRITE;
27890 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27891 (write ? FAULT_FLAG_WRITE : 0);
27892
27893 - tsk = current;
27894 - mm = tsk->mm;
27895 -
27896 /* Get the faulting address: */
27897 - address = read_cr2();
27898 + unsigned long address = read_cr2();
27899 +
27900 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27901 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27902 + if (!search_exception_tables(regs->ip)) {
27903 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27904 + bad_area_nosemaphore(regs, error_code, address);
27905 + return;
27906 + }
27907 + if (address < PAX_USER_SHADOW_BASE) {
27908 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27909 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27910 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27911 + } else
27912 + address -= PAX_USER_SHADOW_BASE;
27913 + }
27914 +#endif
27915 +
27916 + tsk = current;
27917 + mm = tsk->mm;
27918
27919 /*
27920 * Detect and handle instructions that would cause a page fault for
27921 @@ -1086,7 +1296,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27922 * User-mode registers count as a user access even for any
27923 * potential system fault or CPU buglet:
27924 */
27925 - if (user_mode_vm(regs)) {
27926 + if (user_mode(regs)) {
27927 local_irq_enable();
27928 error_code |= PF_USER;
27929 } else {
27930 @@ -1148,6 +1358,11 @@ retry:
27931 might_sleep();
27932 }
27933
27934 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27935 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27936 + return;
27937 +#endif
27938 +
27939 vma = find_vma(mm, address);
27940 if (unlikely(!vma)) {
27941 bad_area(regs, error_code, address);
27942 @@ -1159,18 +1374,24 @@ retry:
27943 bad_area(regs, error_code, address);
27944 return;
27945 }
27946 - if (error_code & PF_USER) {
27947 - /*
27948 - * Accessing the stack below %sp is always a bug.
27949 - * The large cushion allows instructions like enter
27950 - * and pusha to work. ("enter $65535, $31" pushes
27951 - * 32 pointers and then decrements %sp by 65535.)
27952 - */
27953 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27954 - bad_area(regs, error_code, address);
27955 - return;
27956 - }
27957 + /*
27958 + * Accessing the stack below %sp is always a bug.
27959 + * The large cushion allows instructions like enter
27960 + * and pusha to work. ("enter $65535, $31" pushes
27961 + * 32 pointers and then decrements %sp by 65535.)
27962 + */
27963 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27964 + bad_area(regs, error_code, address);
27965 + return;
27966 }
27967 +
27968 +#ifdef CONFIG_PAX_SEGMEXEC
27969 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27970 + bad_area(regs, error_code, address);
27971 + return;
27972 + }
27973 +#endif
27974 +
27975 if (unlikely(expand_stack(vma, address))) {
27976 bad_area(regs, error_code, address);
27977 return;
27978 @@ -1234,3 +1455,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27979 __do_page_fault(regs, error_code);
27980 exception_exit(regs);
27981 }
27982 +
27983 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27984 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27985 +{
27986 + struct mm_struct *mm = current->mm;
27987 + unsigned long ip = regs->ip;
27988 +
27989 + if (v8086_mode(regs))
27990 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27991 +
27992 +#ifdef CONFIG_PAX_PAGEEXEC
27993 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27994 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27995 + return true;
27996 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27997 + return true;
27998 + return false;
27999 + }
28000 +#endif
28001 +
28002 +#ifdef CONFIG_PAX_SEGMEXEC
28003 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
28004 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
28005 + return true;
28006 + return false;
28007 + }
28008 +#endif
28009 +
28010 + return false;
28011 +}
28012 +#endif
28013 +
28014 +#ifdef CONFIG_PAX_EMUTRAMP
28015 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
28016 +{
28017 + int err;
28018 +
28019 + do { /* PaX: libffi trampoline emulation */
28020 + unsigned char mov, jmp;
28021 + unsigned int addr1, addr2;
28022 +
28023 +#ifdef CONFIG_X86_64
28024 + if ((regs->ip + 9) >> 32)
28025 + break;
28026 +#endif
28027 +
28028 + err = get_user(mov, (unsigned char __user *)regs->ip);
28029 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28030 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28031 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28032 +
28033 + if (err)
28034 + break;
28035 +
28036 + if (mov == 0xB8 && jmp == 0xE9) {
28037 + regs->ax = addr1;
28038 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28039 + return 2;
28040 + }
28041 + } while (0);
28042 +
28043 + do { /* PaX: gcc trampoline emulation #1 */
28044 + unsigned char mov1, mov2;
28045 + unsigned short jmp;
28046 + unsigned int addr1, addr2;
28047 +
28048 +#ifdef CONFIG_X86_64
28049 + if ((regs->ip + 11) >> 32)
28050 + break;
28051 +#endif
28052 +
28053 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28054 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28055 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28056 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28057 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28058 +
28059 + if (err)
28060 + break;
28061 +
28062 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28063 + regs->cx = addr1;
28064 + regs->ax = addr2;
28065 + regs->ip = addr2;
28066 + return 2;
28067 + }
28068 + } while (0);
28069 +
28070 + do { /* PaX: gcc trampoline emulation #2 */
28071 + unsigned char mov, jmp;
28072 + unsigned int addr1, addr2;
28073 +
28074 +#ifdef CONFIG_X86_64
28075 + if ((regs->ip + 9) >> 32)
28076 + break;
28077 +#endif
28078 +
28079 + err = get_user(mov, (unsigned char __user *)regs->ip);
28080 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28081 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28082 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28083 +
28084 + if (err)
28085 + break;
28086 +
28087 + if (mov == 0xB9 && jmp == 0xE9) {
28088 + regs->cx = addr1;
28089 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28090 + return 2;
28091 + }
28092 + } while (0);
28093 +
28094 + return 1; /* PaX in action */
28095 +}
28096 +
28097 +#ifdef CONFIG_X86_64
28098 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28099 +{
28100 + int err;
28101 +
28102 + do { /* PaX: libffi trampoline emulation */
28103 + unsigned short mov1, mov2, jmp1;
28104 + unsigned char stcclc, jmp2;
28105 + unsigned long addr1, addr2;
28106 +
28107 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28108 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28109 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28110 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28111 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28112 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28113 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28114 +
28115 + if (err)
28116 + break;
28117 +
28118 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28119 + regs->r11 = addr1;
28120 + regs->r10 = addr2;
28121 + if (stcclc == 0xF8)
28122 + regs->flags &= ~X86_EFLAGS_CF;
28123 + else
28124 + regs->flags |= X86_EFLAGS_CF;
28125 + regs->ip = addr1;
28126 + return 2;
28127 + }
28128 + } while (0);
28129 +
28130 + do { /* PaX: gcc trampoline emulation #1 */
28131 + unsigned short mov1, mov2, jmp1;
28132 + unsigned char jmp2;
28133 + unsigned int addr1;
28134 + unsigned long addr2;
28135 +
28136 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28137 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28138 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28139 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28140 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28141 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28142 +
28143 + if (err)
28144 + break;
28145 +
28146 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28147 + regs->r11 = addr1;
28148 + regs->r10 = addr2;
28149 + regs->ip = addr1;
28150 + return 2;
28151 + }
28152 + } while (0);
28153 +
28154 + do { /* PaX: gcc trampoline emulation #2 */
28155 + unsigned short mov1, mov2, jmp1;
28156 + unsigned char jmp2;
28157 + unsigned long addr1, addr2;
28158 +
28159 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28160 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28161 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28162 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28163 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28164 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28165 +
28166 + if (err)
28167 + break;
28168 +
28169 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28170 + regs->r11 = addr1;
28171 + regs->r10 = addr2;
28172 + regs->ip = addr1;
28173 + return 2;
28174 + }
28175 + } while (0);
28176 +
28177 + return 1; /* PaX in action */
28178 +}
28179 +#endif
28180 +
28181 +/*
28182 + * PaX: decide what to do with offenders (regs->ip = fault address)
28183 + *
28184 + * returns 1 when task should be killed
28185 + * 2 when gcc trampoline was detected
28186 + */
28187 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28188 +{
28189 + if (v8086_mode(regs))
28190 + return 1;
28191 +
28192 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28193 + return 1;
28194 +
28195 +#ifdef CONFIG_X86_32
28196 + return pax_handle_fetch_fault_32(regs);
28197 +#else
28198 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28199 + return pax_handle_fetch_fault_32(regs);
28200 + else
28201 + return pax_handle_fetch_fault_64(regs);
28202 +#endif
28203 +}
28204 +#endif
28205 +
28206 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28207 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28208 +{
28209 + long i;
28210 +
28211 + printk(KERN_ERR "PAX: bytes at PC: ");
28212 + for (i = 0; i < 20; i++) {
28213 + unsigned char c;
28214 + if (get_user(c, (unsigned char __force_user *)pc+i))
28215 + printk(KERN_CONT "?? ");
28216 + else
28217 + printk(KERN_CONT "%02x ", c);
28218 + }
28219 + printk("\n");
28220 +
28221 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28222 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28223 + unsigned long c;
28224 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28225 +#ifdef CONFIG_X86_32
28226 + printk(KERN_CONT "???????? ");
28227 +#else
28228 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28229 + printk(KERN_CONT "???????? ???????? ");
28230 + else
28231 + printk(KERN_CONT "???????????????? ");
28232 +#endif
28233 + } else {
28234 +#ifdef CONFIG_X86_64
28235 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28236 + printk(KERN_CONT "%08x ", (unsigned int)c);
28237 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28238 + } else
28239 +#endif
28240 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28241 + }
28242 + }
28243 + printk("\n");
28244 +}
28245 +#endif
28246 +
28247 +/**
28248 + * probe_kernel_write(): safely attempt to write to a location
28249 + * @dst: address to write to
28250 + * @src: pointer to the data that shall be written
28251 + * @size: size of the data chunk
28252 + *
28253 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28254 + * happens, handle that and return -EFAULT.
28255 + */
28256 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28257 +{
28258 + long ret;
28259 + mm_segment_t old_fs = get_fs();
28260 +
28261 + set_fs(KERNEL_DS);
28262 + pagefault_disable();
28263 + pax_open_kernel();
28264 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28265 + pax_close_kernel();
28266 + pagefault_enable();
28267 + set_fs(old_fs);
28268 +
28269 + return ret ? -EFAULT : 0;
28270 +}
28271 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28272 index dd74e46..7d26398 100644
28273 --- a/arch/x86/mm/gup.c
28274 +++ b/arch/x86/mm/gup.c
28275 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28276 addr = start;
28277 len = (unsigned long) nr_pages << PAGE_SHIFT;
28278 end = start + len;
28279 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28280 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28281 (void __user *)start, len)))
28282 return 0;
28283
28284 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28285 index 6f31ee5..8ee4164 100644
28286 --- a/arch/x86/mm/highmem_32.c
28287 +++ b/arch/x86/mm/highmem_32.c
28288 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28289 idx = type + KM_TYPE_NR*smp_processor_id();
28290 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28291 BUG_ON(!pte_none(*(kmap_pte-idx)));
28292 +
28293 + pax_open_kernel();
28294 set_pte(kmap_pte-idx, mk_pte(page, prot));
28295 + pax_close_kernel();
28296 +
28297 arch_flush_lazy_mmu_mode();
28298
28299 return (void *)vaddr;
28300 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28301 index ae1aa71..56316db 100644
28302 --- a/arch/x86/mm/hugetlbpage.c
28303 +++ b/arch/x86/mm/hugetlbpage.c
28304 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28305 info.flags = 0;
28306 info.length = len;
28307 info.low_limit = TASK_UNMAPPED_BASE;
28308 +
28309 +#ifdef CONFIG_PAX_RANDMMAP
28310 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28311 + info.low_limit += current->mm->delta_mmap;
28312 +#endif
28313 +
28314 info.high_limit = TASK_SIZE;
28315 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28316 info.align_offset = 0;
28317 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28318 VM_BUG_ON(addr != -ENOMEM);
28319 info.flags = 0;
28320 info.low_limit = TASK_UNMAPPED_BASE;
28321 +
28322 +#ifdef CONFIG_PAX_RANDMMAP
28323 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28324 + info.low_limit += current->mm->delta_mmap;
28325 +#endif
28326 +
28327 info.high_limit = TASK_SIZE;
28328 addr = vm_unmapped_area(&info);
28329 }
28330 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28331 struct hstate *h = hstate_file(file);
28332 struct mm_struct *mm = current->mm;
28333 struct vm_area_struct *vma;
28334 + unsigned long pax_task_size = TASK_SIZE;
28335 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28336
28337 if (len & ~huge_page_mask(h))
28338 return -EINVAL;
28339 - if (len > TASK_SIZE)
28340 +
28341 +#ifdef CONFIG_PAX_SEGMEXEC
28342 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28343 + pax_task_size = SEGMEXEC_TASK_SIZE;
28344 +#endif
28345 +
28346 + pax_task_size -= PAGE_SIZE;
28347 +
28348 + if (len > pax_task_size)
28349 return -ENOMEM;
28350
28351 if (flags & MAP_FIXED) {
28352 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28353 return addr;
28354 }
28355
28356 +#ifdef CONFIG_PAX_RANDMMAP
28357 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28358 +#endif
28359 +
28360 if (addr) {
28361 addr = ALIGN(addr, huge_page_size(h));
28362 vma = find_vma(mm, addr);
28363 - if (TASK_SIZE - len >= addr &&
28364 - (!vma || addr + len <= vma->vm_start))
28365 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28366 return addr;
28367 }
28368 if (mm->get_unmapped_area == arch_get_unmapped_area)
28369 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28370 index d7aea41..0fc945b 100644
28371 --- a/arch/x86/mm/init.c
28372 +++ b/arch/x86/mm/init.c
28373 @@ -4,6 +4,7 @@
28374 #include <linux/swap.h>
28375 #include <linux/memblock.h>
28376 #include <linux/bootmem.h> /* for max_low_pfn */
28377 +#include <linux/tboot.h>
28378
28379 #include <asm/cacheflush.h>
28380 #include <asm/e820.h>
28381 @@ -16,6 +17,8 @@
28382 #include <asm/tlb.h>
28383 #include <asm/proto.h>
28384 #include <asm/dma.h> /* for MAX_DMA_PFN */
28385 +#include <asm/desc.h>
28386 +#include <asm/bios_ebda.h>
28387
28388 unsigned long __initdata pgt_buf_start;
28389 unsigned long __meminitdata pgt_buf_end;
28390 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28391 {
28392 int i;
28393 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28394 - unsigned long start = 0, good_end;
28395 + unsigned long start = 0x100000, good_end;
28396 phys_addr_t base;
28397
28398 for (i = 0; i < nr_range; i++) {
28399 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28400 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28401 * mmio resources as well as potential bios/acpi data regions.
28402 */
28403 +
28404 +#ifdef CONFIG_GRKERNSEC_KMEM
28405 +static unsigned int ebda_start __read_only;
28406 +static unsigned int ebda_end __read_only;
28407 +#endif
28408 +
28409 int devmem_is_allowed(unsigned long pagenr)
28410 {
28411 - if (pagenr < 256)
28412 +#ifdef CONFIG_GRKERNSEC_KMEM
28413 + /* allow BDA */
28414 + if (!pagenr)
28415 return 1;
28416 + /* allow EBDA */
28417 + if (pagenr >= ebda_start && pagenr < ebda_end)
28418 + return 1;
28419 + /* if tboot is in use, allow access to its hardcoded serial log range */
28420 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28421 + return 1;
28422 +#else
28423 + if (!pagenr)
28424 + return 1;
28425 +#ifdef CONFIG_VM86
28426 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28427 + return 1;
28428 +#endif
28429 +#endif
28430 +
28431 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28432 + return 1;
28433 +#ifdef CONFIG_GRKERNSEC_KMEM
28434 + /* throw out everything else below 1MB */
28435 + if (pagenr <= 256)
28436 + return 0;
28437 +#endif
28438 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28439 return 0;
28440 if (!page_is_ram(pagenr))
28441 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28442 #endif
28443 }
28444
28445 +#ifdef CONFIG_GRKERNSEC_KMEM
28446 +static inline void gr_init_ebda(void)
28447 +{
28448 + unsigned int ebda_addr;
28449 + unsigned int ebda_size = 0;
28450 +
28451 + ebda_addr = get_bios_ebda();
28452 + if (ebda_addr) {
28453 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28454 + ebda_size <<= 10;
28455 + }
28456 + if (ebda_addr && ebda_size) {
28457 + ebda_start = ebda_addr >> PAGE_SHIFT;
28458 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28459 + } else {
28460 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28461 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28462 + }
28463 +}
28464 +#else
28465 +static inline void gr_init_ebda(void) { }
28466 +#endif
28467 +
28468 void free_initmem(void)
28469 {
28470 +#ifdef CONFIG_PAX_KERNEXEC
28471 +#ifdef CONFIG_X86_32
28472 + /* PaX: limit KERNEL_CS to actual size */
28473 + unsigned long addr, limit;
28474 + struct desc_struct d;
28475 + int cpu;
28476 +#else
28477 + pgd_t *pgd;
28478 + pud_t *pud;
28479 + pmd_t *pmd;
28480 + unsigned long addr, end;
28481 +#endif
28482 +#endif
28483 +
28484 + gr_init_ebda();
28485 +
28486 +#ifdef CONFIG_PAX_KERNEXEC
28487 +#ifdef CONFIG_X86_32
28488 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28489 + limit = (limit - 1UL) >> PAGE_SHIFT;
28490 +
28491 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28492 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28493 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28494 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28495 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28496 + }
28497 +
28498 + /* PaX: make KERNEL_CS read-only */
28499 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28500 + if (!paravirt_enabled())
28501 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28502 +/*
28503 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28504 + pgd = pgd_offset_k(addr);
28505 + pud = pud_offset(pgd, addr);
28506 + pmd = pmd_offset(pud, addr);
28507 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28508 + }
28509 +*/
28510 +#ifdef CONFIG_X86_PAE
28511 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28512 +/*
28513 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28514 + pgd = pgd_offset_k(addr);
28515 + pud = pud_offset(pgd, addr);
28516 + pmd = pmd_offset(pud, addr);
28517 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28518 + }
28519 +*/
28520 +#endif
28521 +
28522 +#ifdef CONFIG_MODULES
28523 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28524 +#endif
28525 +
28526 +#else
28527 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28528 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28529 + pgd = pgd_offset_k(addr);
28530 + pud = pud_offset(pgd, addr);
28531 + pmd = pmd_offset(pud, addr);
28532 + if (!pmd_present(*pmd))
28533 + continue;
28534 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28535 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28536 + else
28537 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28538 + }
28539 +
28540 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28541 + end = addr + KERNEL_IMAGE_SIZE;
28542 + for (; addr < end; addr += PMD_SIZE) {
28543 + pgd = pgd_offset_k(addr);
28544 + pud = pud_offset(pgd, addr);
28545 + pmd = pmd_offset(pud, addr);
28546 + if (!pmd_present(*pmd))
28547 + continue;
28548 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28549 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28550 + }
28551 +#endif
28552 +
28553 + flush_tlb_all();
28554 +#endif
28555 +
28556 free_init_pages("unused kernel memory",
28557 (unsigned long)(&__init_begin),
28558 (unsigned long)(&__init_end));
28559 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28560 index 745d66b..56bf568 100644
28561 --- a/arch/x86/mm/init_32.c
28562 +++ b/arch/x86/mm/init_32.c
28563 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28564 }
28565
28566 /*
28567 - * Creates a middle page table and puts a pointer to it in the
28568 - * given global directory entry. This only returns the gd entry
28569 - * in non-PAE compilation mode, since the middle layer is folded.
28570 - */
28571 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28572 -{
28573 - pud_t *pud;
28574 - pmd_t *pmd_table;
28575 -
28576 -#ifdef CONFIG_X86_PAE
28577 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28578 - if (after_bootmem)
28579 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28580 - else
28581 - pmd_table = (pmd_t *)alloc_low_page();
28582 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28583 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28584 - pud = pud_offset(pgd, 0);
28585 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28586 -
28587 - return pmd_table;
28588 - }
28589 -#endif
28590 - pud = pud_offset(pgd, 0);
28591 - pmd_table = pmd_offset(pud, 0);
28592 -
28593 - return pmd_table;
28594 -}
28595 -
28596 -/*
28597 * Create a page table and place a pointer to it in a middle page
28598 * directory entry:
28599 */
28600 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28601 page_table = (pte_t *)alloc_low_page();
28602
28603 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28604 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28605 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28606 +#else
28607 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28608 +#endif
28609 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28610 }
28611
28612 return pte_offset_kernel(pmd, 0);
28613 }
28614
28615 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28616 +{
28617 + pud_t *pud;
28618 + pmd_t *pmd_table;
28619 +
28620 + pud = pud_offset(pgd, 0);
28621 + pmd_table = pmd_offset(pud, 0);
28622 +
28623 + return pmd_table;
28624 +}
28625 +
28626 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28627 {
28628 int pgd_idx = pgd_index(vaddr);
28629 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28630 int pgd_idx, pmd_idx;
28631 unsigned long vaddr;
28632 pgd_t *pgd;
28633 + pud_t *pud;
28634 pmd_t *pmd;
28635 pte_t *pte = NULL;
28636
28637 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28638 pgd = pgd_base + pgd_idx;
28639
28640 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28641 - pmd = one_md_table_init(pgd);
28642 - pmd = pmd + pmd_index(vaddr);
28643 + pud = pud_offset(pgd, vaddr);
28644 + pmd = pmd_offset(pud, vaddr);
28645 +
28646 +#ifdef CONFIG_X86_PAE
28647 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28648 +#endif
28649 +
28650 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28651 pmd++, pmd_idx++) {
28652 pte = page_table_kmap_check(one_page_table_init(pmd),
28653 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28654 }
28655 }
28656
28657 -static inline int is_kernel_text(unsigned long addr)
28658 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28659 {
28660 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28661 - return 1;
28662 - return 0;
28663 + if ((start > ktla_ktva((unsigned long)_etext) ||
28664 + end <= ktla_ktva((unsigned long)_stext)) &&
28665 + (start > ktla_ktva((unsigned long)_einittext) ||
28666 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28667 +
28668 +#ifdef CONFIG_ACPI_SLEEP
28669 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28670 +#endif
28671 +
28672 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28673 + return 0;
28674 + return 1;
28675 }
28676
28677 /*
28678 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28679 unsigned long last_map_addr = end;
28680 unsigned long start_pfn, end_pfn;
28681 pgd_t *pgd_base = swapper_pg_dir;
28682 - int pgd_idx, pmd_idx, pte_ofs;
28683 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28684 unsigned long pfn;
28685 pgd_t *pgd;
28686 + pud_t *pud;
28687 pmd_t *pmd;
28688 pte_t *pte;
28689 unsigned pages_2m, pages_4k;
28690 @@ -280,8 +281,13 @@ repeat:
28691 pfn = start_pfn;
28692 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28693 pgd = pgd_base + pgd_idx;
28694 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28695 - pmd = one_md_table_init(pgd);
28696 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28697 + pud = pud_offset(pgd, 0);
28698 + pmd = pmd_offset(pud, 0);
28699 +
28700 +#ifdef CONFIG_X86_PAE
28701 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28702 +#endif
28703
28704 if (pfn >= end_pfn)
28705 continue;
28706 @@ -293,14 +299,13 @@ repeat:
28707 #endif
28708 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28709 pmd++, pmd_idx++) {
28710 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28711 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28712
28713 /*
28714 * Map with big pages if possible, otherwise
28715 * create normal page tables:
28716 */
28717 if (use_pse) {
28718 - unsigned int addr2;
28719 pgprot_t prot = PAGE_KERNEL_LARGE;
28720 /*
28721 * first pass will use the same initial
28722 @@ -310,11 +315,7 @@ repeat:
28723 __pgprot(PTE_IDENT_ATTR |
28724 _PAGE_PSE);
28725
28726 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28727 - PAGE_OFFSET + PAGE_SIZE-1;
28728 -
28729 - if (is_kernel_text(addr) ||
28730 - is_kernel_text(addr2))
28731 + if (is_kernel_text(address, address + PMD_SIZE))
28732 prot = PAGE_KERNEL_LARGE_EXEC;
28733
28734 pages_2m++;
28735 @@ -331,7 +332,7 @@ repeat:
28736 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28737 pte += pte_ofs;
28738 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28739 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28740 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28741 pgprot_t prot = PAGE_KERNEL;
28742 /*
28743 * first pass will use the same initial
28744 @@ -339,7 +340,7 @@ repeat:
28745 */
28746 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28747
28748 - if (is_kernel_text(addr))
28749 + if (is_kernel_text(address, address + PAGE_SIZE))
28750 prot = PAGE_KERNEL_EXEC;
28751
28752 pages_4k++;
28753 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28754
28755 pud = pud_offset(pgd, va);
28756 pmd = pmd_offset(pud, va);
28757 - if (!pmd_present(*pmd))
28758 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28759 break;
28760
28761 pte = pte_offset_kernel(pmd, va);
28762 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28763
28764 static void __init pagetable_init(void)
28765 {
28766 - pgd_t *pgd_base = swapper_pg_dir;
28767 -
28768 - permanent_kmaps_init(pgd_base);
28769 + permanent_kmaps_init(swapper_pg_dir);
28770 }
28771
28772 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28773 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28774 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28775
28776 /* user-defined highmem size */
28777 @@ -728,6 +727,12 @@ void __init mem_init(void)
28778
28779 pci_iommu_alloc();
28780
28781 +#ifdef CONFIG_PAX_PER_CPU_PGD
28782 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28783 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28784 + KERNEL_PGD_PTRS);
28785 +#endif
28786 +
28787 #ifdef CONFIG_FLATMEM
28788 BUG_ON(!mem_map);
28789 #endif
28790 @@ -754,7 +759,7 @@ void __init mem_init(void)
28791 reservedpages++;
28792
28793 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28794 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28795 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28796 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28797
28798 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28799 @@ -795,10 +800,10 @@ void __init mem_init(void)
28800 ((unsigned long)&__init_end -
28801 (unsigned long)&__init_begin) >> 10,
28802
28803 - (unsigned long)&_etext, (unsigned long)&_edata,
28804 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28805 + (unsigned long)&_sdata, (unsigned long)&_edata,
28806 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28807
28808 - (unsigned long)&_text, (unsigned long)&_etext,
28809 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28810 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28811
28812 /*
28813 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28814 if (!kernel_set_to_readonly)
28815 return;
28816
28817 + start = ktla_ktva(start);
28818 pr_debug("Set kernel text: %lx - %lx for read write\n",
28819 start, start+size);
28820
28821 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28822 if (!kernel_set_to_readonly)
28823 return;
28824
28825 + start = ktla_ktva(start);
28826 pr_debug("Set kernel text: %lx - %lx for read only\n",
28827 start, start+size);
28828
28829 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28830 unsigned long start = PFN_ALIGN(_text);
28831 unsigned long size = PFN_ALIGN(_etext) - start;
28832
28833 + start = ktla_ktva(start);
28834 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28835 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28836 size >> 10);
28837 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28838 index 75c9a6a..498d677 100644
28839 --- a/arch/x86/mm/init_64.c
28840 +++ b/arch/x86/mm/init_64.c
28841 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28842 * around without checking the pgd every time.
28843 */
28844
28845 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28846 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28847 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28848
28849 int force_personality32;
28850 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28851
28852 for (address = start; address <= end; address += PGDIR_SIZE) {
28853 const pgd_t *pgd_ref = pgd_offset_k(address);
28854 +
28855 +#ifdef CONFIG_PAX_PER_CPU_PGD
28856 + unsigned long cpu;
28857 +#else
28858 struct page *page;
28859 +#endif
28860
28861 if (pgd_none(*pgd_ref))
28862 continue;
28863
28864 spin_lock(&pgd_lock);
28865 +
28866 +#ifdef CONFIG_PAX_PER_CPU_PGD
28867 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28868 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28869 +#else
28870 list_for_each_entry(page, &pgd_list, lru) {
28871 pgd_t *pgd;
28872 spinlock_t *pgt_lock;
28873 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28874 /* the pgt_lock only for Xen */
28875 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28876 spin_lock(pgt_lock);
28877 +#endif
28878
28879 if (pgd_none(*pgd))
28880 set_pgd(pgd, *pgd_ref);
28881 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28882 BUG_ON(pgd_page_vaddr(*pgd)
28883 != pgd_page_vaddr(*pgd_ref));
28884
28885 +#ifndef CONFIG_PAX_PER_CPU_PGD
28886 spin_unlock(pgt_lock);
28887 +#endif
28888 +
28889 }
28890 spin_unlock(&pgd_lock);
28891 }
28892 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28893 {
28894 if (pgd_none(*pgd)) {
28895 pud_t *pud = (pud_t *)spp_getpage();
28896 - pgd_populate(&init_mm, pgd, pud);
28897 + pgd_populate_kernel(&init_mm, pgd, pud);
28898 if (pud != pud_offset(pgd, 0))
28899 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28900 pud, pud_offset(pgd, 0));
28901 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28902 {
28903 if (pud_none(*pud)) {
28904 pmd_t *pmd = (pmd_t *) spp_getpage();
28905 - pud_populate(&init_mm, pud, pmd);
28906 + pud_populate_kernel(&init_mm, pud, pmd);
28907 if (pmd != pmd_offset(pud, 0))
28908 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28909 pmd, pmd_offset(pud, 0));
28910 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28911 pmd = fill_pmd(pud, vaddr);
28912 pte = fill_pte(pmd, vaddr);
28913
28914 + pax_open_kernel();
28915 set_pte(pte, new_pte);
28916 + pax_close_kernel();
28917
28918 /*
28919 * It's enough to flush this one mapping.
28920 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28921 pgd = pgd_offset_k((unsigned long)__va(phys));
28922 if (pgd_none(*pgd)) {
28923 pud = (pud_t *) spp_getpage();
28924 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28925 - _PAGE_USER));
28926 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28927 }
28928 pud = pud_offset(pgd, (unsigned long)__va(phys));
28929 if (pud_none(*pud)) {
28930 pmd = (pmd_t *) spp_getpage();
28931 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28932 - _PAGE_USER));
28933 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28934 }
28935 pmd = pmd_offset(pud, phys);
28936 BUG_ON(!pmd_none(*pmd));
28937 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28938 if (pfn >= pgt_buf_top)
28939 panic("alloc_low_page: ran out of memory");
28940
28941 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28942 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28943 clear_page(adr);
28944 *phys = pfn * PAGE_SIZE;
28945 return adr;
28946 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28947
28948 phys = __pa(virt);
28949 left = phys & (PAGE_SIZE - 1);
28950 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28951 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28952 adr = (void *)(((unsigned long)adr) | left);
28953
28954 return adr;
28955 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28956 unmap_low_page(pmd);
28957
28958 spin_lock(&init_mm.page_table_lock);
28959 - pud_populate(&init_mm, pud, __va(pmd_phys));
28960 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28961 spin_unlock(&init_mm.page_table_lock);
28962 }
28963 __flush_tlb_all();
28964 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28965 unmap_low_page(pud);
28966
28967 spin_lock(&init_mm.page_table_lock);
28968 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28969 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28970 spin_unlock(&init_mm.page_table_lock);
28971 pgd_changed = true;
28972 }
28973 @@ -693,6 +707,12 @@ void __init mem_init(void)
28974
28975 pci_iommu_alloc();
28976
28977 +#ifdef CONFIG_PAX_PER_CPU_PGD
28978 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28979 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28980 + KERNEL_PGD_PTRS);
28981 +#endif
28982 +
28983 /* clear_bss() already clear the empty_zero_page */
28984
28985 reservedpages = 0;
28986 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28987 static struct vm_area_struct gate_vma = {
28988 .vm_start = VSYSCALL_START,
28989 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28990 - .vm_page_prot = PAGE_READONLY_EXEC,
28991 - .vm_flags = VM_READ | VM_EXEC
28992 + .vm_page_prot = PAGE_READONLY,
28993 + .vm_flags = VM_READ
28994 };
28995
28996 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28997 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28998
28999 const char *arch_vma_name(struct vm_area_struct *vma)
29000 {
29001 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
29002 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
29003 return "[vdso]";
29004 if (vma == &gate_vma)
29005 return "[vsyscall]";
29006 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
29007 index 7b179b4..6bd17777 100644
29008 --- a/arch/x86/mm/iomap_32.c
29009 +++ b/arch/x86/mm/iomap_32.c
29010 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
29011 type = kmap_atomic_idx_push();
29012 idx = type + KM_TYPE_NR * smp_processor_id();
29013 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29014 +
29015 + pax_open_kernel();
29016 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
29017 + pax_close_kernel();
29018 +
29019 arch_flush_lazy_mmu_mode();
29020
29021 return (void *)vaddr;
29022 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
29023 index 78fe3f1..73b95e2 100644
29024 --- a/arch/x86/mm/ioremap.c
29025 +++ b/arch/x86/mm/ioremap.c
29026 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
29027 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
29028 int is_ram = page_is_ram(pfn);
29029
29030 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
29031 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
29032 return NULL;
29033 WARN_ON_ONCE(is_ram);
29034 }
29035 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
29036 *
29037 * Caller must ensure there is only one unmapping for the same pointer.
29038 */
29039 -void iounmap(volatile void __iomem *addr)
29040 +void iounmap(const volatile void __iomem *addr)
29041 {
29042 struct vm_struct *p, *o;
29043
29044 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29045
29046 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29047 if (page_is_ram(start >> PAGE_SHIFT))
29048 +#ifdef CONFIG_HIGHMEM
29049 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29050 +#endif
29051 return __va(phys);
29052
29053 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29054 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29055 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29056 {
29057 if (page_is_ram(phys >> PAGE_SHIFT))
29058 +#ifdef CONFIG_HIGHMEM
29059 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29060 +#endif
29061 return;
29062
29063 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29064 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29065 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29066
29067 static __initdata int after_paging_init;
29068 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29069 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29070
29071 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29072 {
29073 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29074 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29075
29076 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29077 - memset(bm_pte, 0, sizeof(bm_pte));
29078 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29079 + pmd_populate_user(&init_mm, pmd, bm_pte);
29080
29081 /*
29082 * The boot-ioremap range spans multiple pmds, for which
29083 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29084 index d87dd6d..bf3fa66 100644
29085 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29086 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29087 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29088 * memory (e.g. tracked pages)? For now, we need this to avoid
29089 * invoking kmemcheck for PnP BIOS calls.
29090 */
29091 - if (regs->flags & X86_VM_MASK)
29092 + if (v8086_mode(regs))
29093 return false;
29094 - if (regs->cs != __KERNEL_CS)
29095 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29096 return false;
29097
29098 pte = kmemcheck_pte_lookup(address);
29099 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29100 index 845df68..1d8d29f 100644
29101 --- a/arch/x86/mm/mmap.c
29102 +++ b/arch/x86/mm/mmap.c
29103 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29104 * Leave an at least ~128 MB hole with possible stack randomization.
29105 */
29106 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29107 -#define MAX_GAP (TASK_SIZE/6*5)
29108 +#define MAX_GAP (pax_task_size/6*5)
29109
29110 static int mmap_is_legacy(void)
29111 {
29112 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29113 return rnd << PAGE_SHIFT;
29114 }
29115
29116 -static unsigned long mmap_base(void)
29117 +static unsigned long mmap_base(struct mm_struct *mm)
29118 {
29119 unsigned long gap = rlimit(RLIMIT_STACK);
29120 + unsigned long pax_task_size = TASK_SIZE;
29121 +
29122 +#ifdef CONFIG_PAX_SEGMEXEC
29123 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29124 + pax_task_size = SEGMEXEC_TASK_SIZE;
29125 +#endif
29126
29127 if (gap < MIN_GAP)
29128 gap = MIN_GAP;
29129 else if (gap > MAX_GAP)
29130 gap = MAX_GAP;
29131
29132 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29133 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29134 }
29135
29136 /*
29137 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29138 * does, but not when emulating X86_32
29139 */
29140 -static unsigned long mmap_legacy_base(void)
29141 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29142 {
29143 - if (mmap_is_ia32())
29144 + if (mmap_is_ia32()) {
29145 +
29146 +#ifdef CONFIG_PAX_SEGMEXEC
29147 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29148 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29149 + else
29150 +#endif
29151 +
29152 return TASK_UNMAPPED_BASE;
29153 - else
29154 + } else
29155 return TASK_UNMAPPED_BASE + mmap_rnd();
29156 }
29157
29158 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29159 void arch_pick_mmap_layout(struct mm_struct *mm)
29160 {
29161 if (mmap_is_legacy()) {
29162 - mm->mmap_base = mmap_legacy_base();
29163 + mm->mmap_base = mmap_legacy_base(mm);
29164 +
29165 +#ifdef CONFIG_PAX_RANDMMAP
29166 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29167 + mm->mmap_base += mm->delta_mmap;
29168 +#endif
29169 +
29170 mm->get_unmapped_area = arch_get_unmapped_area;
29171 mm->unmap_area = arch_unmap_area;
29172 } else {
29173 - mm->mmap_base = mmap_base();
29174 + mm->mmap_base = mmap_base(mm);
29175 +
29176 +#ifdef CONFIG_PAX_RANDMMAP
29177 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29178 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29179 +#endif
29180 +
29181 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29182 mm->unmap_area = arch_unmap_area_topdown;
29183 }
29184 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29185 index dc0b727..f612039 100644
29186 --- a/arch/x86/mm/mmio-mod.c
29187 +++ b/arch/x86/mm/mmio-mod.c
29188 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29189 break;
29190 default:
29191 {
29192 - unsigned char *ip = (unsigned char *)instptr;
29193 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29194 my_trace->opcode = MMIO_UNKNOWN_OP;
29195 my_trace->width = 0;
29196 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29197 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29198 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29199 void __iomem *addr)
29200 {
29201 - static atomic_t next_id;
29202 + static atomic_unchecked_t next_id;
29203 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29204 /* These are page-unaligned. */
29205 struct mmiotrace_map map = {
29206 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29207 .private = trace
29208 },
29209 .phys = offset,
29210 - .id = atomic_inc_return(&next_id)
29211 + .id = atomic_inc_return_unchecked(&next_id)
29212 };
29213 map.map_id = trace->id;
29214
29215 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29216 ioremap_trace_core(offset, size, addr);
29217 }
29218
29219 -static void iounmap_trace_core(volatile void __iomem *addr)
29220 +static void iounmap_trace_core(const volatile void __iomem *addr)
29221 {
29222 struct mmiotrace_map map = {
29223 .phys = 0,
29224 @@ -328,7 +328,7 @@ not_enabled:
29225 }
29226 }
29227
29228 -void mmiotrace_iounmap(volatile void __iomem *addr)
29229 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29230 {
29231 might_sleep();
29232 if (is_enabled()) /* recheck and proper locking in *_core() */
29233 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29234 index 8504f36..5fc68f2 100644
29235 --- a/arch/x86/mm/numa.c
29236 +++ b/arch/x86/mm/numa.c
29237 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29238 return true;
29239 }
29240
29241 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29242 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29243 {
29244 unsigned long uninitialized_var(pfn_align);
29245 int i, nid;
29246 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29247 index b008656..773eac2 100644
29248 --- a/arch/x86/mm/pageattr-test.c
29249 +++ b/arch/x86/mm/pageattr-test.c
29250 @@ -36,7 +36,7 @@ enum {
29251
29252 static int pte_testbit(pte_t pte)
29253 {
29254 - return pte_flags(pte) & _PAGE_UNUSED1;
29255 + return pte_flags(pte) & _PAGE_CPA_TEST;
29256 }
29257
29258 struct split_state {
29259 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29260 index a718e0d..77419bc 100644
29261 --- a/arch/x86/mm/pageattr.c
29262 +++ b/arch/x86/mm/pageattr.c
29263 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29264 */
29265 #ifdef CONFIG_PCI_BIOS
29266 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29267 - pgprot_val(forbidden) |= _PAGE_NX;
29268 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29269 #endif
29270
29271 /*
29272 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29273 * Does not cover __inittext since that is gone later on. On
29274 * 64bit we do not enforce !NX on the low mapping
29275 */
29276 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29277 - pgprot_val(forbidden) |= _PAGE_NX;
29278 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29279 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29280
29281 +#ifdef CONFIG_DEBUG_RODATA
29282 /*
29283 * The .rodata section needs to be read-only. Using the pfn
29284 * catches all aliases.
29285 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29286 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29287 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29288 pgprot_val(forbidden) |= _PAGE_RW;
29289 +#endif
29290
29291 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29292 /*
29293 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29294 }
29295 #endif
29296
29297 +#ifdef CONFIG_PAX_KERNEXEC
29298 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29299 + pgprot_val(forbidden) |= _PAGE_RW;
29300 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29301 + }
29302 +#endif
29303 +
29304 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29305
29306 return prot;
29307 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29308 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29309 {
29310 /* change init_mm */
29311 + pax_open_kernel();
29312 set_pte_atomic(kpte, pte);
29313 +
29314 #ifdef CONFIG_X86_32
29315 if (!SHARED_KERNEL_PMD) {
29316 +
29317 +#ifdef CONFIG_PAX_PER_CPU_PGD
29318 + unsigned long cpu;
29319 +#else
29320 struct page *page;
29321 +#endif
29322
29323 +#ifdef CONFIG_PAX_PER_CPU_PGD
29324 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29325 + pgd_t *pgd = get_cpu_pgd(cpu);
29326 +#else
29327 list_for_each_entry(page, &pgd_list, lru) {
29328 - pgd_t *pgd;
29329 + pgd_t *pgd = (pgd_t *)page_address(page);
29330 +#endif
29331 +
29332 pud_t *pud;
29333 pmd_t *pmd;
29334
29335 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29336 + pgd += pgd_index(address);
29337 pud = pud_offset(pgd, address);
29338 pmd = pmd_offset(pud, address);
29339 set_pte_atomic((pte_t *)pmd, pte);
29340 }
29341 }
29342 #endif
29343 + pax_close_kernel();
29344 }
29345
29346 static int
29347 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29348 index 0eb572e..92f5c1e 100644
29349 --- a/arch/x86/mm/pat.c
29350 +++ b/arch/x86/mm/pat.c
29351 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29352
29353 if (!entry) {
29354 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29355 - current->comm, current->pid, start, end - 1);
29356 + current->comm, task_pid_nr(current), start, end - 1);
29357 return -EINVAL;
29358 }
29359
29360 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29361
29362 while (cursor < to) {
29363 if (!devmem_is_allowed(pfn)) {
29364 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29365 - current->comm, from, to - 1);
29366 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29367 + current->comm, from, to - 1, cursor);
29368 return 0;
29369 }
29370 cursor += PAGE_SIZE;
29371 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29372 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29373 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29374 "for [mem %#010Lx-%#010Lx]\n",
29375 - current->comm, current->pid,
29376 + current->comm, task_pid_nr(current),
29377 cattr_name(flags),
29378 base, (unsigned long long)(base + size-1));
29379 return -EINVAL;
29380 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29381 flags = lookup_memtype(paddr);
29382 if (want_flags != flags) {
29383 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29384 - current->comm, current->pid,
29385 + current->comm, task_pid_nr(current),
29386 cattr_name(want_flags),
29387 (unsigned long long)paddr,
29388 (unsigned long long)(paddr + size - 1),
29389 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29390 free_memtype(paddr, paddr + size);
29391 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29392 " for [mem %#010Lx-%#010Lx], got %s\n",
29393 - current->comm, current->pid,
29394 + current->comm, task_pid_nr(current),
29395 cattr_name(want_flags),
29396 (unsigned long long)paddr,
29397 (unsigned long long)(paddr + size - 1),
29398 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29399 index 9f0614d..92ae64a 100644
29400 --- a/arch/x86/mm/pf_in.c
29401 +++ b/arch/x86/mm/pf_in.c
29402 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29403 int i;
29404 enum reason_type rv = OTHERS;
29405
29406 - p = (unsigned char *)ins_addr;
29407 + p = (unsigned char *)ktla_ktva(ins_addr);
29408 p += skip_prefix(p, &prf);
29409 p += get_opcode(p, &opcode);
29410
29411 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29412 struct prefix_bits prf;
29413 int i;
29414
29415 - p = (unsigned char *)ins_addr;
29416 + p = (unsigned char *)ktla_ktva(ins_addr);
29417 p += skip_prefix(p, &prf);
29418 p += get_opcode(p, &opcode);
29419
29420 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29421 struct prefix_bits prf;
29422 int i;
29423
29424 - p = (unsigned char *)ins_addr;
29425 + p = (unsigned char *)ktla_ktva(ins_addr);
29426 p += skip_prefix(p, &prf);
29427 p += get_opcode(p, &opcode);
29428
29429 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29430 struct prefix_bits prf;
29431 int i;
29432
29433 - p = (unsigned char *)ins_addr;
29434 + p = (unsigned char *)ktla_ktva(ins_addr);
29435 p += skip_prefix(p, &prf);
29436 p += get_opcode(p, &opcode);
29437 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29438 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29439 struct prefix_bits prf;
29440 int i;
29441
29442 - p = (unsigned char *)ins_addr;
29443 + p = (unsigned char *)ktla_ktva(ins_addr);
29444 p += skip_prefix(p, &prf);
29445 p += get_opcode(p, &opcode);
29446 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29447 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29448 index 395b3b4a..213e72b 100644
29449 --- a/arch/x86/mm/pgtable.c
29450 +++ b/arch/x86/mm/pgtable.c
29451 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29452 list_del(&page->lru);
29453 }
29454
29455 -#define UNSHARED_PTRS_PER_PGD \
29456 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29457 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29458 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29459
29460 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29461 +{
29462 + unsigned int count = USER_PGD_PTRS;
29463
29464 + while (count--)
29465 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29466 +}
29467 +#endif
29468 +
29469 +#ifdef CONFIG_PAX_PER_CPU_PGD
29470 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29471 +{
29472 + unsigned int count = USER_PGD_PTRS;
29473 +
29474 + while (count--) {
29475 + pgd_t pgd;
29476 +
29477 +#ifdef CONFIG_X86_64
29478 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29479 +#else
29480 + pgd = *src++;
29481 +#endif
29482 +
29483 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29484 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29485 +#endif
29486 +
29487 + *dst++ = pgd;
29488 + }
29489 +
29490 +}
29491 +#endif
29492 +
29493 +#ifdef CONFIG_X86_64
29494 +#define pxd_t pud_t
29495 +#define pyd_t pgd_t
29496 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29497 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29498 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29499 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29500 +#define PYD_SIZE PGDIR_SIZE
29501 +#else
29502 +#define pxd_t pmd_t
29503 +#define pyd_t pud_t
29504 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29505 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29506 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29507 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29508 +#define PYD_SIZE PUD_SIZE
29509 +#endif
29510 +
29511 +#ifdef CONFIG_PAX_PER_CPU_PGD
29512 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29513 +static inline void pgd_dtor(pgd_t *pgd) {}
29514 +#else
29515 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29516 {
29517 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29518 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29519 pgd_list_del(pgd);
29520 spin_unlock(&pgd_lock);
29521 }
29522 +#endif
29523
29524 /*
29525 * List of all pgd's needed for non-PAE so it can invalidate entries
29526 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29527 * -- nyc
29528 */
29529
29530 -#ifdef CONFIG_X86_PAE
29531 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29532 /*
29533 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29534 * updating the top-level pagetable entries to guarantee the
29535 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29536 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29537 * and initialize the kernel pmds here.
29538 */
29539 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29540 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29541
29542 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29543 {
29544 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29545 */
29546 flush_tlb_mm(mm);
29547 }
29548 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29549 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29550 #else /* !CONFIG_X86_PAE */
29551
29552 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29553 -#define PREALLOCATED_PMDS 0
29554 +#define PREALLOCATED_PXDS 0
29555
29556 #endif /* CONFIG_X86_PAE */
29557
29558 -static void free_pmds(pmd_t *pmds[])
29559 +static void free_pxds(pxd_t *pxds[])
29560 {
29561 int i;
29562
29563 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29564 - if (pmds[i])
29565 - free_page((unsigned long)pmds[i]);
29566 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29567 + if (pxds[i])
29568 + free_page((unsigned long)pxds[i]);
29569 }
29570
29571 -static int preallocate_pmds(pmd_t *pmds[])
29572 +static int preallocate_pxds(pxd_t *pxds[])
29573 {
29574 int i;
29575 bool failed = false;
29576
29577 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29578 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29579 - if (pmd == NULL)
29580 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29581 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29582 + if (pxd == NULL)
29583 failed = true;
29584 - pmds[i] = pmd;
29585 + pxds[i] = pxd;
29586 }
29587
29588 if (failed) {
29589 - free_pmds(pmds);
29590 + free_pxds(pxds);
29591 return -ENOMEM;
29592 }
29593
29594 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29595 * preallocate which never got a corresponding vma will need to be
29596 * freed manually.
29597 */
29598 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29599 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29600 {
29601 int i;
29602
29603 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29604 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29605 pgd_t pgd = pgdp[i];
29606
29607 if (pgd_val(pgd) != 0) {
29608 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29609 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29610
29611 - pgdp[i] = native_make_pgd(0);
29612 + set_pgd(pgdp + i, native_make_pgd(0));
29613
29614 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29615 - pmd_free(mm, pmd);
29616 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29617 + pxd_free(mm, pxd);
29618 }
29619 }
29620 }
29621
29622 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29623 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29624 {
29625 - pud_t *pud;
29626 + pyd_t *pyd;
29627 unsigned long addr;
29628 int i;
29629
29630 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29631 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29632 return;
29633
29634 - pud = pud_offset(pgd, 0);
29635 +#ifdef CONFIG_X86_64
29636 + pyd = pyd_offset(mm, 0L);
29637 +#else
29638 + pyd = pyd_offset(pgd, 0L);
29639 +#endif
29640
29641 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29642 - i++, pud++, addr += PUD_SIZE) {
29643 - pmd_t *pmd = pmds[i];
29644 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29645 + i++, pyd++, addr += PYD_SIZE) {
29646 + pxd_t *pxd = pxds[i];
29647
29648 if (i >= KERNEL_PGD_BOUNDARY)
29649 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29650 - sizeof(pmd_t) * PTRS_PER_PMD);
29651 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29652 + sizeof(pxd_t) * PTRS_PER_PMD);
29653
29654 - pud_populate(mm, pud, pmd);
29655 + pyd_populate(mm, pyd, pxd);
29656 }
29657 }
29658
29659 pgd_t *pgd_alloc(struct mm_struct *mm)
29660 {
29661 pgd_t *pgd;
29662 - pmd_t *pmds[PREALLOCATED_PMDS];
29663 + pxd_t *pxds[PREALLOCATED_PXDS];
29664
29665 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29666
29667 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29668
29669 mm->pgd = pgd;
29670
29671 - if (preallocate_pmds(pmds) != 0)
29672 + if (preallocate_pxds(pxds) != 0)
29673 goto out_free_pgd;
29674
29675 if (paravirt_pgd_alloc(mm) != 0)
29676 - goto out_free_pmds;
29677 + goto out_free_pxds;
29678
29679 /*
29680 * Make sure that pre-populating the pmds is atomic with
29681 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29682 spin_lock(&pgd_lock);
29683
29684 pgd_ctor(mm, pgd);
29685 - pgd_prepopulate_pmd(mm, pgd, pmds);
29686 + pgd_prepopulate_pxd(mm, pgd, pxds);
29687
29688 spin_unlock(&pgd_lock);
29689
29690 return pgd;
29691
29692 -out_free_pmds:
29693 - free_pmds(pmds);
29694 +out_free_pxds:
29695 + free_pxds(pxds);
29696 out_free_pgd:
29697 free_page((unsigned long)pgd);
29698 out:
29699 @@ -302,7 +363,7 @@ out:
29700
29701 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29702 {
29703 - pgd_mop_up_pmds(mm, pgd);
29704 + pgd_mop_up_pxds(mm, pgd);
29705 pgd_dtor(pgd);
29706 paravirt_pgd_free(mm, pgd);
29707 free_page((unsigned long)pgd);
29708 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29709 index a69bcb8..19068ab 100644
29710 --- a/arch/x86/mm/pgtable_32.c
29711 +++ b/arch/x86/mm/pgtable_32.c
29712 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29713 return;
29714 }
29715 pte = pte_offset_kernel(pmd, vaddr);
29716 +
29717 + pax_open_kernel();
29718 if (pte_val(pteval))
29719 set_pte_at(&init_mm, vaddr, pte, pteval);
29720 else
29721 pte_clear(&init_mm, vaddr, pte);
29722 + pax_close_kernel();
29723
29724 /*
29725 * It's enough to flush this one mapping.
29726 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29727 index d2e2735..5c6586f 100644
29728 --- a/arch/x86/mm/physaddr.c
29729 +++ b/arch/x86/mm/physaddr.c
29730 @@ -8,7 +8,7 @@
29731
29732 #ifdef CONFIG_X86_64
29733
29734 -unsigned long __phys_addr(unsigned long x)
29735 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29736 {
29737 if (x >= __START_KERNEL_map) {
29738 x -= __START_KERNEL_map;
29739 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29740 #else
29741
29742 #ifdef CONFIG_DEBUG_VIRTUAL
29743 -unsigned long __phys_addr(unsigned long x)
29744 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29745 {
29746 /* VMALLOC_* aren't constants */
29747 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29748 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29749 index 410531d..0f16030 100644
29750 --- a/arch/x86/mm/setup_nx.c
29751 +++ b/arch/x86/mm/setup_nx.c
29752 @@ -5,8 +5,10 @@
29753 #include <asm/pgtable.h>
29754 #include <asm/proto.h>
29755
29756 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29757 static int disable_nx __cpuinitdata;
29758
29759 +#ifndef CONFIG_PAX_PAGEEXEC
29760 /*
29761 * noexec = on|off
29762 *
29763 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29764 return 0;
29765 }
29766 early_param("noexec", noexec_setup);
29767 +#endif
29768 +
29769 +#endif
29770
29771 void __cpuinit x86_configure_nx(void)
29772 {
29773 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29774 if (cpu_has_nx && !disable_nx)
29775 __supported_pte_mask |= _PAGE_NX;
29776 else
29777 +#endif
29778 __supported_pte_mask &= ~_PAGE_NX;
29779 }
29780
29781 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29782 index 13a6b29..c2fff23 100644
29783 --- a/arch/x86/mm/tlb.c
29784 +++ b/arch/x86/mm/tlb.c
29785 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29786 BUG();
29787 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29788 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29789 +
29790 +#ifndef CONFIG_PAX_PER_CPU_PGD
29791 load_cr3(swapper_pg_dir);
29792 +#endif
29793 +
29794 }
29795 }
29796 EXPORT_SYMBOL_GPL(leave_mm);
29797 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29798 index 877b9a1..a8ecf42 100644
29799 --- a/arch/x86/net/bpf_jit.S
29800 +++ b/arch/x86/net/bpf_jit.S
29801 @@ -9,6 +9,7 @@
29802 */
29803 #include <linux/linkage.h>
29804 #include <asm/dwarf2.h>
29805 +#include <asm/alternative-asm.h>
29806
29807 /*
29808 * Calling convention :
29809 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29810 jle bpf_slow_path_word
29811 mov (SKBDATA,%rsi),%eax
29812 bswap %eax /* ntohl() */
29813 + pax_force_retaddr
29814 ret
29815
29816 sk_load_half:
29817 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29818 jle bpf_slow_path_half
29819 movzwl (SKBDATA,%rsi),%eax
29820 rol $8,%ax # ntohs()
29821 + pax_force_retaddr
29822 ret
29823
29824 sk_load_byte:
29825 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29826 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29827 jle bpf_slow_path_byte
29828 movzbl (SKBDATA,%rsi),%eax
29829 + pax_force_retaddr
29830 ret
29831
29832 /**
29833 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29834 movzbl (SKBDATA,%rsi),%ebx
29835 and $15,%bl
29836 shl $2,%bl
29837 + pax_force_retaddr
29838 ret
29839
29840 /* rsi contains offset and can be scratched */
29841 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29842 js bpf_error
29843 mov -12(%rbp),%eax
29844 bswap %eax
29845 + pax_force_retaddr
29846 ret
29847
29848 bpf_slow_path_half:
29849 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29850 mov -12(%rbp),%ax
29851 rol $8,%ax
29852 movzwl %ax,%eax
29853 + pax_force_retaddr
29854 ret
29855
29856 bpf_slow_path_byte:
29857 bpf_slow_path_common(1)
29858 js bpf_error
29859 movzbl -12(%rbp),%eax
29860 + pax_force_retaddr
29861 ret
29862
29863 bpf_slow_path_byte_msh:
29864 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29865 and $15,%al
29866 shl $2,%al
29867 xchg %eax,%ebx
29868 + pax_force_retaddr
29869 ret
29870
29871 #define sk_negative_common(SIZE) \
29872 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29873 sk_negative_common(4)
29874 mov (%rax), %eax
29875 bswap %eax
29876 + pax_force_retaddr
29877 ret
29878
29879 bpf_slow_path_half_neg:
29880 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29881 mov (%rax),%ax
29882 rol $8,%ax
29883 movzwl %ax,%eax
29884 + pax_force_retaddr
29885 ret
29886
29887 bpf_slow_path_byte_neg:
29888 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29889 .globl sk_load_byte_negative_offset
29890 sk_negative_common(1)
29891 movzbl (%rax), %eax
29892 + pax_force_retaddr
29893 ret
29894
29895 bpf_slow_path_byte_msh_neg:
29896 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29897 and $15,%al
29898 shl $2,%al
29899 xchg %eax,%ebx
29900 + pax_force_retaddr
29901 ret
29902
29903 bpf_error:
29904 @@ -197,4 +210,5 @@ bpf_error:
29905 xor %eax,%eax
29906 mov -8(%rbp),%rbx
29907 leaveq
29908 + pax_force_retaddr
29909 ret
29910 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29911 index d11a470..3f9adff3 100644
29912 --- a/arch/x86/net/bpf_jit_comp.c
29913 +++ b/arch/x86/net/bpf_jit_comp.c
29914 @@ -12,6 +12,7 @@
29915 #include <linux/netdevice.h>
29916 #include <linux/filter.h>
29917 #include <linux/if_vlan.h>
29918 +#include <linux/random.h>
29919
29920 /*
29921 * Conventions :
29922 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29923 return ptr + len;
29924 }
29925
29926 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29927 +#define MAX_INSTR_CODE_SIZE 96
29928 +#else
29929 +#define MAX_INSTR_CODE_SIZE 64
29930 +#endif
29931 +
29932 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29933
29934 #define EMIT1(b1) EMIT(b1, 1)
29935 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29936 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29937 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29938 +
29939 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29940 +/* original constant will appear in ecx */
29941 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29942 +do { \
29943 + /* mov ecx, randkey */ \
29944 + EMIT1(0xb9); \
29945 + EMIT(_key, 4); \
29946 + /* xor ecx, randkey ^ off */ \
29947 + EMIT2(0x81, 0xf1); \
29948 + EMIT((_key) ^ (_off), 4); \
29949 +} while (0)
29950 +
29951 +#define EMIT1_off32(b1, _off) \
29952 +do { \
29953 + switch (b1) { \
29954 + case 0x05: /* add eax, imm32 */ \
29955 + case 0x2d: /* sub eax, imm32 */ \
29956 + case 0x25: /* and eax, imm32 */ \
29957 + case 0x0d: /* or eax, imm32 */ \
29958 + case 0xb8: /* mov eax, imm32 */ \
29959 + case 0x3d: /* cmp eax, imm32 */ \
29960 + case 0xa9: /* test eax, imm32 */ \
29961 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29962 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29963 + break; \
29964 + case 0xbb: /* mov ebx, imm32 */ \
29965 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29966 + /* mov ebx, ecx */ \
29967 + EMIT2(0x89, 0xcb); \
29968 + break; \
29969 + case 0xbe: /* mov esi, imm32 */ \
29970 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29971 + /* mov esi, ecx */ \
29972 + EMIT2(0x89, 0xce); \
29973 + break; \
29974 + case 0xe9: /* jmp rel imm32 */ \
29975 + EMIT1(b1); \
29976 + EMIT(_off, 4); \
29977 + /* prevent fall-through, we're not called if off = 0 */ \
29978 + EMIT(0xcccccccc, 4); \
29979 + EMIT(0xcccccccc, 4); \
29980 + break; \
29981 + default: \
29982 + EMIT1(b1); \
29983 + EMIT(_off, 4); \
29984 + } \
29985 +} while (0)
29986 +
29987 +#define EMIT2_off32(b1, b2, _off) \
29988 +do { \
29989 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29990 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29991 + EMIT(randkey, 4); \
29992 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29993 + EMIT((_off) - randkey, 4); \
29994 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29995 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29996 + /* imul eax, ecx */ \
29997 + EMIT3(0x0f, 0xaf, 0xc1); \
29998 + } else { \
29999 + EMIT2(b1, b2); \
30000 + EMIT(_off, 4); \
30001 + } \
30002 +} while (0)
30003 +#else
30004 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
30005 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
30006 +#endif
30007
30008 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
30009 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
30010 @@ -90,6 +165,24 @@ do { \
30011 #define X86_JBE 0x76
30012 #define X86_JA 0x77
30013
30014 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30015 +#define APPEND_FLOW_VERIFY() \
30016 +do { \
30017 + /* mov ecx, randkey */ \
30018 + EMIT1(0xb9); \
30019 + EMIT(randkey, 4); \
30020 + /* cmp ecx, randkey */ \
30021 + EMIT2(0x81, 0xf9); \
30022 + EMIT(randkey, 4); \
30023 + /* jz after 8 int 3s */ \
30024 + EMIT2(0x74, 0x08); \
30025 + EMIT(0xcccccccc, 4); \
30026 + EMIT(0xcccccccc, 4); \
30027 +} while (0)
30028 +#else
30029 +#define APPEND_FLOW_VERIFY() do { } while (0)
30030 +#endif
30031 +
30032 #define EMIT_COND_JMP(op, offset) \
30033 do { \
30034 if (is_near(offset)) \
30035 @@ -97,6 +190,7 @@ do { \
30036 else { \
30037 EMIT2(0x0f, op + 0x10); \
30038 EMIT(offset, 4); /* jxx .+off32 */ \
30039 + APPEND_FLOW_VERIFY(); \
30040 } \
30041 } while (0)
30042
30043 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30044 set_fs(old_fs);
30045 }
30046
30047 +struct bpf_jit_work {
30048 + struct work_struct work;
30049 + void *image;
30050 +};
30051 +
30052 #define CHOOSE_LOAD_FUNC(K, func) \
30053 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30054
30055 void bpf_jit_compile(struct sk_filter *fp)
30056 {
30057 - u8 temp[64];
30058 + u8 temp[MAX_INSTR_CODE_SIZE];
30059 u8 *prog;
30060 unsigned int proglen, oldproglen = 0;
30061 int ilen, i;
30062 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30063 unsigned int *addrs;
30064 const struct sock_filter *filter = fp->insns;
30065 int flen = fp->len;
30066 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30067 + unsigned int randkey;
30068 +#endif
30069
30070 if (!bpf_jit_enable)
30071 return;
30072 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30073 if (addrs == NULL)
30074 return;
30075
30076 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30077 + if (!fp->work)
30078 + goto out;
30079 +
30080 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30081 + randkey = get_random_int();
30082 +#endif
30083 +
30084 /* Before first pass, make a rough estimation of addrs[]
30085 - * each bpf instruction is translated to less than 64 bytes
30086 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30087 */
30088 for (proglen = 0, i = 0; i < flen; i++) {
30089 - proglen += 64;
30090 + proglen += MAX_INSTR_CODE_SIZE;
30091 addrs[i] = proglen;
30092 }
30093 cleanup_addr = proglen; /* epilogue address */
30094 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30095 case BPF_S_ALU_MUL_K: /* A *= K */
30096 if (is_imm8(K))
30097 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30098 - else {
30099 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30100 - EMIT(K, 4);
30101 - }
30102 + else
30103 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30104 break;
30105 case BPF_S_ALU_DIV_X: /* A /= X; */
30106 seen |= SEEN_XREG;
30107 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30108 break;
30109 case BPF_S_ALU_MOD_K: /* A %= K; */
30110 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30111 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30112 + DILUTE_CONST_SEQUENCE(K, randkey);
30113 +#else
30114 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30115 +#endif
30116 EMIT2(0xf7, 0xf1); /* div %ecx */
30117 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30118 break;
30119 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30120 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30121 + DILUTE_CONST_SEQUENCE(K, randkey);
30122 + // imul rax, rcx
30123 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30124 +#else
30125 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30126 EMIT(K, 4);
30127 +#endif
30128 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30129 break;
30130 case BPF_S_ALU_AND_X:
30131 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30132 if (is_imm8(K)) {
30133 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30134 } else {
30135 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30136 - EMIT(K, 4);
30137 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30138 }
30139 } else {
30140 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30141 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30142 break;
30143 default:
30144 /* hmm, too complex filter, give up with jit compiler */
30145 - goto out;
30146 + goto error;
30147 }
30148 ilen = prog - temp;
30149 if (image) {
30150 if (unlikely(proglen + ilen > oldproglen)) {
30151 pr_err("bpb_jit_compile fatal error\n");
30152 - kfree(addrs);
30153 - module_free(NULL, image);
30154 - return;
30155 + module_free_exec(NULL, image);
30156 + goto error;
30157 }
30158 + pax_open_kernel();
30159 memcpy(image + proglen, temp, ilen);
30160 + pax_close_kernel();
30161 }
30162 proglen += ilen;
30163 addrs[i] = proglen;
30164 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30165 break;
30166 }
30167 if (proglen == oldproglen) {
30168 - image = module_alloc(max_t(unsigned int,
30169 - proglen,
30170 - sizeof(struct work_struct)));
30171 + image = module_alloc_exec(proglen);
30172 if (!image)
30173 - goto out;
30174 + goto error;
30175 }
30176 oldproglen = proglen;
30177 }
30178 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30179 bpf_flush_icache(image, image + proglen);
30180
30181 fp->bpf_func = (void *)image;
30182 - }
30183 + } else
30184 +error:
30185 + kfree(fp->work);
30186 +
30187 out:
30188 kfree(addrs);
30189 return;
30190 @@ -707,18 +826,20 @@ out:
30191
30192 static void jit_free_defer(struct work_struct *arg)
30193 {
30194 - module_free(NULL, arg);
30195 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30196 + kfree(arg);
30197 }
30198
30199 /* run from softirq, we must use a work_struct to call
30200 - * module_free() from process context
30201 + * module_free_exec() from process context
30202 */
30203 void bpf_jit_free(struct sk_filter *fp)
30204 {
30205 if (fp->bpf_func != sk_run_filter) {
30206 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30207 + struct work_struct *work = &fp->work->work;
30208
30209 INIT_WORK(work, jit_free_defer);
30210 + fp->work->image = fp->bpf_func;
30211 schedule_work(work);
30212 }
30213 }
30214 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30215 index d6aa6e8..266395a 100644
30216 --- a/arch/x86/oprofile/backtrace.c
30217 +++ b/arch/x86/oprofile/backtrace.c
30218 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30219 struct stack_frame_ia32 *fp;
30220 unsigned long bytes;
30221
30222 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30223 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30224 if (bytes != sizeof(bufhead))
30225 return NULL;
30226
30227 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30228 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30229
30230 oprofile_add_trace(bufhead[0].return_address);
30231
30232 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30233 struct stack_frame bufhead[2];
30234 unsigned long bytes;
30235
30236 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30237 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30238 if (bytes != sizeof(bufhead))
30239 return NULL;
30240
30241 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30242 {
30243 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30244
30245 - if (!user_mode_vm(regs)) {
30246 + if (!user_mode(regs)) {
30247 unsigned long stack = kernel_stack_pointer(regs);
30248 if (depth)
30249 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30250 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30251 index 48768df..ba9143c 100644
30252 --- a/arch/x86/oprofile/nmi_int.c
30253 +++ b/arch/x86/oprofile/nmi_int.c
30254 @@ -23,6 +23,7 @@
30255 #include <asm/nmi.h>
30256 #include <asm/msr.h>
30257 #include <asm/apic.h>
30258 +#include <asm/pgtable.h>
30259
30260 #include "op_counter.h"
30261 #include "op_x86_model.h"
30262 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30263 if (ret)
30264 return ret;
30265
30266 - if (!model->num_virt_counters)
30267 - model->num_virt_counters = model->num_counters;
30268 + if (!model->num_virt_counters) {
30269 + pax_open_kernel();
30270 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30271 + pax_close_kernel();
30272 + }
30273
30274 mux_init(ops);
30275
30276 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30277 index b2b9443..be58856 100644
30278 --- a/arch/x86/oprofile/op_model_amd.c
30279 +++ b/arch/x86/oprofile/op_model_amd.c
30280 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30281 num_counters = AMD64_NUM_COUNTERS;
30282 }
30283
30284 - op_amd_spec.num_counters = num_counters;
30285 - op_amd_spec.num_controls = num_counters;
30286 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30287 + pax_open_kernel();
30288 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30289 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30290 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30291 + pax_close_kernel();
30292
30293 return 0;
30294 }
30295 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30296 index d90528e..0127e2b 100644
30297 --- a/arch/x86/oprofile/op_model_ppro.c
30298 +++ b/arch/x86/oprofile/op_model_ppro.c
30299 @@ -19,6 +19,7 @@
30300 #include <asm/msr.h>
30301 #include <asm/apic.h>
30302 #include <asm/nmi.h>
30303 +#include <asm/pgtable.h>
30304
30305 #include "op_x86_model.h"
30306 #include "op_counter.h"
30307 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30308
30309 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30310
30311 - op_arch_perfmon_spec.num_counters = num_counters;
30312 - op_arch_perfmon_spec.num_controls = num_counters;
30313 + pax_open_kernel();
30314 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30315 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30316 + pax_close_kernel();
30317 }
30318
30319 static int arch_perfmon_init(struct oprofile_operations *ignore)
30320 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30321 index 71e8a67..6a313bb 100644
30322 --- a/arch/x86/oprofile/op_x86_model.h
30323 +++ b/arch/x86/oprofile/op_x86_model.h
30324 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30325 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30326 struct op_msrs const * const msrs);
30327 #endif
30328 -};
30329 +} __do_const;
30330
30331 struct op_counter_config;
30332
30333 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30334 index e9e6ed5..e47ae67 100644
30335 --- a/arch/x86/pci/amd_bus.c
30336 +++ b/arch/x86/pci/amd_bus.c
30337 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30338 return NOTIFY_OK;
30339 }
30340
30341 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30342 +static struct notifier_block amd_cpu_notifier = {
30343 .notifier_call = amd_cpu_notify,
30344 };
30345
30346 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30347 index 372e9b8..e775a6c 100644
30348 --- a/arch/x86/pci/irq.c
30349 +++ b/arch/x86/pci/irq.c
30350 @@ -50,7 +50,7 @@ struct irq_router {
30351 struct irq_router_handler {
30352 u16 vendor;
30353 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30354 -};
30355 +} __do_const;
30356
30357 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30358 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30359 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30360 return 0;
30361 }
30362
30363 -static __initdata struct irq_router_handler pirq_routers[] = {
30364 +static __initconst const struct irq_router_handler pirq_routers[] = {
30365 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30366 { PCI_VENDOR_ID_AL, ali_router_probe },
30367 { PCI_VENDOR_ID_ITE, ite_router_probe },
30368 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30369 static void __init pirq_find_router(struct irq_router *r)
30370 {
30371 struct irq_routing_table *rt = pirq_table;
30372 - struct irq_router_handler *h;
30373 + const struct irq_router_handler *h;
30374
30375 #ifdef CONFIG_PCI_BIOS
30376 if (!rt->signature) {
30377 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30378 return 0;
30379 }
30380
30381 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30382 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30383 {
30384 .callback = fix_broken_hp_bios_irq9,
30385 .ident = "HP Pavilion N5400 Series Laptop",
30386 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30387 index 6eb18c4..20d83de 100644
30388 --- a/arch/x86/pci/mrst.c
30389 +++ b/arch/x86/pci/mrst.c
30390 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30391 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30392 pci_mmcfg_late_init();
30393 pcibios_enable_irq = mrst_pci_irq_enable;
30394 - pci_root_ops = pci_mrst_ops;
30395 + pax_open_kernel();
30396 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30397 + pax_close_kernel();
30398 pci_soc_mode = 1;
30399 /* Continue with standard init */
30400 return 1;
30401 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30402 index c77b24a..c979855 100644
30403 --- a/arch/x86/pci/pcbios.c
30404 +++ b/arch/x86/pci/pcbios.c
30405 @@ -79,7 +79,7 @@ union bios32 {
30406 static struct {
30407 unsigned long address;
30408 unsigned short segment;
30409 -} bios32_indirect = { 0, __KERNEL_CS };
30410 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30411
30412 /*
30413 * Returns the entry point for the given service, NULL on error
30414 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30415 unsigned long length; /* %ecx */
30416 unsigned long entry; /* %edx */
30417 unsigned long flags;
30418 + struct desc_struct d, *gdt;
30419
30420 local_irq_save(flags);
30421 - __asm__("lcall *(%%edi); cld"
30422 +
30423 + gdt = get_cpu_gdt_table(smp_processor_id());
30424 +
30425 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30426 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30427 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30428 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30429 +
30430 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30431 : "=a" (return_code),
30432 "=b" (address),
30433 "=c" (length),
30434 "=d" (entry)
30435 : "0" (service),
30436 "1" (0),
30437 - "D" (&bios32_indirect));
30438 + "D" (&bios32_indirect),
30439 + "r"(__PCIBIOS_DS)
30440 + : "memory");
30441 +
30442 + pax_open_kernel();
30443 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30444 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30445 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30446 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30447 + pax_close_kernel();
30448 +
30449 local_irq_restore(flags);
30450
30451 switch (return_code) {
30452 - case 0:
30453 - return address + entry;
30454 - case 0x80: /* Not present */
30455 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30456 - return 0;
30457 - default: /* Shouldn't happen */
30458 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30459 - service, return_code);
30460 + case 0: {
30461 + int cpu;
30462 + unsigned char flags;
30463 +
30464 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30465 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30466 + printk(KERN_WARNING "bios32_service: not valid\n");
30467 return 0;
30468 + }
30469 + address = address + PAGE_OFFSET;
30470 + length += 16UL; /* some BIOSs underreport this... */
30471 + flags = 4;
30472 + if (length >= 64*1024*1024) {
30473 + length >>= PAGE_SHIFT;
30474 + flags |= 8;
30475 + }
30476 +
30477 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30478 + gdt = get_cpu_gdt_table(cpu);
30479 + pack_descriptor(&d, address, length, 0x9b, flags);
30480 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30481 + pack_descriptor(&d, address, length, 0x93, flags);
30482 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30483 + }
30484 + return entry;
30485 + }
30486 + case 0x80: /* Not present */
30487 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30488 + return 0;
30489 + default: /* Shouldn't happen */
30490 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30491 + service, return_code);
30492 + return 0;
30493 }
30494 }
30495
30496 static struct {
30497 unsigned long address;
30498 unsigned short segment;
30499 -} pci_indirect = { 0, __KERNEL_CS };
30500 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30501
30502 -static int pci_bios_present;
30503 +static int pci_bios_present __read_only;
30504
30505 static int check_pcibios(void)
30506 {
30507 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30508 unsigned long flags, pcibios_entry;
30509
30510 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30511 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30512 + pci_indirect.address = pcibios_entry;
30513
30514 local_irq_save(flags);
30515 - __asm__(
30516 - "lcall *(%%edi); cld\n\t"
30517 + __asm__("movw %w6, %%ds\n\t"
30518 + "lcall *%%ss:(%%edi); cld\n\t"
30519 + "push %%ss\n\t"
30520 + "pop %%ds\n\t"
30521 "jc 1f\n\t"
30522 "xor %%ah, %%ah\n"
30523 "1:"
30524 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30525 "=b" (ebx),
30526 "=c" (ecx)
30527 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30528 - "D" (&pci_indirect)
30529 + "D" (&pci_indirect),
30530 + "r" (__PCIBIOS_DS)
30531 : "memory");
30532 local_irq_restore(flags);
30533
30534 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30535
30536 switch (len) {
30537 case 1:
30538 - __asm__("lcall *(%%esi); cld\n\t"
30539 + __asm__("movw %w6, %%ds\n\t"
30540 + "lcall *%%ss:(%%esi); cld\n\t"
30541 + "push %%ss\n\t"
30542 + "pop %%ds\n\t"
30543 "jc 1f\n\t"
30544 "xor %%ah, %%ah\n"
30545 "1:"
30546 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30547 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30548 "b" (bx),
30549 "D" ((long)reg),
30550 - "S" (&pci_indirect));
30551 + "S" (&pci_indirect),
30552 + "r" (__PCIBIOS_DS));
30553 /*
30554 * Zero-extend the result beyond 8 bits, do not trust the
30555 * BIOS having done it:
30556 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30557 *value &= 0xff;
30558 break;
30559 case 2:
30560 - __asm__("lcall *(%%esi); cld\n\t"
30561 + __asm__("movw %w6, %%ds\n\t"
30562 + "lcall *%%ss:(%%esi); cld\n\t"
30563 + "push %%ss\n\t"
30564 + "pop %%ds\n\t"
30565 "jc 1f\n\t"
30566 "xor %%ah, %%ah\n"
30567 "1:"
30568 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30569 : "1" (PCIBIOS_READ_CONFIG_WORD),
30570 "b" (bx),
30571 "D" ((long)reg),
30572 - "S" (&pci_indirect));
30573 + "S" (&pci_indirect),
30574 + "r" (__PCIBIOS_DS));
30575 /*
30576 * Zero-extend the result beyond 16 bits, do not trust the
30577 * BIOS having done it:
30578 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30579 *value &= 0xffff;
30580 break;
30581 case 4:
30582 - __asm__("lcall *(%%esi); cld\n\t"
30583 + __asm__("movw %w6, %%ds\n\t"
30584 + "lcall *%%ss:(%%esi); cld\n\t"
30585 + "push %%ss\n\t"
30586 + "pop %%ds\n\t"
30587 "jc 1f\n\t"
30588 "xor %%ah, %%ah\n"
30589 "1:"
30590 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30591 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30592 "b" (bx),
30593 "D" ((long)reg),
30594 - "S" (&pci_indirect));
30595 + "S" (&pci_indirect),
30596 + "r" (__PCIBIOS_DS));
30597 break;
30598 }
30599
30600 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30601
30602 switch (len) {
30603 case 1:
30604 - __asm__("lcall *(%%esi); cld\n\t"
30605 + __asm__("movw %w6, %%ds\n\t"
30606 + "lcall *%%ss:(%%esi); cld\n\t"
30607 + "push %%ss\n\t"
30608 + "pop %%ds\n\t"
30609 "jc 1f\n\t"
30610 "xor %%ah, %%ah\n"
30611 "1:"
30612 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30613 "c" (value),
30614 "b" (bx),
30615 "D" ((long)reg),
30616 - "S" (&pci_indirect));
30617 + "S" (&pci_indirect),
30618 + "r" (__PCIBIOS_DS));
30619 break;
30620 case 2:
30621 - __asm__("lcall *(%%esi); cld\n\t"
30622 + __asm__("movw %w6, %%ds\n\t"
30623 + "lcall *%%ss:(%%esi); cld\n\t"
30624 + "push %%ss\n\t"
30625 + "pop %%ds\n\t"
30626 "jc 1f\n\t"
30627 "xor %%ah, %%ah\n"
30628 "1:"
30629 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30630 "c" (value),
30631 "b" (bx),
30632 "D" ((long)reg),
30633 - "S" (&pci_indirect));
30634 + "S" (&pci_indirect),
30635 + "r" (__PCIBIOS_DS));
30636 break;
30637 case 4:
30638 - __asm__("lcall *(%%esi); cld\n\t"
30639 + __asm__("movw %w6, %%ds\n\t"
30640 + "lcall *%%ss:(%%esi); cld\n\t"
30641 + "push %%ss\n\t"
30642 + "pop %%ds\n\t"
30643 "jc 1f\n\t"
30644 "xor %%ah, %%ah\n"
30645 "1:"
30646 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30647 "c" (value),
30648 "b" (bx),
30649 "D" ((long)reg),
30650 - "S" (&pci_indirect));
30651 + "S" (&pci_indirect),
30652 + "r" (__PCIBIOS_DS));
30653 break;
30654 }
30655
30656 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30657
30658 DBG("PCI: Fetching IRQ routing table... ");
30659 __asm__("push %%es\n\t"
30660 + "movw %w8, %%ds\n\t"
30661 "push %%ds\n\t"
30662 "pop %%es\n\t"
30663 - "lcall *(%%esi); cld\n\t"
30664 + "lcall *%%ss:(%%esi); cld\n\t"
30665 "pop %%es\n\t"
30666 + "push %%ss\n\t"
30667 + "pop %%ds\n"
30668 "jc 1f\n\t"
30669 "xor %%ah, %%ah\n"
30670 "1:"
30671 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30672 "1" (0),
30673 "D" ((long) &opt),
30674 "S" (&pci_indirect),
30675 - "m" (opt)
30676 + "m" (opt),
30677 + "r" (__PCIBIOS_DS)
30678 : "memory");
30679 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30680 if (ret & 0xff00)
30681 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30682 {
30683 int ret;
30684
30685 - __asm__("lcall *(%%esi); cld\n\t"
30686 + __asm__("movw %w5, %%ds\n\t"
30687 + "lcall *%%ss:(%%esi); cld\n\t"
30688 + "push %%ss\n\t"
30689 + "pop %%ds\n"
30690 "jc 1f\n\t"
30691 "xor %%ah, %%ah\n"
30692 "1:"
30693 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30694 : "0" (PCIBIOS_SET_PCI_HW_INT),
30695 "b" ((dev->bus->number << 8) | dev->devfn),
30696 "c" ((irq << 8) | (pin + 10)),
30697 - "S" (&pci_indirect));
30698 + "S" (&pci_indirect),
30699 + "r" (__PCIBIOS_DS));
30700 return !(ret & 0xff00);
30701 }
30702 EXPORT_SYMBOL(pcibios_set_irq_routing);
30703 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30704 index 40e4469..1ab536e 100644
30705 --- a/arch/x86/platform/efi/efi_32.c
30706 +++ b/arch/x86/platform/efi/efi_32.c
30707 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30708 {
30709 struct desc_ptr gdt_descr;
30710
30711 +#ifdef CONFIG_PAX_KERNEXEC
30712 + struct desc_struct d;
30713 +#endif
30714 +
30715 local_irq_save(efi_rt_eflags);
30716
30717 load_cr3(initial_page_table);
30718 __flush_tlb_all();
30719
30720 +#ifdef CONFIG_PAX_KERNEXEC
30721 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30722 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30723 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30724 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30725 +#endif
30726 +
30727 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30728 gdt_descr.size = GDT_SIZE - 1;
30729 load_gdt(&gdt_descr);
30730 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30731 {
30732 struct desc_ptr gdt_descr;
30733
30734 +#ifdef CONFIG_PAX_KERNEXEC
30735 + struct desc_struct d;
30736 +
30737 + memset(&d, 0, sizeof d);
30738 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30739 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30740 +#endif
30741 +
30742 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30743 gdt_descr.size = GDT_SIZE - 1;
30744 load_gdt(&gdt_descr);
30745 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30746 index fbe66e6..eae5e38 100644
30747 --- a/arch/x86/platform/efi/efi_stub_32.S
30748 +++ b/arch/x86/platform/efi/efi_stub_32.S
30749 @@ -6,7 +6,9 @@
30750 */
30751
30752 #include <linux/linkage.h>
30753 +#include <linux/init.h>
30754 #include <asm/page_types.h>
30755 +#include <asm/segment.h>
30756
30757 /*
30758 * efi_call_phys(void *, ...) is a function with variable parameters.
30759 @@ -20,7 +22,7 @@
30760 * service functions will comply with gcc calling convention, too.
30761 */
30762
30763 -.text
30764 +__INIT
30765 ENTRY(efi_call_phys)
30766 /*
30767 * 0. The function can only be called in Linux kernel. So CS has been
30768 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30769 * The mapping of lower virtual memory has been created in prelog and
30770 * epilog.
30771 */
30772 - movl $1f, %edx
30773 - subl $__PAGE_OFFSET, %edx
30774 - jmp *%edx
30775 +#ifdef CONFIG_PAX_KERNEXEC
30776 + movl $(__KERNEXEC_EFI_DS), %edx
30777 + mov %edx, %ds
30778 + mov %edx, %es
30779 + mov %edx, %ss
30780 + addl $2f,(1f)
30781 + ljmp *(1f)
30782 +
30783 +__INITDATA
30784 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30785 +.previous
30786 +
30787 +2:
30788 + subl $2b,(1b)
30789 +#else
30790 + jmp 1f-__PAGE_OFFSET
30791 1:
30792 +#endif
30793
30794 /*
30795 * 2. Now on the top of stack is the return
30796 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30797 * parameter 2, ..., param n. To make things easy, we save the return
30798 * address of efi_call_phys in a global variable.
30799 */
30800 - popl %edx
30801 - movl %edx, saved_return_addr
30802 - /* get the function pointer into ECX*/
30803 - popl %ecx
30804 - movl %ecx, efi_rt_function_ptr
30805 - movl $2f, %edx
30806 - subl $__PAGE_OFFSET, %edx
30807 - pushl %edx
30808 + popl (saved_return_addr)
30809 + popl (efi_rt_function_ptr)
30810
30811 /*
30812 * 3. Clear PG bit in %CR0.
30813 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30814 /*
30815 * 5. Call the physical function.
30816 */
30817 - jmp *%ecx
30818 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30819
30820 -2:
30821 /*
30822 * 6. After EFI runtime service returns, control will return to
30823 * following instruction. We'd better readjust stack pointer first.
30824 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30825 movl %cr0, %edx
30826 orl $0x80000000, %edx
30827 movl %edx, %cr0
30828 - jmp 1f
30829 -1:
30830 +
30831 /*
30832 * 8. Now restore the virtual mode from flat mode by
30833 * adding EIP with PAGE_OFFSET.
30834 */
30835 - movl $1f, %edx
30836 - jmp *%edx
30837 +#ifdef CONFIG_PAX_KERNEXEC
30838 + movl $(__KERNEL_DS), %edx
30839 + mov %edx, %ds
30840 + mov %edx, %es
30841 + mov %edx, %ss
30842 + ljmp $(__KERNEL_CS),$1f
30843 +#else
30844 + jmp 1f+__PAGE_OFFSET
30845 +#endif
30846 1:
30847
30848 /*
30849 * 9. Balance the stack. And because EAX contain the return value,
30850 * we'd better not clobber it.
30851 */
30852 - leal efi_rt_function_ptr, %edx
30853 - movl (%edx), %ecx
30854 - pushl %ecx
30855 + pushl (efi_rt_function_ptr)
30856
30857 /*
30858 - * 10. Push the saved return address onto the stack and return.
30859 + * 10. Return to the saved return address.
30860 */
30861 - leal saved_return_addr, %edx
30862 - movl (%edx), %ecx
30863 - pushl %ecx
30864 - ret
30865 + jmpl *(saved_return_addr)
30866 ENDPROC(efi_call_phys)
30867 .previous
30868
30869 -.data
30870 +__INITDATA
30871 saved_return_addr:
30872 .long 0
30873 efi_rt_function_ptr:
30874 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30875 index 4c07cca..2c8427d 100644
30876 --- a/arch/x86/platform/efi/efi_stub_64.S
30877 +++ b/arch/x86/platform/efi/efi_stub_64.S
30878 @@ -7,6 +7,7 @@
30879 */
30880
30881 #include <linux/linkage.h>
30882 +#include <asm/alternative-asm.h>
30883
30884 #define SAVE_XMM \
30885 mov %rsp, %rax; \
30886 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30887 call *%rdi
30888 addq $32, %rsp
30889 RESTORE_XMM
30890 + pax_force_retaddr 0, 1
30891 ret
30892 ENDPROC(efi_call0)
30893
30894 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30895 call *%rdi
30896 addq $32, %rsp
30897 RESTORE_XMM
30898 + pax_force_retaddr 0, 1
30899 ret
30900 ENDPROC(efi_call1)
30901
30902 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30903 call *%rdi
30904 addq $32, %rsp
30905 RESTORE_XMM
30906 + pax_force_retaddr 0, 1
30907 ret
30908 ENDPROC(efi_call2)
30909
30910 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30911 call *%rdi
30912 addq $32, %rsp
30913 RESTORE_XMM
30914 + pax_force_retaddr 0, 1
30915 ret
30916 ENDPROC(efi_call3)
30917
30918 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30919 call *%rdi
30920 addq $32, %rsp
30921 RESTORE_XMM
30922 + pax_force_retaddr 0, 1
30923 ret
30924 ENDPROC(efi_call4)
30925
30926 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30927 call *%rdi
30928 addq $48, %rsp
30929 RESTORE_XMM
30930 + pax_force_retaddr 0, 1
30931 ret
30932 ENDPROC(efi_call5)
30933
30934 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30935 call *%rdi
30936 addq $48, %rsp
30937 RESTORE_XMM
30938 + pax_force_retaddr 0, 1
30939 ret
30940 ENDPROC(efi_call6)
30941 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30942 index e31bcd8..f12dc46 100644
30943 --- a/arch/x86/platform/mrst/mrst.c
30944 +++ b/arch/x86/platform/mrst/mrst.c
30945 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30946 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30947 int sfi_mrtc_num;
30948
30949 -static void mrst_power_off(void)
30950 +static __noreturn void mrst_power_off(void)
30951 {
30952 + BUG();
30953 }
30954
30955 -static void mrst_reboot(void)
30956 +static __noreturn void mrst_reboot(void)
30957 {
30958 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30959 + BUG();
30960 }
30961
30962 /* parse all the mtimer info to a static mtimer array */
30963 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30964 index d6ee929..3637cb5 100644
30965 --- a/arch/x86/platform/olpc/olpc_dt.c
30966 +++ b/arch/x86/platform/olpc/olpc_dt.c
30967 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30968 return res;
30969 }
30970
30971 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30972 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30973 .nextprop = olpc_dt_nextprop,
30974 .getproplen = olpc_dt_getproplen,
30975 .getproperty = olpc_dt_getproperty,
30976 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30977 index 3c68768..07e82b8 100644
30978 --- a/arch/x86/power/cpu.c
30979 +++ b/arch/x86/power/cpu.c
30980 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30981 static void fix_processor_context(void)
30982 {
30983 int cpu = smp_processor_id();
30984 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30985 + struct tss_struct *t = init_tss + cpu;
30986
30987 set_tss_desc(cpu, t); /*
30988 * This just modifies memory; should not be
30989 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30990 */
30991
30992 #ifdef CONFIG_X86_64
30993 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30994 -
30995 syscall_init(); /* This sets MSR_*STAR and related */
30996 #endif
30997 load_TR_desc(); /* This does ltr */
30998 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30999 index cbca565..bae7133 100644
31000 --- a/arch/x86/realmode/init.c
31001 +++ b/arch/x86/realmode/init.c
31002 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
31003 __va(real_mode_header->trampoline_header);
31004
31005 #ifdef CONFIG_X86_32
31006 - trampoline_header->start = __pa(startup_32_smp);
31007 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
31008 +
31009 +#ifdef CONFIG_PAX_KERNEXEC
31010 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
31011 +#endif
31012 +
31013 + trampoline_header->boot_cs = __BOOT_CS;
31014 trampoline_header->gdt_limit = __BOOT_DS + 7;
31015 trampoline_header->gdt_base = __pa(boot_gdt);
31016 #else
31017 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
31018 index 8869287..d577672 100644
31019 --- a/arch/x86/realmode/rm/Makefile
31020 +++ b/arch/x86/realmode/rm/Makefile
31021 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
31022 $(call cc-option, -fno-unit-at-a-time)) \
31023 $(call cc-option, -fno-stack-protector) \
31024 $(call cc-option, -mpreferred-stack-boundary=2)
31025 +ifdef CONSTIFY_PLUGIN
31026 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
31027 +endif
31028 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
31029 GCOV_PROFILE := n
31030 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
31031 index a28221d..93c40f1 100644
31032 --- a/arch/x86/realmode/rm/header.S
31033 +++ b/arch/x86/realmode/rm/header.S
31034 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
31035 #endif
31036 /* APM/BIOS reboot */
31037 .long pa_machine_real_restart_asm
31038 -#ifdef CONFIG_X86_64
31039 +#ifdef CONFIG_X86_32
31040 + .long __KERNEL_CS
31041 +#else
31042 .long __KERNEL32_CS
31043 #endif
31044 END(real_mode_header)
31045 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31046 index c1b2791..f9e31c7 100644
31047 --- a/arch/x86/realmode/rm/trampoline_32.S
31048 +++ b/arch/x86/realmode/rm/trampoline_32.S
31049 @@ -25,6 +25,12 @@
31050 #include <asm/page_types.h>
31051 #include "realmode.h"
31052
31053 +#ifdef CONFIG_PAX_KERNEXEC
31054 +#define ta(X) (X)
31055 +#else
31056 +#define ta(X) (pa_ ## X)
31057 +#endif
31058 +
31059 .text
31060 .code16
31061
31062 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31063
31064 cli # We should be safe anyway
31065
31066 - movl tr_start, %eax # where we need to go
31067 -
31068 movl $0xA5A5A5A5, trampoline_status
31069 # write marker for master knows we're running
31070
31071 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31072 movw $1, %dx # protected mode (PE) bit
31073 lmsw %dx # into protected mode
31074
31075 - ljmpl $__BOOT_CS, $pa_startup_32
31076 + ljmpl *(trampoline_header)
31077
31078 .section ".text32","ax"
31079 .code32
31080 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31081 .balign 8
31082 GLOBAL(trampoline_header)
31083 tr_start: .space 4
31084 - tr_gdt_pad: .space 2
31085 + tr_boot_cs: .space 2
31086 tr_gdt: .space 6
31087 END(trampoline_header)
31088
31089 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31090 index bb360dc..3e5945f 100644
31091 --- a/arch/x86/realmode/rm/trampoline_64.S
31092 +++ b/arch/x86/realmode/rm/trampoline_64.S
31093 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31094 wrmsr
31095
31096 # Enable paging and in turn activate Long Mode
31097 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31098 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31099 movl %eax, %cr0
31100
31101 /*
31102 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31103 index 79d67bd..c7e1b90 100644
31104 --- a/arch/x86/tools/relocs.c
31105 +++ b/arch/x86/tools/relocs.c
31106 @@ -12,10 +12,13 @@
31107 #include <regex.h>
31108 #include <tools/le_byteshift.h>
31109
31110 +#include "../../../include/generated/autoconf.h"
31111 +
31112 static void die(char *fmt, ...);
31113
31114 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31115 static Elf32_Ehdr ehdr;
31116 +static Elf32_Phdr *phdr;
31117 static unsigned long reloc_count, reloc_idx;
31118 static unsigned long *relocs;
31119 static unsigned long reloc16_count, reloc16_idx;
31120 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31121 }
31122 }
31123
31124 +static void read_phdrs(FILE *fp)
31125 +{
31126 + unsigned int i;
31127 +
31128 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31129 + if (!phdr) {
31130 + die("Unable to allocate %d program headers\n",
31131 + ehdr.e_phnum);
31132 + }
31133 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31134 + die("Seek to %d failed: %s\n",
31135 + ehdr.e_phoff, strerror(errno));
31136 + }
31137 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31138 + die("Cannot read ELF program headers: %s\n",
31139 + strerror(errno));
31140 + }
31141 + for(i = 0; i < ehdr.e_phnum; i++) {
31142 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31143 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31144 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31145 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31146 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31147 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31148 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31149 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31150 + }
31151 +
31152 +}
31153 +
31154 static void read_shdrs(FILE *fp)
31155 {
31156 - int i;
31157 + unsigned int i;
31158 Elf32_Shdr shdr;
31159
31160 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31161 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31162
31163 static void read_strtabs(FILE *fp)
31164 {
31165 - int i;
31166 + unsigned int i;
31167 for (i = 0; i < ehdr.e_shnum; i++) {
31168 struct section *sec = &secs[i];
31169 if (sec->shdr.sh_type != SHT_STRTAB) {
31170 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31171
31172 static void read_symtabs(FILE *fp)
31173 {
31174 - int i,j;
31175 + unsigned int i,j;
31176 for (i = 0; i < ehdr.e_shnum; i++) {
31177 struct section *sec = &secs[i];
31178 if (sec->shdr.sh_type != SHT_SYMTAB) {
31179 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31180 }
31181
31182
31183 -static void read_relocs(FILE *fp)
31184 +static void read_relocs(FILE *fp, int use_real_mode)
31185 {
31186 - int i,j;
31187 + unsigned int i,j;
31188 + uint32_t base;
31189 +
31190 for (i = 0; i < ehdr.e_shnum; i++) {
31191 struct section *sec = &secs[i];
31192 if (sec->shdr.sh_type != SHT_REL) {
31193 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31194 die("Cannot read symbol table: %s\n",
31195 strerror(errno));
31196 }
31197 + base = 0;
31198 +
31199 +#ifdef CONFIG_X86_32
31200 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31201 + if (phdr[j].p_type != PT_LOAD )
31202 + continue;
31203 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
31204 + continue;
31205 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31206 + break;
31207 + }
31208 +#endif
31209 +
31210 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31211 Elf32_Rel *rel = &sec->reltab[j];
31212 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31213 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31214 rel->r_info = elf32_to_cpu(rel->r_info);
31215 }
31216 }
31217 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31218
31219 static void print_absolute_symbols(void)
31220 {
31221 - int i;
31222 + unsigned int i;
31223 printf("Absolute symbols\n");
31224 printf(" Num: Value Size Type Bind Visibility Name\n");
31225 for (i = 0; i < ehdr.e_shnum; i++) {
31226 struct section *sec = &secs[i];
31227 char *sym_strtab;
31228 - int j;
31229 + unsigned int j;
31230
31231 if (sec->shdr.sh_type != SHT_SYMTAB) {
31232 continue;
31233 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31234
31235 static void print_absolute_relocs(void)
31236 {
31237 - int i, printed = 0;
31238 + unsigned int i, printed = 0;
31239
31240 for (i = 0; i < ehdr.e_shnum; i++) {
31241 struct section *sec = &secs[i];
31242 struct section *sec_applies, *sec_symtab;
31243 char *sym_strtab;
31244 Elf32_Sym *sh_symtab;
31245 - int j;
31246 + unsigned int j;
31247 if (sec->shdr.sh_type != SHT_REL) {
31248 continue;
31249 }
31250 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31251 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31252 int use_real_mode)
31253 {
31254 - int i;
31255 + unsigned int i;
31256 /* Walk through the relocations */
31257 for (i = 0; i < ehdr.e_shnum; i++) {
31258 char *sym_strtab;
31259 Elf32_Sym *sh_symtab;
31260 struct section *sec_applies, *sec_symtab;
31261 - int j;
31262 + unsigned int j;
31263 struct section *sec = &secs[i];
31264
31265 if (sec->shdr.sh_type != SHT_REL) {
31266 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31267 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31268 r_type = ELF32_R_TYPE(rel->r_info);
31269
31270 + if (!use_real_mode) {
31271 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31272 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31273 + continue;
31274 +
31275 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31276 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31277 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31278 + continue;
31279 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31280 + continue;
31281 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31282 + continue;
31283 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31284 + continue;
31285 +#endif
31286 + }
31287 +
31288 shn_abs = sym->st_shndx == SHN_ABS;
31289
31290 switch (r_type) {
31291 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31292
31293 static void emit_relocs(int as_text, int use_real_mode)
31294 {
31295 - int i;
31296 + unsigned int i;
31297 /* Count how many relocations I have and allocate space for them. */
31298 reloc_count = 0;
31299 walk_relocs(count_reloc, use_real_mode);
31300 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31301 fname, strerror(errno));
31302 }
31303 read_ehdr(fp);
31304 + read_phdrs(fp);
31305 read_shdrs(fp);
31306 read_strtabs(fp);
31307 read_symtabs(fp);
31308 - read_relocs(fp);
31309 + read_relocs(fp, use_real_mode);
31310 if (show_absolute_syms) {
31311 print_absolute_symbols();
31312 goto out;
31313 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31314 index fd14be1..e3c79c0 100644
31315 --- a/arch/x86/vdso/Makefile
31316 +++ b/arch/x86/vdso/Makefile
31317 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31318 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31319 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31320
31321 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31322 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31323 GCOV_PROFILE := n
31324
31325 #
31326 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31327 index 0faad64..39ef157 100644
31328 --- a/arch/x86/vdso/vdso32-setup.c
31329 +++ b/arch/x86/vdso/vdso32-setup.c
31330 @@ -25,6 +25,7 @@
31331 #include <asm/tlbflush.h>
31332 #include <asm/vdso.h>
31333 #include <asm/proto.h>
31334 +#include <asm/mman.h>
31335
31336 enum {
31337 VDSO_DISABLED = 0,
31338 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31339 void enable_sep_cpu(void)
31340 {
31341 int cpu = get_cpu();
31342 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31343 + struct tss_struct *tss = init_tss + cpu;
31344
31345 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31346 put_cpu();
31347 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31348 gate_vma.vm_start = FIXADDR_USER_START;
31349 gate_vma.vm_end = FIXADDR_USER_END;
31350 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31351 - gate_vma.vm_page_prot = __P101;
31352 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31353
31354 return 0;
31355 }
31356 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31357 if (compat)
31358 addr = VDSO_HIGH_BASE;
31359 else {
31360 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31361 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31362 if (IS_ERR_VALUE(addr)) {
31363 ret = addr;
31364 goto up_fail;
31365 }
31366 }
31367
31368 - current->mm->context.vdso = (void *)addr;
31369 + current->mm->context.vdso = addr;
31370
31371 if (compat_uses_vma || !compat) {
31372 /*
31373 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31374 }
31375
31376 current_thread_info()->sysenter_return =
31377 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31378 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31379
31380 up_fail:
31381 if (ret)
31382 - current->mm->context.vdso = NULL;
31383 + current->mm->context.vdso = 0;
31384
31385 up_write(&mm->mmap_sem);
31386
31387 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31388
31389 const char *arch_vma_name(struct vm_area_struct *vma)
31390 {
31391 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31392 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31393 return "[vdso]";
31394 +
31395 +#ifdef CONFIG_PAX_SEGMEXEC
31396 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31397 + return "[vdso]";
31398 +#endif
31399 +
31400 return NULL;
31401 }
31402
31403 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31404 * Check to see if the corresponding task was created in compat vdso
31405 * mode.
31406 */
31407 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31408 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31409 return &gate_vma;
31410 return NULL;
31411 }
31412 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31413 index 431e875..cbb23f3 100644
31414 --- a/arch/x86/vdso/vma.c
31415 +++ b/arch/x86/vdso/vma.c
31416 @@ -16,8 +16,6 @@
31417 #include <asm/vdso.h>
31418 #include <asm/page.h>
31419
31420 -unsigned int __read_mostly vdso_enabled = 1;
31421 -
31422 extern char vdso_start[], vdso_end[];
31423 extern unsigned short vdso_sync_cpuid;
31424
31425 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31426 * unaligned here as a result of stack start randomization.
31427 */
31428 addr = PAGE_ALIGN(addr);
31429 - addr = align_vdso_addr(addr);
31430
31431 return addr;
31432 }
31433 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31434 unsigned size)
31435 {
31436 struct mm_struct *mm = current->mm;
31437 - unsigned long addr;
31438 + unsigned long addr = 0;
31439 int ret;
31440
31441 - if (!vdso_enabled)
31442 - return 0;
31443 -
31444 down_write(&mm->mmap_sem);
31445 +
31446 +#ifdef CONFIG_PAX_RANDMMAP
31447 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31448 +#endif
31449 +
31450 addr = vdso_addr(mm->start_stack, size);
31451 + addr = align_vdso_addr(addr);
31452 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31453 if (IS_ERR_VALUE(addr)) {
31454 ret = addr;
31455 goto up_fail;
31456 }
31457
31458 - current->mm->context.vdso = (void *)addr;
31459 + mm->context.vdso = addr;
31460
31461 ret = install_special_mapping(mm, addr, size,
31462 VM_READ|VM_EXEC|
31463 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31464 pages);
31465 - if (ret) {
31466 - current->mm->context.vdso = NULL;
31467 - goto up_fail;
31468 - }
31469 + if (ret)
31470 + mm->context.vdso = 0;
31471
31472 up_fail:
31473 up_write(&mm->mmap_sem);
31474 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31475 vdsox32_size);
31476 }
31477 #endif
31478 -
31479 -static __init int vdso_setup(char *s)
31480 -{
31481 - vdso_enabled = simple_strtoul(s, NULL, 0);
31482 - return 0;
31483 -}
31484 -__setup("vdso=", vdso_setup);
31485 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31486 index 08c6511..d946c4a 100644
31487 --- a/arch/x86/xen/enlighten.c
31488 +++ b/arch/x86/xen/enlighten.c
31489 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31490
31491 struct shared_info xen_dummy_shared_info;
31492
31493 -void *xen_initial_gdt;
31494 -
31495 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31496 __read_mostly int xen_have_vector_callback;
31497 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31498 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31499 {
31500 unsigned long va = dtr->address;
31501 unsigned int size = dtr->size + 1;
31502 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31503 - unsigned long frames[pages];
31504 + unsigned long frames[65536 / PAGE_SIZE];
31505 int f;
31506
31507 /*
31508 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31509 {
31510 unsigned long va = dtr->address;
31511 unsigned int size = dtr->size + 1;
31512 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31513 - unsigned long frames[pages];
31514 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31515 int f;
31516
31517 /*
31518 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31519 * 8-byte entries, or 16 4k pages..
31520 */
31521
31522 - BUG_ON(size > 65536);
31523 + BUG_ON(size > GDT_SIZE);
31524 BUG_ON(va & ~PAGE_MASK);
31525
31526 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31527 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31528 return 0;
31529 }
31530
31531 -static void set_xen_basic_apic_ops(void)
31532 +static void __init set_xen_basic_apic_ops(void)
31533 {
31534 apic->read = xen_apic_read;
31535 apic->write = xen_apic_write;
31536 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31537 #endif
31538 };
31539
31540 -static void xen_reboot(int reason)
31541 +static __noreturn void xen_reboot(int reason)
31542 {
31543 struct sched_shutdown r = { .reason = reason };
31544
31545 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31546 - BUG();
31547 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31548 + BUG();
31549 }
31550
31551 -static void xen_restart(char *msg)
31552 +static __noreturn void xen_restart(char *msg)
31553 {
31554 xen_reboot(SHUTDOWN_reboot);
31555 }
31556
31557 -static void xen_emergency_restart(void)
31558 +static __noreturn void xen_emergency_restart(void)
31559 {
31560 xen_reboot(SHUTDOWN_reboot);
31561 }
31562
31563 -static void xen_machine_halt(void)
31564 +static __noreturn void xen_machine_halt(void)
31565 {
31566 xen_reboot(SHUTDOWN_poweroff);
31567 }
31568
31569 -static void xen_machine_power_off(void)
31570 +static __noreturn void xen_machine_power_off(void)
31571 {
31572 if (pm_power_off)
31573 pm_power_off();
31574 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31575 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31576
31577 /* Work out if we support NX */
31578 - x86_configure_nx();
31579 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31580 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31581 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31582 + unsigned l, h;
31583 +
31584 + __supported_pte_mask |= _PAGE_NX;
31585 + rdmsr(MSR_EFER, l, h);
31586 + l |= EFER_NX;
31587 + wrmsr(MSR_EFER, l, h);
31588 + }
31589 +#endif
31590
31591 xen_setup_features();
31592
31593 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31594
31595 machine_ops = xen_machine_ops;
31596
31597 - /*
31598 - * The only reliable way to retain the initial address of the
31599 - * percpu gdt_page is to remember it here, so we can go and
31600 - * mark it RW later, when the initial percpu area is freed.
31601 - */
31602 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31603 -
31604 xen_smp_init();
31605
31606 #ifdef CONFIG_ACPI_NUMA
31607 @@ -1601,7 +1600,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31608 return NOTIFY_OK;
31609 }
31610
31611 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31612 +static struct notifier_block xen_hvm_cpu_notifier = {
31613 .notifier_call = xen_hvm_cpu_notify,
31614 };
31615
31616 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31617 index cab96b6..8c629ba 100644
31618 --- a/arch/x86/xen/mmu.c
31619 +++ b/arch/x86/xen/mmu.c
31620 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31621 }
31622
31623 /* Set the page permissions on an identity-mapped pages */
31624 -static void set_page_prot(void *addr, pgprot_t prot)
31625 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31626 {
31627 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31628 pte_t pte = pfn_pte(pfn, prot);
31629
31630 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31631 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31632 BUG();
31633 }
31634 +static void set_page_prot(void *addr, pgprot_t prot)
31635 +{
31636 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31637 +}
31638 #ifdef CONFIG_X86_32
31639 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31640 {
31641 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31642 unsigned long addr)
31643 {
31644 if (*pt_base == PFN_DOWN(__pa(addr))) {
31645 - set_page_prot((void *)addr, PAGE_KERNEL);
31646 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31647 clear_page((void *)addr);
31648 (*pt_base)++;
31649 }
31650 if (*pt_end == PFN_DOWN(__pa(addr))) {
31651 - set_page_prot((void *)addr, PAGE_KERNEL);
31652 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31653 clear_page((void *)addr);
31654 (*pt_end)--;
31655 }
31656 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31657 /* L3_k[510] -> level2_kernel_pgt
31658 * L3_i[511] -> level2_fixmap_pgt */
31659 convert_pfn_mfn(level3_kernel_pgt);
31660 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31661 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31662 + convert_pfn_mfn(level3_vmemmap_pgt);
31663
31664 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31665 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31666 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31667 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31668 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31669 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31670 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31671 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31672 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31673 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31674 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31675 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31676 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31677 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31678
31679 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31680 pv_mmu_ops.set_pud = xen_set_pud;
31681 #if PAGETABLE_LEVELS == 4
31682 pv_mmu_ops.set_pgd = xen_set_pgd;
31683 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31684 #endif
31685
31686 /* This will work as long as patching hasn't happened yet
31687 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31688 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31689 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31690 .set_pgd = xen_set_pgd_hyper,
31691 + .set_pgd_batched = xen_set_pgd_hyper,
31692
31693 .alloc_pud = xen_alloc_pmd_init,
31694 .release_pud = xen_release_pmd_init,
31695 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31696 index 48d7b2c..20fed27 100644
31697 --- a/arch/x86/xen/smp.c
31698 +++ b/arch/x86/xen/smp.c
31699 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31700 {
31701 BUG_ON(smp_processor_id() != 0);
31702 native_smp_prepare_boot_cpu();
31703 -
31704 - /* We've switched to the "real" per-cpu gdt, so make sure the
31705 - old memory can be recycled */
31706 - make_lowmem_page_readwrite(xen_initial_gdt);
31707 -
31708 xen_filter_cpu_maps();
31709 xen_setup_vcpu_info_placement();
31710 }
31711 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31712 gdt = get_cpu_gdt_table(cpu);
31713
31714 ctxt->flags = VGCF_IN_KERNEL;
31715 - ctxt->user_regs.ds = __USER_DS;
31716 - ctxt->user_regs.es = __USER_DS;
31717 + ctxt->user_regs.ds = __KERNEL_DS;
31718 + ctxt->user_regs.es = __KERNEL_DS;
31719 ctxt->user_regs.ss = __KERNEL_DS;
31720 #ifdef CONFIG_X86_32
31721 ctxt->user_regs.fs = __KERNEL_PERCPU;
31722 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31723 + savesegment(gs, ctxt->user_regs.gs);
31724 #else
31725 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31726 #endif
31727 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31728 int rc;
31729
31730 per_cpu(current_task, cpu) = idle;
31731 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31732 #ifdef CONFIG_X86_32
31733 irq_ctx_init(cpu);
31734 #else
31735 clear_tsk_thread_flag(idle, TIF_FORK);
31736 - per_cpu(kernel_stack, cpu) =
31737 - (unsigned long)task_stack_page(idle) -
31738 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31739 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31740 #endif
31741 xen_setup_runstate_info(cpu);
31742 xen_setup_timer(cpu);
31743 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31744
31745 void __init xen_smp_init(void)
31746 {
31747 - smp_ops = xen_smp_ops;
31748 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31749 xen_fill_possible_map();
31750 xen_init_spinlocks();
31751 }
31752 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31753 index 33ca6e4..0ded929 100644
31754 --- a/arch/x86/xen/xen-asm_32.S
31755 +++ b/arch/x86/xen/xen-asm_32.S
31756 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31757 ESP_OFFSET=4 # bytes pushed onto stack
31758
31759 /*
31760 - * Store vcpu_info pointer for easy access. Do it this way to
31761 - * avoid having to reload %fs
31762 + * Store vcpu_info pointer for easy access.
31763 */
31764 #ifdef CONFIG_SMP
31765 - GET_THREAD_INFO(%eax)
31766 - movl %ss:TI_cpu(%eax), %eax
31767 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31768 - mov %ss:xen_vcpu(%eax), %eax
31769 + push %fs
31770 + mov $(__KERNEL_PERCPU), %eax
31771 + mov %eax, %fs
31772 + mov PER_CPU_VAR(xen_vcpu), %eax
31773 + pop %fs
31774 #else
31775 movl %ss:xen_vcpu, %eax
31776 #endif
31777 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31778 index 7faed58..ba4427c 100644
31779 --- a/arch/x86/xen/xen-head.S
31780 +++ b/arch/x86/xen/xen-head.S
31781 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31782 #ifdef CONFIG_X86_32
31783 mov %esi,xen_start_info
31784 mov $init_thread_union+THREAD_SIZE,%esp
31785 +#ifdef CONFIG_SMP
31786 + movl $cpu_gdt_table,%edi
31787 + movl $__per_cpu_load,%eax
31788 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31789 + rorl $16,%eax
31790 + movb %al,__KERNEL_PERCPU + 4(%edi)
31791 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31792 + movl $__per_cpu_end - 1,%eax
31793 + subl $__per_cpu_start,%eax
31794 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31795 +#endif
31796 #else
31797 mov %rsi,xen_start_info
31798 mov $init_thread_union+THREAD_SIZE,%rsp
31799 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31800 index a95b417..b6dbd0b 100644
31801 --- a/arch/x86/xen/xen-ops.h
31802 +++ b/arch/x86/xen/xen-ops.h
31803 @@ -10,8 +10,6 @@
31804 extern const char xen_hypervisor_callback[];
31805 extern const char xen_failsafe_callback[];
31806
31807 -extern void *xen_initial_gdt;
31808 -
31809 struct trap_info;
31810 void xen_copy_trap_info(struct trap_info *traps);
31811
31812 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31813 index 525bd3d..ef888b1 100644
31814 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31815 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31816 @@ -119,9 +119,9 @@
31817 ----------------------------------------------------------------------*/
31818
31819 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31820 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31821 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31822 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31823 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31824
31825 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31826 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31827 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31828 index 2f33760..835e50a 100644
31829 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31830 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31831 @@ -11,6 +11,7 @@
31832 #ifndef _XTENSA_CORE_H
31833 #define _XTENSA_CORE_H
31834
31835 +#include <linux/const.h>
31836
31837 /****************************************************************************
31838 Parameters Useful for Any Code, USER or PRIVILEGED
31839 @@ -112,9 +113,9 @@
31840 ----------------------------------------------------------------------*/
31841
31842 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31843 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31844 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31845 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31846 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31847
31848 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31849 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31850 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31851 index af00795..2bb8105 100644
31852 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31853 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31854 @@ -11,6 +11,7 @@
31855 #ifndef _XTENSA_CORE_CONFIGURATION_H
31856 #define _XTENSA_CORE_CONFIGURATION_H
31857
31858 +#include <linux/const.h>
31859
31860 /****************************************************************************
31861 Parameters Useful for Any Code, USER or PRIVILEGED
31862 @@ -118,9 +119,9 @@
31863 ----------------------------------------------------------------------*/
31864
31865 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31866 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31867 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31868 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31869 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31870
31871 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31872 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31873 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31874 index 58916af..eb9dbcf6 100644
31875 --- a/block/blk-iopoll.c
31876 +++ b/block/blk-iopoll.c
31877 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31878 }
31879 EXPORT_SYMBOL(blk_iopoll_complete);
31880
31881 -static void blk_iopoll_softirq(struct softirq_action *h)
31882 +static void blk_iopoll_softirq(void)
31883 {
31884 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31885 int rearm = 0, budget = blk_iopoll_budget;
31886 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31887 return NOTIFY_OK;
31888 }
31889
31890 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31891 +static struct notifier_block blk_iopoll_cpu_notifier = {
31892 .notifier_call = blk_iopoll_cpu_notify,
31893 };
31894
31895 diff --git a/block/blk-map.c b/block/blk-map.c
31896 index 623e1cd..ca1e109 100644
31897 --- a/block/blk-map.c
31898 +++ b/block/blk-map.c
31899 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31900 if (!len || !kbuf)
31901 return -EINVAL;
31902
31903 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31904 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31905 if (do_copy)
31906 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31907 else
31908 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31909 index 467c8de..f3628c5 100644
31910 --- a/block/blk-softirq.c
31911 +++ b/block/blk-softirq.c
31912 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31913 * Softirq action handler - move entries to local list and loop over them
31914 * while passing them to the queue registered handler.
31915 */
31916 -static void blk_done_softirq(struct softirq_action *h)
31917 +static void blk_done_softirq(void)
31918 {
31919 struct list_head *cpu_list, local_list;
31920
31921 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31922 return NOTIFY_OK;
31923 }
31924
31925 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31926 +static struct notifier_block blk_cpu_notifier = {
31927 .notifier_call = blk_cpu_notify,
31928 };
31929
31930 diff --git a/block/bsg.c b/block/bsg.c
31931 index ff64ae3..593560c 100644
31932 --- a/block/bsg.c
31933 +++ b/block/bsg.c
31934 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31935 struct sg_io_v4 *hdr, struct bsg_device *bd,
31936 fmode_t has_write_perm)
31937 {
31938 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31939 + unsigned char *cmdptr;
31940 +
31941 if (hdr->request_len > BLK_MAX_CDB) {
31942 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31943 if (!rq->cmd)
31944 return -ENOMEM;
31945 - }
31946 + cmdptr = rq->cmd;
31947 + } else
31948 + cmdptr = tmpcmd;
31949
31950 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31951 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31952 hdr->request_len))
31953 return -EFAULT;
31954
31955 + if (cmdptr != rq->cmd)
31956 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31957 +
31958 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31959 if (blk_verify_command(rq->cmd, has_write_perm))
31960 return -EPERM;
31961 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31962 index 7c668c8..db3521c 100644
31963 --- a/block/compat_ioctl.c
31964 +++ b/block/compat_ioctl.c
31965 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31966 err |= __get_user(f->spec1, &uf->spec1);
31967 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31968 err |= __get_user(name, &uf->name);
31969 - f->name = compat_ptr(name);
31970 + f->name = (void __force_kernel *)compat_ptr(name);
31971 if (err) {
31972 err = -EFAULT;
31973 goto out;
31974 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31975 index b62fb88..bdab4c4 100644
31976 --- a/block/partitions/efi.c
31977 +++ b/block/partitions/efi.c
31978 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31979 if (!gpt)
31980 return NULL;
31981
31982 + if (!le32_to_cpu(gpt->num_partition_entries))
31983 + return NULL;
31984 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31985 + if (!pte)
31986 + return NULL;
31987 +
31988 count = le32_to_cpu(gpt->num_partition_entries) *
31989 le32_to_cpu(gpt->sizeof_partition_entry);
31990 - if (!count)
31991 - return NULL;
31992 - pte = kzalloc(count, GFP_KERNEL);
31993 - if (!pte)
31994 - return NULL;
31995 -
31996 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31997 (u8 *) pte,
31998 count) < count) {
31999 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
32000 index 9a87daa..fb17486 100644
32001 --- a/block/scsi_ioctl.c
32002 +++ b/block/scsi_ioctl.c
32003 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
32004 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
32005 struct sg_io_hdr *hdr, fmode_t mode)
32006 {
32007 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
32008 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32009 + unsigned char *cmdptr;
32010 +
32011 + if (rq->cmd != rq->__cmd)
32012 + cmdptr = rq->cmd;
32013 + else
32014 + cmdptr = tmpcmd;
32015 +
32016 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
32017 return -EFAULT;
32018 +
32019 + if (cmdptr != rq->cmd)
32020 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
32021 +
32022 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
32023 return -EPERM;
32024
32025 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32026 int err;
32027 unsigned int in_len, out_len, bytes, opcode, cmdlen;
32028 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
32029 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32030 + unsigned char *cmdptr;
32031
32032 if (!sic)
32033 return -EINVAL;
32034 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32035 */
32036 err = -EFAULT;
32037 rq->cmd_len = cmdlen;
32038 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
32039 +
32040 + if (rq->cmd != rq->__cmd)
32041 + cmdptr = rq->cmd;
32042 + else
32043 + cmdptr = tmpcmd;
32044 +
32045 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32046 goto error;
32047
32048 + if (rq->cmd != cmdptr)
32049 + memcpy(rq->cmd, cmdptr, cmdlen);
32050 +
32051 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32052 goto error;
32053
32054 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32055 index 7bdd61b..afec999 100644
32056 --- a/crypto/cryptd.c
32057 +++ b/crypto/cryptd.c
32058 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32059
32060 struct cryptd_blkcipher_request_ctx {
32061 crypto_completion_t complete;
32062 -};
32063 +} __no_const;
32064
32065 struct cryptd_hash_ctx {
32066 struct crypto_shash *child;
32067 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32068
32069 struct cryptd_aead_request_ctx {
32070 crypto_completion_t complete;
32071 -};
32072 +} __no_const;
32073
32074 static void cryptd_queue_worker(struct work_struct *work);
32075
32076 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32077 index f6d9baf..dfd511f 100644
32078 --- a/crypto/crypto_user.c
32079 +++ b/crypto/crypto_user.c
32080 @@ -30,6 +30,8 @@
32081
32082 #include "internal.h"
32083
32084 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32085 +
32086 static DEFINE_MUTEX(crypto_cfg_mutex);
32087
32088 /* The crypto netlink socket */
32089 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32090 struct crypto_dump_info info;
32091 int err;
32092
32093 - if (!p->cru_driver_name)
32094 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32095 + return -EINVAL;
32096 +
32097 + if (!p->cru_driver_name[0])
32098 return -EINVAL;
32099
32100 alg = crypto_alg_match(p, 1);
32101 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32102 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32103 LIST_HEAD(list);
32104
32105 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32106 + return -EINVAL;
32107 +
32108 if (priority && !strlen(p->cru_driver_name))
32109 return -EINVAL;
32110
32111 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32112 struct crypto_alg *alg;
32113 struct crypto_user_alg *p = nlmsg_data(nlh);
32114
32115 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32116 + return -EINVAL;
32117 +
32118 alg = crypto_alg_match(p, 1);
32119 if (!alg)
32120 return -ENOENT;
32121 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32122 struct crypto_user_alg *p = nlmsg_data(nlh);
32123 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32124
32125 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32126 + return -EINVAL;
32127 +
32128 if (strlen(p->cru_driver_name))
32129 exact = 1;
32130
32131 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32132 index f220d64..d359ad6 100644
32133 --- a/drivers/acpi/apei/apei-internal.h
32134 +++ b/drivers/acpi/apei/apei-internal.h
32135 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32136 struct apei_exec_ins_type {
32137 u32 flags;
32138 apei_exec_ins_func_t run;
32139 -};
32140 +} __do_const;
32141
32142 struct apei_exec_context {
32143 u32 ip;
32144 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32145 index e6defd8..c26a225 100644
32146 --- a/drivers/acpi/apei/cper.c
32147 +++ b/drivers/acpi/apei/cper.c
32148 @@ -38,12 +38,12 @@
32149 */
32150 u64 cper_next_record_id(void)
32151 {
32152 - static atomic64_t seq;
32153 + static atomic64_unchecked_t seq;
32154
32155 - if (!atomic64_read(&seq))
32156 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32157 + if (!atomic64_read_unchecked(&seq))
32158 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32159
32160 - return atomic64_inc_return(&seq);
32161 + return atomic64_inc_return_unchecked(&seq);
32162 }
32163 EXPORT_SYMBOL_GPL(cper_next_record_id);
32164
32165 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32166 index be60399..778b33e8 100644
32167 --- a/drivers/acpi/bgrt.c
32168 +++ b/drivers/acpi/bgrt.c
32169 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32170 return -ENODEV;
32171
32172 sysfs_bin_attr_init(&image_attr);
32173 - image_attr.private = bgrt_image;
32174 - image_attr.size = bgrt_image_size;
32175 + pax_open_kernel();
32176 + *(void **)&image_attr.private = bgrt_image;
32177 + *(size_t *)&image_attr.size = bgrt_image_size;
32178 + pax_close_kernel();
32179
32180 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32181 if (!bgrt_kobj)
32182 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32183 index cb96296..b81293b 100644
32184 --- a/drivers/acpi/blacklist.c
32185 +++ b/drivers/acpi/blacklist.c
32186 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32187 u32 is_critical_error;
32188 };
32189
32190 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32191 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32192
32193 /*
32194 * POLICY: If *anything* doesn't work, put it on the blacklist.
32195 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32196 return 0;
32197 }
32198
32199 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32200 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32201 {
32202 .callback = dmi_disable_osi_vista,
32203 .ident = "Fujitsu Siemens",
32204 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32205 index 7586544..636a2f0 100644
32206 --- a/drivers/acpi/ec_sys.c
32207 +++ b/drivers/acpi/ec_sys.c
32208 @@ -12,6 +12,7 @@
32209 #include <linux/acpi.h>
32210 #include <linux/debugfs.h>
32211 #include <linux/module.h>
32212 +#include <linux/uaccess.h>
32213 #include "internal.h"
32214
32215 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32216 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32217 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32218 */
32219 unsigned int size = EC_SPACE_SIZE;
32220 - u8 *data = (u8 *) buf;
32221 + u8 data;
32222 loff_t init_off = *off;
32223 int err = 0;
32224
32225 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32226 size = count;
32227
32228 while (size) {
32229 - err = ec_read(*off, &data[*off - init_off]);
32230 + err = ec_read(*off, &data);
32231 if (err)
32232 return err;
32233 + if (put_user(data, &buf[*off - init_off]))
32234 + return -EFAULT;
32235 *off += 1;
32236 size--;
32237 }
32238 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32239
32240 unsigned int size = count;
32241 loff_t init_off = *off;
32242 - u8 *data = (u8 *) buf;
32243 int err = 0;
32244
32245 if (*off >= EC_SPACE_SIZE)
32246 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32247 }
32248
32249 while (size) {
32250 - u8 byte_write = data[*off - init_off];
32251 + u8 byte_write;
32252 + if (get_user(byte_write, &buf[*off - init_off]))
32253 + return -EFAULT;
32254 err = ec_write(*off, byte_write);
32255 if (err)
32256 return err;
32257 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32258 index e83311b..142b5cc 100644
32259 --- a/drivers/acpi/processor_driver.c
32260 +++ b/drivers/acpi/processor_driver.c
32261 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32262 return 0;
32263 #endif
32264
32265 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32266 + BUG_ON(pr->id >= nr_cpu_ids);
32267
32268 /*
32269 * Buggy BIOS check
32270 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32271 index ed9a1cc..f4a354c 100644
32272 --- a/drivers/acpi/processor_idle.c
32273 +++ b/drivers/acpi/processor_idle.c
32274 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32275 {
32276 int i, count = CPUIDLE_DRIVER_STATE_START;
32277 struct acpi_processor_cx *cx;
32278 - struct cpuidle_state *state;
32279 + cpuidle_state_no_const *state;
32280 struct cpuidle_driver *drv = &acpi_idle_driver;
32281
32282 if (!pr->flags.power_setup_done)
32283 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32284 index ea61ca9..3fdd70d 100644
32285 --- a/drivers/acpi/sysfs.c
32286 +++ b/drivers/acpi/sysfs.c
32287 @@ -420,11 +420,11 @@ static u32 num_counters;
32288 static struct attribute **all_attrs;
32289 static u32 acpi_gpe_count;
32290
32291 -static struct attribute_group interrupt_stats_attr_group = {
32292 +static attribute_group_no_const interrupt_stats_attr_group = {
32293 .name = "interrupts",
32294 };
32295
32296 -static struct kobj_attribute *counter_attrs;
32297 +static kobj_attribute_no_const *counter_attrs;
32298
32299 static void delete_gpe_attr_array(void)
32300 {
32301 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32302 index 6cd7805..07facb3 100644
32303 --- a/drivers/ata/libahci.c
32304 +++ b/drivers/ata/libahci.c
32305 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32306 }
32307 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32308
32309 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32310 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32311 struct ata_taskfile *tf, int is_cmd, u16 flags,
32312 unsigned long timeout_msec)
32313 {
32314 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32315 index 501c209..5f28b4d 100644
32316 --- a/drivers/ata/libata-core.c
32317 +++ b/drivers/ata/libata-core.c
32318 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32319 struct ata_port *ap;
32320 unsigned int tag;
32321
32322 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32323 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32324 ap = qc->ap;
32325
32326 qc->flags = 0;
32327 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32328 struct ata_port *ap;
32329 struct ata_link *link;
32330
32331 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32332 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32333 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32334 ap = qc->ap;
32335 link = qc->dev->link;
32336 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32337 return;
32338
32339 spin_lock(&lock);
32340 + pax_open_kernel();
32341
32342 for (cur = ops->inherits; cur; cur = cur->inherits) {
32343 void **inherit = (void **)cur;
32344 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32345 if (IS_ERR(*pp))
32346 *pp = NULL;
32347
32348 - ops->inherits = NULL;
32349 + *(struct ata_port_operations **)&ops->inherits = NULL;
32350
32351 + pax_close_kernel();
32352 spin_unlock(&lock);
32353 }
32354
32355 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32356 index 405022d..fb70e53 100644
32357 --- a/drivers/ata/pata_arasan_cf.c
32358 +++ b/drivers/ata/pata_arasan_cf.c
32359 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32360 /* Handle platform specific quirks */
32361 if (pdata->quirk) {
32362 if (pdata->quirk & CF_BROKEN_PIO) {
32363 - ap->ops->set_piomode = NULL;
32364 + pax_open_kernel();
32365 + *(void **)&ap->ops->set_piomode = NULL;
32366 + pax_close_kernel();
32367 ap->pio_mask = 0;
32368 }
32369 if (pdata->quirk & CF_BROKEN_MWDMA)
32370 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32371 index f9b983a..887b9d8 100644
32372 --- a/drivers/atm/adummy.c
32373 +++ b/drivers/atm/adummy.c
32374 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32375 vcc->pop(vcc, skb);
32376 else
32377 dev_kfree_skb_any(skb);
32378 - atomic_inc(&vcc->stats->tx);
32379 + atomic_inc_unchecked(&vcc->stats->tx);
32380
32381 return 0;
32382 }
32383 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32384 index 77a7480..05cde58 100644
32385 --- a/drivers/atm/ambassador.c
32386 +++ b/drivers/atm/ambassador.c
32387 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32388 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32389
32390 // VC layer stats
32391 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32392 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32393
32394 // free the descriptor
32395 kfree (tx_descr);
32396 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32397 dump_skb ("<<<", vc, skb);
32398
32399 // VC layer stats
32400 - atomic_inc(&atm_vcc->stats->rx);
32401 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32402 __net_timestamp(skb);
32403 // end of our responsibility
32404 atm_vcc->push (atm_vcc, skb);
32405 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32406 } else {
32407 PRINTK (KERN_INFO, "dropped over-size frame");
32408 // should we count this?
32409 - atomic_inc(&atm_vcc->stats->rx_drop);
32410 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32411 }
32412
32413 } else {
32414 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32415 }
32416
32417 if (check_area (skb->data, skb->len)) {
32418 - atomic_inc(&atm_vcc->stats->tx_err);
32419 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32420 return -ENOMEM; // ?
32421 }
32422
32423 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32424 index b22d71c..d6e1049 100644
32425 --- a/drivers/atm/atmtcp.c
32426 +++ b/drivers/atm/atmtcp.c
32427 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32428 if (vcc->pop) vcc->pop(vcc,skb);
32429 else dev_kfree_skb(skb);
32430 if (dev_data) return 0;
32431 - atomic_inc(&vcc->stats->tx_err);
32432 + atomic_inc_unchecked(&vcc->stats->tx_err);
32433 return -ENOLINK;
32434 }
32435 size = skb->len+sizeof(struct atmtcp_hdr);
32436 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32437 if (!new_skb) {
32438 if (vcc->pop) vcc->pop(vcc,skb);
32439 else dev_kfree_skb(skb);
32440 - atomic_inc(&vcc->stats->tx_err);
32441 + atomic_inc_unchecked(&vcc->stats->tx_err);
32442 return -ENOBUFS;
32443 }
32444 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32445 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32446 if (vcc->pop) vcc->pop(vcc,skb);
32447 else dev_kfree_skb(skb);
32448 out_vcc->push(out_vcc,new_skb);
32449 - atomic_inc(&vcc->stats->tx);
32450 - atomic_inc(&out_vcc->stats->rx);
32451 + atomic_inc_unchecked(&vcc->stats->tx);
32452 + atomic_inc_unchecked(&out_vcc->stats->rx);
32453 return 0;
32454 }
32455
32456 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32457 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32458 read_unlock(&vcc_sklist_lock);
32459 if (!out_vcc) {
32460 - atomic_inc(&vcc->stats->tx_err);
32461 + atomic_inc_unchecked(&vcc->stats->tx_err);
32462 goto done;
32463 }
32464 skb_pull(skb,sizeof(struct atmtcp_hdr));
32465 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32466 __net_timestamp(new_skb);
32467 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32468 out_vcc->push(out_vcc,new_skb);
32469 - atomic_inc(&vcc->stats->tx);
32470 - atomic_inc(&out_vcc->stats->rx);
32471 + atomic_inc_unchecked(&vcc->stats->tx);
32472 + atomic_inc_unchecked(&out_vcc->stats->rx);
32473 done:
32474 if (vcc->pop) vcc->pop(vcc,skb);
32475 else dev_kfree_skb(skb);
32476 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32477 index c1eb6fa..4c71be9 100644
32478 --- a/drivers/atm/eni.c
32479 +++ b/drivers/atm/eni.c
32480 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32481 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32482 vcc->dev->number);
32483 length = 0;
32484 - atomic_inc(&vcc->stats->rx_err);
32485 + atomic_inc_unchecked(&vcc->stats->rx_err);
32486 }
32487 else {
32488 length = ATM_CELL_SIZE-1; /* no HEC */
32489 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32490 size);
32491 }
32492 eff = length = 0;
32493 - atomic_inc(&vcc->stats->rx_err);
32494 + atomic_inc_unchecked(&vcc->stats->rx_err);
32495 }
32496 else {
32497 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32498 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32499 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32500 vcc->dev->number,vcc->vci,length,size << 2,descr);
32501 length = eff = 0;
32502 - atomic_inc(&vcc->stats->rx_err);
32503 + atomic_inc_unchecked(&vcc->stats->rx_err);
32504 }
32505 }
32506 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32507 @@ -767,7 +767,7 @@ rx_dequeued++;
32508 vcc->push(vcc,skb);
32509 pushed++;
32510 }
32511 - atomic_inc(&vcc->stats->rx);
32512 + atomic_inc_unchecked(&vcc->stats->rx);
32513 }
32514 wake_up(&eni_dev->rx_wait);
32515 }
32516 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32517 PCI_DMA_TODEVICE);
32518 if (vcc->pop) vcc->pop(vcc,skb);
32519 else dev_kfree_skb_irq(skb);
32520 - atomic_inc(&vcc->stats->tx);
32521 + atomic_inc_unchecked(&vcc->stats->tx);
32522 wake_up(&eni_dev->tx_wait);
32523 dma_complete++;
32524 }
32525 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32526 index b41c948..a002b17 100644
32527 --- a/drivers/atm/firestream.c
32528 +++ b/drivers/atm/firestream.c
32529 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32530 }
32531 }
32532
32533 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32534 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32535
32536 fs_dprintk (FS_DEBUG_TXMEM, "i");
32537 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32538 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32539 #endif
32540 skb_put (skb, qe->p1 & 0xffff);
32541 ATM_SKB(skb)->vcc = atm_vcc;
32542 - atomic_inc(&atm_vcc->stats->rx);
32543 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32544 __net_timestamp(skb);
32545 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32546 atm_vcc->push (atm_vcc, skb);
32547 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32548 kfree (pe);
32549 }
32550 if (atm_vcc)
32551 - atomic_inc(&atm_vcc->stats->rx_drop);
32552 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32553 break;
32554 case 0x1f: /* Reassembly abort: no buffers. */
32555 /* Silently increment error counter. */
32556 if (atm_vcc)
32557 - atomic_inc(&atm_vcc->stats->rx_drop);
32558 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32559 break;
32560 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32561 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32562 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32563 index 204814e..cede831 100644
32564 --- a/drivers/atm/fore200e.c
32565 +++ b/drivers/atm/fore200e.c
32566 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32567 #endif
32568 /* check error condition */
32569 if (*entry->status & STATUS_ERROR)
32570 - atomic_inc(&vcc->stats->tx_err);
32571 + atomic_inc_unchecked(&vcc->stats->tx_err);
32572 else
32573 - atomic_inc(&vcc->stats->tx);
32574 + atomic_inc_unchecked(&vcc->stats->tx);
32575 }
32576 }
32577
32578 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32579 if (skb == NULL) {
32580 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32581
32582 - atomic_inc(&vcc->stats->rx_drop);
32583 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32584 return -ENOMEM;
32585 }
32586
32587 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32588
32589 dev_kfree_skb_any(skb);
32590
32591 - atomic_inc(&vcc->stats->rx_drop);
32592 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32593 return -ENOMEM;
32594 }
32595
32596 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32597
32598 vcc->push(vcc, skb);
32599 - atomic_inc(&vcc->stats->rx);
32600 + atomic_inc_unchecked(&vcc->stats->rx);
32601
32602 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32603
32604 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32605 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32606 fore200e->atm_dev->number,
32607 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32608 - atomic_inc(&vcc->stats->rx_err);
32609 + atomic_inc_unchecked(&vcc->stats->rx_err);
32610 }
32611 }
32612
32613 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32614 goto retry_here;
32615 }
32616
32617 - atomic_inc(&vcc->stats->tx_err);
32618 + atomic_inc_unchecked(&vcc->stats->tx_err);
32619
32620 fore200e->tx_sat++;
32621 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32622 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32623 index 72b6960..cf9167a 100644
32624 --- a/drivers/atm/he.c
32625 +++ b/drivers/atm/he.c
32626 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32627
32628 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32629 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32630 - atomic_inc(&vcc->stats->rx_drop);
32631 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32632 goto return_host_buffers;
32633 }
32634
32635 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32636 RBRQ_LEN_ERR(he_dev->rbrq_head)
32637 ? "LEN_ERR" : "",
32638 vcc->vpi, vcc->vci);
32639 - atomic_inc(&vcc->stats->rx_err);
32640 + atomic_inc_unchecked(&vcc->stats->rx_err);
32641 goto return_host_buffers;
32642 }
32643
32644 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32645 vcc->push(vcc, skb);
32646 spin_lock(&he_dev->global_lock);
32647
32648 - atomic_inc(&vcc->stats->rx);
32649 + atomic_inc_unchecked(&vcc->stats->rx);
32650
32651 return_host_buffers:
32652 ++pdus_assembled;
32653 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32654 tpd->vcc->pop(tpd->vcc, tpd->skb);
32655 else
32656 dev_kfree_skb_any(tpd->skb);
32657 - atomic_inc(&tpd->vcc->stats->tx_err);
32658 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32659 }
32660 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32661 return;
32662 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32663 vcc->pop(vcc, skb);
32664 else
32665 dev_kfree_skb_any(skb);
32666 - atomic_inc(&vcc->stats->tx_err);
32667 + atomic_inc_unchecked(&vcc->stats->tx_err);
32668 return -EINVAL;
32669 }
32670
32671 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32672 vcc->pop(vcc, skb);
32673 else
32674 dev_kfree_skb_any(skb);
32675 - atomic_inc(&vcc->stats->tx_err);
32676 + atomic_inc_unchecked(&vcc->stats->tx_err);
32677 return -EINVAL;
32678 }
32679 #endif
32680 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32681 vcc->pop(vcc, skb);
32682 else
32683 dev_kfree_skb_any(skb);
32684 - atomic_inc(&vcc->stats->tx_err);
32685 + atomic_inc_unchecked(&vcc->stats->tx_err);
32686 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32687 return -ENOMEM;
32688 }
32689 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32690 vcc->pop(vcc, skb);
32691 else
32692 dev_kfree_skb_any(skb);
32693 - atomic_inc(&vcc->stats->tx_err);
32694 + atomic_inc_unchecked(&vcc->stats->tx_err);
32695 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32696 return -ENOMEM;
32697 }
32698 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32699 __enqueue_tpd(he_dev, tpd, cid);
32700 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32701
32702 - atomic_inc(&vcc->stats->tx);
32703 + atomic_inc_unchecked(&vcc->stats->tx);
32704
32705 return 0;
32706 }
32707 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32708 index 1dc0519..1aadaf7 100644
32709 --- a/drivers/atm/horizon.c
32710 +++ b/drivers/atm/horizon.c
32711 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32712 {
32713 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32714 // VC layer stats
32715 - atomic_inc(&vcc->stats->rx);
32716 + atomic_inc_unchecked(&vcc->stats->rx);
32717 __net_timestamp(skb);
32718 // end of our responsibility
32719 vcc->push (vcc, skb);
32720 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32721 dev->tx_iovec = NULL;
32722
32723 // VC layer stats
32724 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32725 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32726
32727 // free the skb
32728 hrz_kfree_skb (skb);
32729 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32730 index 272f009..a18ba55 100644
32731 --- a/drivers/atm/idt77252.c
32732 +++ b/drivers/atm/idt77252.c
32733 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32734 else
32735 dev_kfree_skb(skb);
32736
32737 - atomic_inc(&vcc->stats->tx);
32738 + atomic_inc_unchecked(&vcc->stats->tx);
32739 }
32740
32741 atomic_dec(&scq->used);
32742 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32743 if ((sb = dev_alloc_skb(64)) == NULL) {
32744 printk("%s: Can't allocate buffers for aal0.\n",
32745 card->name);
32746 - atomic_add(i, &vcc->stats->rx_drop);
32747 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32748 break;
32749 }
32750 if (!atm_charge(vcc, sb->truesize)) {
32751 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32752 card->name);
32753 - atomic_add(i - 1, &vcc->stats->rx_drop);
32754 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32755 dev_kfree_skb(sb);
32756 break;
32757 }
32758 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32759 ATM_SKB(sb)->vcc = vcc;
32760 __net_timestamp(sb);
32761 vcc->push(vcc, sb);
32762 - atomic_inc(&vcc->stats->rx);
32763 + atomic_inc_unchecked(&vcc->stats->rx);
32764
32765 cell += ATM_CELL_PAYLOAD;
32766 }
32767 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32768 "(CDC: %08x)\n",
32769 card->name, len, rpp->len, readl(SAR_REG_CDC));
32770 recycle_rx_pool_skb(card, rpp);
32771 - atomic_inc(&vcc->stats->rx_err);
32772 + atomic_inc_unchecked(&vcc->stats->rx_err);
32773 return;
32774 }
32775 if (stat & SAR_RSQE_CRC) {
32776 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32777 recycle_rx_pool_skb(card, rpp);
32778 - atomic_inc(&vcc->stats->rx_err);
32779 + atomic_inc_unchecked(&vcc->stats->rx_err);
32780 return;
32781 }
32782 if (skb_queue_len(&rpp->queue) > 1) {
32783 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32784 RXPRINTK("%s: Can't alloc RX skb.\n",
32785 card->name);
32786 recycle_rx_pool_skb(card, rpp);
32787 - atomic_inc(&vcc->stats->rx_err);
32788 + atomic_inc_unchecked(&vcc->stats->rx_err);
32789 return;
32790 }
32791 if (!atm_charge(vcc, skb->truesize)) {
32792 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32793 __net_timestamp(skb);
32794
32795 vcc->push(vcc, skb);
32796 - atomic_inc(&vcc->stats->rx);
32797 + atomic_inc_unchecked(&vcc->stats->rx);
32798
32799 return;
32800 }
32801 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32802 __net_timestamp(skb);
32803
32804 vcc->push(vcc, skb);
32805 - atomic_inc(&vcc->stats->rx);
32806 + atomic_inc_unchecked(&vcc->stats->rx);
32807
32808 if (skb->truesize > SAR_FB_SIZE_3)
32809 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32810 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32811 if (vcc->qos.aal != ATM_AAL0) {
32812 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32813 card->name, vpi, vci);
32814 - atomic_inc(&vcc->stats->rx_drop);
32815 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32816 goto drop;
32817 }
32818
32819 if ((sb = dev_alloc_skb(64)) == NULL) {
32820 printk("%s: Can't allocate buffers for AAL0.\n",
32821 card->name);
32822 - atomic_inc(&vcc->stats->rx_err);
32823 + atomic_inc_unchecked(&vcc->stats->rx_err);
32824 goto drop;
32825 }
32826
32827 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32828 ATM_SKB(sb)->vcc = vcc;
32829 __net_timestamp(sb);
32830 vcc->push(vcc, sb);
32831 - atomic_inc(&vcc->stats->rx);
32832 + atomic_inc_unchecked(&vcc->stats->rx);
32833
32834 drop:
32835 skb_pull(queue, 64);
32836 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32837
32838 if (vc == NULL) {
32839 printk("%s: NULL connection in send().\n", card->name);
32840 - atomic_inc(&vcc->stats->tx_err);
32841 + atomic_inc_unchecked(&vcc->stats->tx_err);
32842 dev_kfree_skb(skb);
32843 return -EINVAL;
32844 }
32845 if (!test_bit(VCF_TX, &vc->flags)) {
32846 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32847 - atomic_inc(&vcc->stats->tx_err);
32848 + atomic_inc_unchecked(&vcc->stats->tx_err);
32849 dev_kfree_skb(skb);
32850 return -EINVAL;
32851 }
32852 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32853 break;
32854 default:
32855 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32856 - atomic_inc(&vcc->stats->tx_err);
32857 + atomic_inc_unchecked(&vcc->stats->tx_err);
32858 dev_kfree_skb(skb);
32859 return -EINVAL;
32860 }
32861
32862 if (skb_shinfo(skb)->nr_frags != 0) {
32863 printk("%s: No scatter-gather yet.\n", card->name);
32864 - atomic_inc(&vcc->stats->tx_err);
32865 + atomic_inc_unchecked(&vcc->stats->tx_err);
32866 dev_kfree_skb(skb);
32867 return -EINVAL;
32868 }
32869 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32870
32871 err = queue_skb(card, vc, skb, oam);
32872 if (err) {
32873 - atomic_inc(&vcc->stats->tx_err);
32874 + atomic_inc_unchecked(&vcc->stats->tx_err);
32875 dev_kfree_skb(skb);
32876 return err;
32877 }
32878 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32879 skb = dev_alloc_skb(64);
32880 if (!skb) {
32881 printk("%s: Out of memory in send_oam().\n", card->name);
32882 - atomic_inc(&vcc->stats->tx_err);
32883 + atomic_inc_unchecked(&vcc->stats->tx_err);
32884 return -ENOMEM;
32885 }
32886 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32887 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32888 index 4217f29..88f547a 100644
32889 --- a/drivers/atm/iphase.c
32890 +++ b/drivers/atm/iphase.c
32891 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32892 status = (u_short) (buf_desc_ptr->desc_mode);
32893 if (status & (RX_CER | RX_PTE | RX_OFL))
32894 {
32895 - atomic_inc(&vcc->stats->rx_err);
32896 + atomic_inc_unchecked(&vcc->stats->rx_err);
32897 IF_ERR(printk("IA: bad packet, dropping it");)
32898 if (status & RX_CER) {
32899 IF_ERR(printk(" cause: packet CRC error\n");)
32900 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32901 len = dma_addr - buf_addr;
32902 if (len > iadev->rx_buf_sz) {
32903 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32904 - atomic_inc(&vcc->stats->rx_err);
32905 + atomic_inc_unchecked(&vcc->stats->rx_err);
32906 goto out_free_desc;
32907 }
32908
32909 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32910 ia_vcc = INPH_IA_VCC(vcc);
32911 if (ia_vcc == NULL)
32912 {
32913 - atomic_inc(&vcc->stats->rx_err);
32914 + atomic_inc_unchecked(&vcc->stats->rx_err);
32915 atm_return(vcc, skb->truesize);
32916 dev_kfree_skb_any(skb);
32917 goto INCR_DLE;
32918 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32919 if ((length > iadev->rx_buf_sz) || (length >
32920 (skb->len - sizeof(struct cpcs_trailer))))
32921 {
32922 - atomic_inc(&vcc->stats->rx_err);
32923 + atomic_inc_unchecked(&vcc->stats->rx_err);
32924 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32925 length, skb->len);)
32926 atm_return(vcc, skb->truesize);
32927 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32928
32929 IF_RX(printk("rx_dle_intr: skb push");)
32930 vcc->push(vcc,skb);
32931 - atomic_inc(&vcc->stats->rx);
32932 + atomic_inc_unchecked(&vcc->stats->rx);
32933 iadev->rx_pkt_cnt++;
32934 }
32935 INCR_DLE:
32936 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32937 {
32938 struct k_sonet_stats *stats;
32939 stats = &PRIV(_ia_dev[board])->sonet_stats;
32940 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32941 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32942 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32943 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32944 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32945 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32946 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32947 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32948 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32949 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32950 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32951 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32952 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32953 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32954 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32955 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32956 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32957 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32958 }
32959 ia_cmds.status = 0;
32960 break;
32961 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32962 if ((desc == 0) || (desc > iadev->num_tx_desc))
32963 {
32964 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32965 - atomic_inc(&vcc->stats->tx);
32966 + atomic_inc_unchecked(&vcc->stats->tx);
32967 if (vcc->pop)
32968 vcc->pop(vcc, skb);
32969 else
32970 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32971 ATM_DESC(skb) = vcc->vci;
32972 skb_queue_tail(&iadev->tx_dma_q, skb);
32973
32974 - atomic_inc(&vcc->stats->tx);
32975 + atomic_inc_unchecked(&vcc->stats->tx);
32976 iadev->tx_pkt_cnt++;
32977 /* Increment transaction counter */
32978 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32979
32980 #if 0
32981 /* add flow control logic */
32982 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32983 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32984 if (iavcc->vc_desc_cnt > 10) {
32985 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32986 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32987 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32988 index fa7d701..1e404c7 100644
32989 --- a/drivers/atm/lanai.c
32990 +++ b/drivers/atm/lanai.c
32991 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32992 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32993 lanai_endtx(lanai, lvcc);
32994 lanai_free_skb(lvcc->tx.atmvcc, skb);
32995 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32996 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32997 }
32998
32999 /* Try to fill the buffer - don't call unless there is backlog */
33000 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
33001 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
33002 __net_timestamp(skb);
33003 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
33004 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
33005 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
33006 out:
33007 lvcc->rx.buf.ptr = end;
33008 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
33009 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33010 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
33011 "vcc %d\n", lanai->number, (unsigned int) s, vci);
33012 lanai->stats.service_rxnotaal5++;
33013 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33014 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33015 return 0;
33016 }
33017 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
33018 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33019 int bytes;
33020 read_unlock(&vcc_sklist_lock);
33021 DPRINTK("got trashed rx pdu on vci %d\n", vci);
33022 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33023 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33024 lvcc->stats.x.aal5.service_trash++;
33025 bytes = (SERVICE_GET_END(s) * 16) -
33026 (((unsigned long) lvcc->rx.buf.ptr) -
33027 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33028 }
33029 if (s & SERVICE_STREAM) {
33030 read_unlock(&vcc_sklist_lock);
33031 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33032 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33033 lvcc->stats.x.aal5.service_stream++;
33034 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
33035 "PDU on VCI %d!\n", lanai->number, vci);
33036 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33037 return 0;
33038 }
33039 DPRINTK("got rx crc error on vci %d\n", vci);
33040 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33041 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33042 lvcc->stats.x.aal5.service_rxcrc++;
33043 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33044 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33045 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33046 index ed1d2b7..8cffc1f 100644
33047 --- a/drivers/atm/nicstar.c
33048 +++ b/drivers/atm/nicstar.c
33049 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33050 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33051 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33052 card->index);
33053 - atomic_inc(&vcc->stats->tx_err);
33054 + atomic_inc_unchecked(&vcc->stats->tx_err);
33055 dev_kfree_skb_any(skb);
33056 return -EINVAL;
33057 }
33058 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33059 if (!vc->tx) {
33060 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33061 card->index);
33062 - atomic_inc(&vcc->stats->tx_err);
33063 + atomic_inc_unchecked(&vcc->stats->tx_err);
33064 dev_kfree_skb_any(skb);
33065 return -EINVAL;
33066 }
33067 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33068 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33069 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33070 card->index);
33071 - atomic_inc(&vcc->stats->tx_err);
33072 + atomic_inc_unchecked(&vcc->stats->tx_err);
33073 dev_kfree_skb_any(skb);
33074 return -EINVAL;
33075 }
33076
33077 if (skb_shinfo(skb)->nr_frags != 0) {
33078 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33079 - atomic_inc(&vcc->stats->tx_err);
33080 + atomic_inc_unchecked(&vcc->stats->tx_err);
33081 dev_kfree_skb_any(skb);
33082 return -EINVAL;
33083 }
33084 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33085 }
33086
33087 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33088 - atomic_inc(&vcc->stats->tx_err);
33089 + atomic_inc_unchecked(&vcc->stats->tx_err);
33090 dev_kfree_skb_any(skb);
33091 return -EIO;
33092 }
33093 - atomic_inc(&vcc->stats->tx);
33094 + atomic_inc_unchecked(&vcc->stats->tx);
33095
33096 return 0;
33097 }
33098 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33099 printk
33100 ("nicstar%d: Can't allocate buffers for aal0.\n",
33101 card->index);
33102 - atomic_add(i, &vcc->stats->rx_drop);
33103 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33104 break;
33105 }
33106 if (!atm_charge(vcc, sb->truesize)) {
33107 RXPRINTK
33108 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33109 card->index);
33110 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33111 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33112 dev_kfree_skb_any(sb);
33113 break;
33114 }
33115 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33116 ATM_SKB(sb)->vcc = vcc;
33117 __net_timestamp(sb);
33118 vcc->push(vcc, sb);
33119 - atomic_inc(&vcc->stats->rx);
33120 + atomic_inc_unchecked(&vcc->stats->rx);
33121 cell += ATM_CELL_PAYLOAD;
33122 }
33123
33124 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33125 if (iovb == NULL) {
33126 printk("nicstar%d: Out of iovec buffers.\n",
33127 card->index);
33128 - atomic_inc(&vcc->stats->rx_drop);
33129 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33130 recycle_rx_buf(card, skb);
33131 return;
33132 }
33133 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33134 small or large buffer itself. */
33135 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33136 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33137 - atomic_inc(&vcc->stats->rx_err);
33138 + atomic_inc_unchecked(&vcc->stats->rx_err);
33139 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33140 NS_MAX_IOVECS);
33141 NS_PRV_IOVCNT(iovb) = 0;
33142 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33143 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33144 card->index);
33145 which_list(card, skb);
33146 - atomic_inc(&vcc->stats->rx_err);
33147 + atomic_inc_unchecked(&vcc->stats->rx_err);
33148 recycle_rx_buf(card, skb);
33149 vc->rx_iov = NULL;
33150 recycle_iov_buf(card, iovb);
33151 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33152 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33153 card->index);
33154 which_list(card, skb);
33155 - atomic_inc(&vcc->stats->rx_err);
33156 + atomic_inc_unchecked(&vcc->stats->rx_err);
33157 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33158 NS_PRV_IOVCNT(iovb));
33159 vc->rx_iov = NULL;
33160 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33161 printk(" - PDU size mismatch.\n");
33162 else
33163 printk(".\n");
33164 - atomic_inc(&vcc->stats->rx_err);
33165 + atomic_inc_unchecked(&vcc->stats->rx_err);
33166 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33167 NS_PRV_IOVCNT(iovb));
33168 vc->rx_iov = NULL;
33169 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33170 /* skb points to a small buffer */
33171 if (!atm_charge(vcc, skb->truesize)) {
33172 push_rxbufs(card, skb);
33173 - atomic_inc(&vcc->stats->rx_drop);
33174 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33175 } else {
33176 skb_put(skb, len);
33177 dequeue_sm_buf(card, skb);
33178 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33179 ATM_SKB(skb)->vcc = vcc;
33180 __net_timestamp(skb);
33181 vcc->push(vcc, skb);
33182 - atomic_inc(&vcc->stats->rx);
33183 + atomic_inc_unchecked(&vcc->stats->rx);
33184 }
33185 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33186 struct sk_buff *sb;
33187 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33188 if (len <= NS_SMBUFSIZE) {
33189 if (!atm_charge(vcc, sb->truesize)) {
33190 push_rxbufs(card, sb);
33191 - atomic_inc(&vcc->stats->rx_drop);
33192 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33193 } else {
33194 skb_put(sb, len);
33195 dequeue_sm_buf(card, sb);
33196 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33197 ATM_SKB(sb)->vcc = vcc;
33198 __net_timestamp(sb);
33199 vcc->push(vcc, sb);
33200 - atomic_inc(&vcc->stats->rx);
33201 + atomic_inc_unchecked(&vcc->stats->rx);
33202 }
33203
33204 push_rxbufs(card, skb);
33205 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33206
33207 if (!atm_charge(vcc, skb->truesize)) {
33208 push_rxbufs(card, skb);
33209 - atomic_inc(&vcc->stats->rx_drop);
33210 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33211 } else {
33212 dequeue_lg_buf(card, skb);
33213 #ifdef NS_USE_DESTRUCTORS
33214 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33215 ATM_SKB(skb)->vcc = vcc;
33216 __net_timestamp(skb);
33217 vcc->push(vcc, skb);
33218 - atomic_inc(&vcc->stats->rx);
33219 + atomic_inc_unchecked(&vcc->stats->rx);
33220 }
33221
33222 push_rxbufs(card, sb);
33223 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33224 printk
33225 ("nicstar%d: Out of huge buffers.\n",
33226 card->index);
33227 - atomic_inc(&vcc->stats->rx_drop);
33228 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33229 recycle_iovec_rx_bufs(card,
33230 (struct iovec *)
33231 iovb->data,
33232 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33233 card->hbpool.count++;
33234 } else
33235 dev_kfree_skb_any(hb);
33236 - atomic_inc(&vcc->stats->rx_drop);
33237 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33238 } else {
33239 /* Copy the small buffer to the huge buffer */
33240 sb = (struct sk_buff *)iov->iov_base;
33241 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33242 #endif /* NS_USE_DESTRUCTORS */
33243 __net_timestamp(hb);
33244 vcc->push(vcc, hb);
33245 - atomic_inc(&vcc->stats->rx);
33246 + atomic_inc_unchecked(&vcc->stats->rx);
33247 }
33248 }
33249
33250 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33251 index 0474a89..06ea4a1 100644
33252 --- a/drivers/atm/solos-pci.c
33253 +++ b/drivers/atm/solos-pci.c
33254 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33255 }
33256 atm_charge(vcc, skb->truesize);
33257 vcc->push(vcc, skb);
33258 - atomic_inc(&vcc->stats->rx);
33259 + atomic_inc_unchecked(&vcc->stats->rx);
33260 break;
33261
33262 case PKT_STATUS:
33263 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33264 vcc = SKB_CB(oldskb)->vcc;
33265
33266 if (vcc) {
33267 - atomic_inc(&vcc->stats->tx);
33268 + atomic_inc_unchecked(&vcc->stats->tx);
33269 solos_pop(vcc, oldskb);
33270 } else {
33271 dev_kfree_skb_irq(oldskb);
33272 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33273 index 0215934..ce9f5b1 100644
33274 --- a/drivers/atm/suni.c
33275 +++ b/drivers/atm/suni.c
33276 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33277
33278
33279 #define ADD_LIMITED(s,v) \
33280 - atomic_add((v),&stats->s); \
33281 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33282 + atomic_add_unchecked((v),&stats->s); \
33283 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33284
33285
33286 static void suni_hz(unsigned long from_timer)
33287 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33288 index 5120a96..e2572bd 100644
33289 --- a/drivers/atm/uPD98402.c
33290 +++ b/drivers/atm/uPD98402.c
33291 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33292 struct sonet_stats tmp;
33293 int error = 0;
33294
33295 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33296 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33297 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33298 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33299 if (zero && !error) {
33300 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33301
33302
33303 #define ADD_LIMITED(s,v) \
33304 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33305 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33306 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33307 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33308 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33309 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33310
33311
33312 static void stat_event(struct atm_dev *dev)
33313 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33314 if (reason & uPD98402_INT_PFM) stat_event(dev);
33315 if (reason & uPD98402_INT_PCO) {
33316 (void) GET(PCOCR); /* clear interrupt cause */
33317 - atomic_add(GET(HECCT),
33318 + atomic_add_unchecked(GET(HECCT),
33319 &PRIV(dev)->sonet_stats.uncorr_hcs);
33320 }
33321 if ((reason & uPD98402_INT_RFO) &&
33322 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33323 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33324 uPD98402_INT_LOS),PIMR); /* enable them */
33325 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33326 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33327 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33328 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33329 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33330 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33331 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33332 return 0;
33333 }
33334
33335 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33336 index 969c3c2..9b72956 100644
33337 --- a/drivers/atm/zatm.c
33338 +++ b/drivers/atm/zatm.c
33339 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33340 }
33341 if (!size) {
33342 dev_kfree_skb_irq(skb);
33343 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33344 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33345 continue;
33346 }
33347 if (!atm_charge(vcc,skb->truesize)) {
33348 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33349 skb->len = size;
33350 ATM_SKB(skb)->vcc = vcc;
33351 vcc->push(vcc,skb);
33352 - atomic_inc(&vcc->stats->rx);
33353 + atomic_inc_unchecked(&vcc->stats->rx);
33354 }
33355 zout(pos & 0xffff,MTA(mbx));
33356 #if 0 /* probably a stupid idea */
33357 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33358 skb_queue_head(&zatm_vcc->backlog,skb);
33359 break;
33360 }
33361 - atomic_inc(&vcc->stats->tx);
33362 + atomic_inc_unchecked(&vcc->stats->tx);
33363 wake_up(&zatm_vcc->tx_wait);
33364 }
33365
33366 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33367 index 6856303..0602d70 100644
33368 --- a/drivers/base/bus.c
33369 +++ b/drivers/base/bus.c
33370 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33371 return -EINVAL;
33372
33373 mutex_lock(&subsys->p->mutex);
33374 - list_add_tail(&sif->node, &subsys->p->interfaces);
33375 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33376 if (sif->add_dev) {
33377 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33378 while ((dev = subsys_dev_iter_next(&iter)))
33379 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33380 subsys = sif->subsys;
33381
33382 mutex_lock(&subsys->p->mutex);
33383 - list_del_init(&sif->node);
33384 + pax_list_del_init((struct list_head *)&sif->node);
33385 if (sif->remove_dev) {
33386 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33387 while ((dev = subsys_dev_iter_next(&iter)))
33388 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33389 index 17cf7ca..7e553e1 100644
33390 --- a/drivers/base/devtmpfs.c
33391 +++ b/drivers/base/devtmpfs.c
33392 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33393 if (!thread)
33394 return 0;
33395
33396 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33397 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33398 if (err)
33399 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33400 else
33401 diff --git a/drivers/base/node.c b/drivers/base/node.c
33402 index fac124a..66bd4ab 100644
33403 --- a/drivers/base/node.c
33404 +++ b/drivers/base/node.c
33405 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33406 struct node_attr {
33407 struct device_attribute attr;
33408 enum node_states state;
33409 -};
33410 +} __do_const;
33411
33412 static ssize_t show_node_state(struct device *dev,
33413 struct device_attribute *attr, char *buf)
33414 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33415 index acc3a8d..981c236 100644
33416 --- a/drivers/base/power/domain.c
33417 +++ b/drivers/base/power/domain.c
33418 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33419 {
33420 struct cpuidle_driver *cpuidle_drv;
33421 struct gpd_cpu_data *cpu_data;
33422 - struct cpuidle_state *idle_state;
33423 + cpuidle_state_no_const *idle_state;
33424 int ret = 0;
33425
33426 if (IS_ERR_OR_NULL(genpd) || state < 0)
33427 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33428 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33429 {
33430 struct gpd_cpu_data *cpu_data;
33431 - struct cpuidle_state *idle_state;
33432 + cpuidle_state_no_const *idle_state;
33433 int ret = 0;
33434
33435 if (IS_ERR_OR_NULL(genpd))
33436 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33437 index e6ee5e8..98ad7fc 100644
33438 --- a/drivers/base/power/wakeup.c
33439 +++ b/drivers/base/power/wakeup.c
33440 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33441 * They need to be modified together atomically, so it's better to use one
33442 * atomic variable to hold them both.
33443 */
33444 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33445 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33446
33447 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33448 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33449
33450 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33451 {
33452 - unsigned int comb = atomic_read(&combined_event_count);
33453 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33454
33455 *cnt = (comb >> IN_PROGRESS_BITS);
33456 *inpr = comb & MAX_IN_PROGRESS;
33457 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33458 ws->start_prevent_time = ws->last_time;
33459
33460 /* Increment the counter of events in progress. */
33461 - cec = atomic_inc_return(&combined_event_count);
33462 + cec = atomic_inc_return_unchecked(&combined_event_count);
33463
33464 trace_wakeup_source_activate(ws->name, cec);
33465 }
33466 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33467 * Increment the counter of registered wakeup events and decrement the
33468 * couter of wakeup events in progress simultaneously.
33469 */
33470 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33471 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33472 trace_wakeup_source_deactivate(ws->name, cec);
33473
33474 split_counters(&cnt, &inpr);
33475 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33476 index e8d11b6..7b1b36f 100644
33477 --- a/drivers/base/syscore.c
33478 +++ b/drivers/base/syscore.c
33479 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33480 void register_syscore_ops(struct syscore_ops *ops)
33481 {
33482 mutex_lock(&syscore_ops_lock);
33483 - list_add_tail(&ops->node, &syscore_ops_list);
33484 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33485 mutex_unlock(&syscore_ops_lock);
33486 }
33487 EXPORT_SYMBOL_GPL(register_syscore_ops);
33488 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33489 void unregister_syscore_ops(struct syscore_ops *ops)
33490 {
33491 mutex_lock(&syscore_ops_lock);
33492 - list_del(&ops->node);
33493 + pax_list_del((struct list_head *)&ops->node);
33494 mutex_unlock(&syscore_ops_lock);
33495 }
33496 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33497 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33498 index ade58bc..867143d 100644
33499 --- a/drivers/block/cciss.c
33500 +++ b/drivers/block/cciss.c
33501 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33502 int err;
33503 u32 cp;
33504
33505 + memset(&arg64, 0, sizeof(arg64));
33506 +
33507 err = 0;
33508 err |=
33509 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33510 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33511 while (!list_empty(&h->reqQ)) {
33512 c = list_entry(h->reqQ.next, CommandList_struct, list);
33513 /* can't do anything if fifo is full */
33514 - if ((h->access.fifo_full(h))) {
33515 + if ((h->access->fifo_full(h))) {
33516 dev_warn(&h->pdev->dev, "fifo full\n");
33517 break;
33518 }
33519 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33520 h->Qdepth--;
33521
33522 /* Tell the controller execute command */
33523 - h->access.submit_command(h, c);
33524 + h->access->submit_command(h, c);
33525
33526 /* Put job onto the completed Q */
33527 addQ(&h->cmpQ, c);
33528 @@ -3441,17 +3443,17 @@ startio:
33529
33530 static inline unsigned long get_next_completion(ctlr_info_t *h)
33531 {
33532 - return h->access.command_completed(h);
33533 + return h->access->command_completed(h);
33534 }
33535
33536 static inline int interrupt_pending(ctlr_info_t *h)
33537 {
33538 - return h->access.intr_pending(h);
33539 + return h->access->intr_pending(h);
33540 }
33541
33542 static inline long interrupt_not_for_us(ctlr_info_t *h)
33543 {
33544 - return ((h->access.intr_pending(h) == 0) ||
33545 + return ((h->access->intr_pending(h) == 0) ||
33546 (h->interrupts_enabled == 0));
33547 }
33548
33549 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33550 u32 a;
33551
33552 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33553 - return h->access.command_completed(h);
33554 + return h->access->command_completed(h);
33555
33556 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33557 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33558 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33559 trans_support & CFGTBL_Trans_use_short_tags);
33560
33561 /* Change the access methods to the performant access methods */
33562 - h->access = SA5_performant_access;
33563 + h->access = &SA5_performant_access;
33564 h->transMethod = CFGTBL_Trans_Performant;
33565
33566 return;
33567 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33568 if (prod_index < 0)
33569 return -ENODEV;
33570 h->product_name = products[prod_index].product_name;
33571 - h->access = *(products[prod_index].access);
33572 + h->access = products[prod_index].access;
33573
33574 if (cciss_board_disabled(h)) {
33575 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33576 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33577 }
33578
33579 /* make sure the board interrupts are off */
33580 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33581 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33582 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33583 if (rc)
33584 goto clean2;
33585 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33586 * fake ones to scoop up any residual completions.
33587 */
33588 spin_lock_irqsave(&h->lock, flags);
33589 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33590 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33591 spin_unlock_irqrestore(&h->lock, flags);
33592 free_irq(h->intr[h->intr_mode], h);
33593 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33594 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33595 dev_info(&h->pdev->dev, "Board READY.\n");
33596 dev_info(&h->pdev->dev,
33597 "Waiting for stale completions to drain.\n");
33598 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33599 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33600 msleep(10000);
33601 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33602 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33603
33604 rc = controller_reset_failed(h->cfgtable);
33605 if (rc)
33606 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33607 cciss_scsi_setup(h);
33608
33609 /* Turn the interrupts on so we can service requests */
33610 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33611 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33612
33613 /* Get the firmware version */
33614 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33615 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33616 kfree(flush_buf);
33617 if (return_code != IO_OK)
33618 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33619 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33620 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33621 free_irq(h->intr[h->intr_mode], h);
33622 }
33623
33624 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33625 index 7fda30e..eb5dfe0 100644
33626 --- a/drivers/block/cciss.h
33627 +++ b/drivers/block/cciss.h
33628 @@ -101,7 +101,7 @@ struct ctlr_info
33629 /* information about each logical volume */
33630 drive_info_struct *drv[CISS_MAX_LUN];
33631
33632 - struct access_method access;
33633 + struct access_method *access;
33634
33635 /* queue and queue Info */
33636 struct list_head reqQ;
33637 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33638 index 3f08713..56a586a 100644
33639 --- a/drivers/block/cpqarray.c
33640 +++ b/drivers/block/cpqarray.c
33641 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33642 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33643 goto Enomem4;
33644 }
33645 - hba[i]->access.set_intr_mask(hba[i], 0);
33646 + hba[i]->access->set_intr_mask(hba[i], 0);
33647 if (request_irq(hba[i]->intr, do_ida_intr,
33648 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33649 {
33650 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33651 add_timer(&hba[i]->timer);
33652
33653 /* Enable IRQ now that spinlock and rate limit timer are set up */
33654 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33655 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33656
33657 for(j=0; j<NWD; j++) {
33658 struct gendisk *disk = ida_gendisk[i][j];
33659 @@ -694,7 +694,7 @@ DBGINFO(
33660 for(i=0; i<NR_PRODUCTS; i++) {
33661 if (board_id == products[i].board_id) {
33662 c->product_name = products[i].product_name;
33663 - c->access = *(products[i].access);
33664 + c->access = products[i].access;
33665 break;
33666 }
33667 }
33668 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33669 hba[ctlr]->intr = intr;
33670 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33671 hba[ctlr]->product_name = products[j].product_name;
33672 - hba[ctlr]->access = *(products[j].access);
33673 + hba[ctlr]->access = products[j].access;
33674 hba[ctlr]->ctlr = ctlr;
33675 hba[ctlr]->board_id = board_id;
33676 hba[ctlr]->pci_dev = NULL; /* not PCI */
33677 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33678
33679 while((c = h->reqQ) != NULL) {
33680 /* Can't do anything if we're busy */
33681 - if (h->access.fifo_full(h) == 0)
33682 + if (h->access->fifo_full(h) == 0)
33683 return;
33684
33685 /* Get the first entry from the request Q */
33686 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33687 h->Qdepth--;
33688
33689 /* Tell the controller to do our bidding */
33690 - h->access.submit_command(h, c);
33691 + h->access->submit_command(h, c);
33692
33693 /* Get onto the completion Q */
33694 addQ(&h->cmpQ, c);
33695 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33696 unsigned long flags;
33697 __u32 a,a1;
33698
33699 - istat = h->access.intr_pending(h);
33700 + istat = h->access->intr_pending(h);
33701 /* Is this interrupt for us? */
33702 if (istat == 0)
33703 return IRQ_NONE;
33704 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33705 */
33706 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33707 if (istat & FIFO_NOT_EMPTY) {
33708 - while((a = h->access.command_completed(h))) {
33709 + while((a = h->access->command_completed(h))) {
33710 a1 = a; a &= ~3;
33711 if ((c = h->cmpQ) == NULL)
33712 {
33713 @@ -1449,11 +1449,11 @@ static int sendcmd(
33714 /*
33715 * Disable interrupt
33716 */
33717 - info_p->access.set_intr_mask(info_p, 0);
33718 + info_p->access->set_intr_mask(info_p, 0);
33719 /* Make sure there is room in the command FIFO */
33720 /* Actually it should be completely empty at this time. */
33721 for (i = 200000; i > 0; i--) {
33722 - temp = info_p->access.fifo_full(info_p);
33723 + temp = info_p->access->fifo_full(info_p);
33724 if (temp != 0) {
33725 break;
33726 }
33727 @@ -1466,7 +1466,7 @@ DBG(
33728 /*
33729 * Send the cmd
33730 */
33731 - info_p->access.submit_command(info_p, c);
33732 + info_p->access->submit_command(info_p, c);
33733 complete = pollcomplete(ctlr);
33734
33735 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33736 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33737 * we check the new geometry. Then turn interrupts back on when
33738 * we're done.
33739 */
33740 - host->access.set_intr_mask(host, 0);
33741 + host->access->set_intr_mask(host, 0);
33742 getgeometry(ctlr);
33743 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33744 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33745
33746 for(i=0; i<NWD; i++) {
33747 struct gendisk *disk = ida_gendisk[ctlr][i];
33748 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33749 /* Wait (up to 2 seconds) for a command to complete */
33750
33751 for (i = 200000; i > 0; i--) {
33752 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33753 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33754 if (done == 0) {
33755 udelay(10); /* a short fixed delay */
33756 } else
33757 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33758 index be73e9d..7fbf140 100644
33759 --- a/drivers/block/cpqarray.h
33760 +++ b/drivers/block/cpqarray.h
33761 @@ -99,7 +99,7 @@ struct ctlr_info {
33762 drv_info_t drv[NWD];
33763 struct proc_dir_entry *proc;
33764
33765 - struct access_method access;
33766 + struct access_method *access;
33767
33768 cmdlist_t *reqQ;
33769 cmdlist_t *cmpQ;
33770 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33771 index 6b51afa..17e1191 100644
33772 --- a/drivers/block/drbd/drbd_int.h
33773 +++ b/drivers/block/drbd/drbd_int.h
33774 @@ -582,7 +582,7 @@ struct drbd_epoch {
33775 struct drbd_tconn *tconn;
33776 struct list_head list;
33777 unsigned int barrier_nr;
33778 - atomic_t epoch_size; /* increased on every request added. */
33779 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33780 atomic_t active; /* increased on every req. added, and dec on every finished. */
33781 unsigned long flags;
33782 };
33783 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33784 int al_tr_cycle;
33785 int al_tr_pos; /* position of the next transaction in the journal */
33786 wait_queue_head_t seq_wait;
33787 - atomic_t packet_seq;
33788 + atomic_unchecked_t packet_seq;
33789 unsigned int peer_seq;
33790 spinlock_t peer_seq_lock;
33791 unsigned int minor;
33792 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33793 char __user *uoptval;
33794 int err;
33795
33796 - uoptval = (char __user __force *)optval;
33797 + uoptval = (char __force_user *)optval;
33798
33799 set_fs(KERNEL_DS);
33800 if (level == SOL_SOCKET)
33801 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33802 index 8c13eeb..217adee 100644
33803 --- a/drivers/block/drbd/drbd_main.c
33804 +++ b/drivers/block/drbd/drbd_main.c
33805 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33806 p->sector = sector;
33807 p->block_id = block_id;
33808 p->blksize = blksize;
33809 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33810 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33811 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33812 }
33813
33814 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33815 return -EIO;
33816 p->sector = cpu_to_be64(req->i.sector);
33817 p->block_id = (unsigned long)req;
33818 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33819 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33820 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33821 if (mdev->state.conn >= C_SYNC_SOURCE &&
33822 mdev->state.conn <= C_PAUSED_SYNC_T)
33823 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33824 {
33825 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33826
33827 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33828 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33829 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33830 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33831 kfree(tconn->current_epoch);
33832
33833 idr_destroy(&tconn->volumes);
33834 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33835 index a9eccfc..f5efe87 100644
33836 --- a/drivers/block/drbd/drbd_receiver.c
33837 +++ b/drivers/block/drbd/drbd_receiver.c
33838 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33839 {
33840 int err;
33841
33842 - atomic_set(&mdev->packet_seq, 0);
33843 + atomic_set_unchecked(&mdev->packet_seq, 0);
33844 mdev->peer_seq = 0;
33845
33846 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33847 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33848 do {
33849 next_epoch = NULL;
33850
33851 - epoch_size = atomic_read(&epoch->epoch_size);
33852 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33853
33854 switch (ev & ~EV_CLEANUP) {
33855 case EV_PUT:
33856 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33857 rv = FE_DESTROYED;
33858 } else {
33859 epoch->flags = 0;
33860 - atomic_set(&epoch->epoch_size, 0);
33861 + atomic_set_unchecked(&epoch->epoch_size, 0);
33862 /* atomic_set(&epoch->active, 0); is already zero */
33863 if (rv == FE_STILL_LIVE)
33864 rv = FE_RECYCLED;
33865 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33866 conn_wait_active_ee_empty(tconn);
33867 drbd_flush(tconn);
33868
33869 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33870 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33871 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33872 if (epoch)
33873 break;
33874 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33875 }
33876
33877 epoch->flags = 0;
33878 - atomic_set(&epoch->epoch_size, 0);
33879 + atomic_set_unchecked(&epoch->epoch_size, 0);
33880 atomic_set(&epoch->active, 0);
33881
33882 spin_lock(&tconn->epoch_lock);
33883 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33884 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33885 list_add(&epoch->list, &tconn->current_epoch->list);
33886 tconn->current_epoch = epoch;
33887 tconn->epochs++;
33888 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33889
33890 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33891 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33892 - atomic_inc(&tconn->current_epoch->epoch_size);
33893 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33894 err2 = drbd_drain_block(mdev, pi->size);
33895 if (!err)
33896 err = err2;
33897 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33898
33899 spin_lock(&tconn->epoch_lock);
33900 peer_req->epoch = tconn->current_epoch;
33901 - atomic_inc(&peer_req->epoch->epoch_size);
33902 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33903 atomic_inc(&peer_req->epoch->active);
33904 spin_unlock(&tconn->epoch_lock);
33905
33906 @@ -4346,7 +4346,7 @@ struct data_cmd {
33907 int expect_payload;
33908 size_t pkt_size;
33909 int (*fn)(struct drbd_tconn *, struct packet_info *);
33910 -};
33911 +} __do_const;
33912
33913 static struct data_cmd drbd_cmd_handler[] = {
33914 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33915 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33916 if (!list_empty(&tconn->current_epoch->list))
33917 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33918 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33919 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33920 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33921 tconn->send.seen_any_write_yet = false;
33922
33923 conn_info(tconn, "Connection closed\n");
33924 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33925 struct asender_cmd {
33926 size_t pkt_size;
33927 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33928 -};
33929 +} __do_const;
33930
33931 static struct asender_cmd asender_tbl[] = {
33932 [P_PING] = { 0, got_Ping },
33933 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33934 index f74f2c0..bb668af 100644
33935 --- a/drivers/block/loop.c
33936 +++ b/drivers/block/loop.c
33937 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33938 mm_segment_t old_fs = get_fs();
33939
33940 set_fs(get_ds());
33941 - bw = file->f_op->write(file, buf, len, &pos);
33942 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33943 set_fs(old_fs);
33944 if (likely(bw == len))
33945 return 0;
33946 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33947 index 2e7de7a..ed86dc0 100644
33948 --- a/drivers/block/pktcdvd.c
33949 +++ b/drivers/block/pktcdvd.c
33950 @@ -83,7 +83,7 @@
33951
33952 #define MAX_SPEED 0xffff
33953
33954 -#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1))
33955 +#define ZONE(sector, pd) (((sector) + (pd)->offset) & ~((pd)->settings.size - 1UL))
33956
33957 static DEFINE_MUTEX(pktcdvd_mutex);
33958 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33959 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33960 index d620b44..587561e 100644
33961 --- a/drivers/cdrom/cdrom.c
33962 +++ b/drivers/cdrom/cdrom.c
33963 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33964 ENSURE(reset, CDC_RESET);
33965 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33966 cdi->mc_flags = 0;
33967 - cdo->n_minors = 0;
33968 cdi->options = CDO_USE_FFLAGS;
33969
33970 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33971 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33972 else
33973 cdi->cdda_method = CDDA_OLD;
33974
33975 - if (!cdo->generic_packet)
33976 - cdo->generic_packet = cdrom_dummy_generic_packet;
33977 + if (!cdo->generic_packet) {
33978 + pax_open_kernel();
33979 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33980 + pax_close_kernel();
33981 + }
33982
33983 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33984 mutex_lock(&cdrom_mutex);
33985 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33986 if (cdi->exit)
33987 cdi->exit(cdi);
33988
33989 - cdi->ops->n_minors--;
33990 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33991 }
33992
33993 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33994 index d59cdcb..11afddf 100644
33995 --- a/drivers/cdrom/gdrom.c
33996 +++ b/drivers/cdrom/gdrom.c
33997 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33998 .audio_ioctl = gdrom_audio_ioctl,
33999 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
34000 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
34001 - .n_minors = 1,
34002 };
34003
34004 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
34005 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
34006 index 72bedad..8181ce1 100644
34007 --- a/drivers/char/Kconfig
34008 +++ b/drivers/char/Kconfig
34009 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
34010
34011 config DEVKMEM
34012 bool "/dev/kmem virtual device support"
34013 - default y
34014 + default n
34015 + depends on !GRKERNSEC_KMEM
34016 help
34017 Say Y here if you want to support the /dev/kmem device. The
34018 /dev/kmem device is rarely used, but can be used for certain
34019 @@ -581,6 +582,7 @@ config DEVPORT
34020 bool
34021 depends on !M68K
34022 depends on ISA || PCI
34023 + depends on !GRKERNSEC_KMEM
34024 default y
34025
34026 source "drivers/s390/char/Kconfig"
34027 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
34028 index 2e04433..22afc64 100644
34029 --- a/drivers/char/agp/frontend.c
34030 +++ b/drivers/char/agp/frontend.c
34031 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
34032 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
34033 return -EFAULT;
34034
34035 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
34036 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
34037 return -EFAULT;
34038
34039 client = agp_find_client_by_pid(reserve.pid);
34040 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
34041 index 21cb980..f15107c 100644
34042 --- a/drivers/char/genrtc.c
34043 +++ b/drivers/char/genrtc.c
34044 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34045 switch (cmd) {
34046
34047 case RTC_PLL_GET:
34048 + memset(&pll, 0, sizeof(pll));
34049 if (get_rtc_pll(&pll))
34050 return -EINVAL;
34051 else
34052 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34053 index 615d262..15d5c9d 100644
34054 --- a/drivers/char/hpet.c
34055 +++ b/drivers/char/hpet.c
34056 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34057 }
34058
34059 static int
34060 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34061 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34062 struct hpet_info *info)
34063 {
34064 struct hpet_timer __iomem *timer;
34065 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34066 index 053201b0..8335cce 100644
34067 --- a/drivers/char/ipmi/ipmi_msghandler.c
34068 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34069 @@ -420,7 +420,7 @@ struct ipmi_smi {
34070 struct proc_dir_entry *proc_dir;
34071 char proc_dir_name[10];
34072
34073 - atomic_t stats[IPMI_NUM_STATS];
34074 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34075
34076 /*
34077 * run_to_completion duplicate of smb_info, smi_info
34078 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34079
34080
34081 #define ipmi_inc_stat(intf, stat) \
34082 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34083 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34084 #define ipmi_get_stat(intf, stat) \
34085 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34086 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34087
34088 static int is_lan_addr(struct ipmi_addr *addr)
34089 {
34090 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34091 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34092 init_waitqueue_head(&intf->waitq);
34093 for (i = 0; i < IPMI_NUM_STATS; i++)
34094 - atomic_set(&intf->stats[i], 0);
34095 + atomic_set_unchecked(&intf->stats[i], 0);
34096
34097 intf->proc_dir = NULL;
34098
34099 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34100 index 1c7fdcd..4899100 100644
34101 --- a/drivers/char/ipmi/ipmi_si_intf.c
34102 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34103 @@ -275,7 +275,7 @@ struct smi_info {
34104 unsigned char slave_addr;
34105
34106 /* Counters and things for the proc filesystem. */
34107 - atomic_t stats[SI_NUM_STATS];
34108 + atomic_unchecked_t stats[SI_NUM_STATS];
34109
34110 struct task_struct *thread;
34111
34112 @@ -284,9 +284,9 @@ struct smi_info {
34113 };
34114
34115 #define smi_inc_stat(smi, stat) \
34116 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34117 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34118 #define smi_get_stat(smi, stat) \
34119 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34120 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34121
34122 #define SI_MAX_PARMS 4
34123
34124 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34125 atomic_set(&new_smi->req_events, 0);
34126 new_smi->run_to_completion = 0;
34127 for (i = 0; i < SI_NUM_STATS; i++)
34128 - atomic_set(&new_smi->stats[i], 0);
34129 + atomic_set_unchecked(&new_smi->stats[i], 0);
34130
34131 new_smi->interrupt_disabled = 1;
34132 atomic_set(&new_smi->stop_operation, 0);
34133 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34134 index c6fa3bc..4ca3e42 100644
34135 --- a/drivers/char/mem.c
34136 +++ b/drivers/char/mem.c
34137 @@ -18,6 +18,7 @@
34138 #include <linux/raw.h>
34139 #include <linux/tty.h>
34140 #include <linux/capability.h>
34141 +#include <linux/security.h>
34142 #include <linux/ptrace.h>
34143 #include <linux/device.h>
34144 #include <linux/highmem.h>
34145 @@ -37,6 +38,10 @@
34146
34147 #define DEVPORT_MINOR 4
34148
34149 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34150 +extern const struct file_operations grsec_fops;
34151 +#endif
34152 +
34153 static inline unsigned long size_inside_page(unsigned long start,
34154 unsigned long size)
34155 {
34156 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34157
34158 while (cursor < to) {
34159 if (!devmem_is_allowed(pfn)) {
34160 +#ifdef CONFIG_GRKERNSEC_KMEM
34161 + gr_handle_mem_readwrite(from, to);
34162 +#else
34163 printk(KERN_INFO
34164 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34165 current->comm, from, to);
34166 +#endif
34167 return 0;
34168 }
34169 cursor += PAGE_SIZE;
34170 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34171 }
34172 return 1;
34173 }
34174 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34175 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34176 +{
34177 + return 0;
34178 +}
34179 #else
34180 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34181 {
34182 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34183
34184 while (count > 0) {
34185 unsigned long remaining;
34186 + char *temp;
34187
34188 sz = size_inside_page(p, count);
34189
34190 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34191 if (!ptr)
34192 return -EFAULT;
34193
34194 - remaining = copy_to_user(buf, ptr, sz);
34195 +#ifdef CONFIG_PAX_USERCOPY
34196 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34197 + if (!temp) {
34198 + unxlate_dev_mem_ptr(p, ptr);
34199 + return -ENOMEM;
34200 + }
34201 + memcpy(temp, ptr, sz);
34202 +#else
34203 + temp = ptr;
34204 +#endif
34205 +
34206 + remaining = copy_to_user(buf, temp, sz);
34207 +
34208 +#ifdef CONFIG_PAX_USERCOPY
34209 + kfree(temp);
34210 +#endif
34211 +
34212 unxlate_dev_mem_ptr(p, ptr);
34213 if (remaining)
34214 return -EFAULT;
34215 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34216 size_t count, loff_t *ppos)
34217 {
34218 unsigned long p = *ppos;
34219 - ssize_t low_count, read, sz;
34220 + ssize_t low_count, read, sz, err = 0;
34221 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34222 - int err = 0;
34223
34224 read = 0;
34225 if (p < (unsigned long) high_memory) {
34226 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34227 }
34228 #endif
34229 while (low_count > 0) {
34230 + char *temp;
34231 +
34232 sz = size_inside_page(p, low_count);
34233
34234 /*
34235 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34236 */
34237 kbuf = xlate_dev_kmem_ptr((char *)p);
34238
34239 - if (copy_to_user(buf, kbuf, sz))
34240 +#ifdef CONFIG_PAX_USERCOPY
34241 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34242 + if (!temp)
34243 + return -ENOMEM;
34244 + memcpy(temp, kbuf, sz);
34245 +#else
34246 + temp = kbuf;
34247 +#endif
34248 +
34249 + err = copy_to_user(buf, temp, sz);
34250 +
34251 +#ifdef CONFIG_PAX_USERCOPY
34252 + kfree(temp);
34253 +#endif
34254 +
34255 + if (err)
34256 return -EFAULT;
34257 buf += sz;
34258 p += sz;
34259 @@ -833,6 +880,9 @@ static const struct memdev {
34260 #ifdef CONFIG_CRASH_DUMP
34261 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34262 #endif
34263 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34264 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34265 +#endif
34266 };
34267
34268 static int memory_open(struct inode *inode, struct file *filp)
34269 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34270 index 9df78e2..01ba9ae 100644
34271 --- a/drivers/char/nvram.c
34272 +++ b/drivers/char/nvram.c
34273 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34274
34275 spin_unlock_irq(&rtc_lock);
34276
34277 - if (copy_to_user(buf, contents, tmp - contents))
34278 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34279 return -EFAULT;
34280
34281 *ppos = i;
34282 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34283 index b66eaa0..2619d1b 100644
34284 --- a/drivers/char/pcmcia/synclink_cs.c
34285 +++ b/drivers/char/pcmcia/synclink_cs.c
34286 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34287
34288 if (debug_level >= DEBUG_LEVEL_INFO)
34289 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34290 - __FILE__,__LINE__, info->device_name, port->count);
34291 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34292
34293 - WARN_ON(!port->count);
34294 + WARN_ON(!atomic_read(&port->count));
34295
34296 if (tty_port_close_start(port, tty, filp) == 0)
34297 goto cleanup;
34298 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34299 cleanup:
34300 if (debug_level >= DEBUG_LEVEL_INFO)
34301 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34302 - tty->driver->name, port->count);
34303 + tty->driver->name, atomic_read(&port->count));
34304 }
34305
34306 /* Wait until the transmitter is empty.
34307 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34308
34309 if (debug_level >= DEBUG_LEVEL_INFO)
34310 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34311 - __FILE__,__LINE__,tty->driver->name, port->count);
34312 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34313
34314 /* If port is closing, signal caller to try again */
34315 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34316 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34317 goto cleanup;
34318 }
34319 spin_lock(&port->lock);
34320 - port->count++;
34321 + atomic_inc(&port->count);
34322 spin_unlock(&port->lock);
34323 spin_unlock_irqrestore(&info->netlock, flags);
34324
34325 - if (port->count == 1) {
34326 + if (atomic_read(&port->count) == 1) {
34327 /* 1st open on this device, init hardware */
34328 retval = startup(info, tty);
34329 if (retval < 0)
34330 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34331 unsigned short new_crctype;
34332
34333 /* return error if TTY interface open */
34334 - if (info->port.count)
34335 + if (atomic_read(&info->port.count))
34336 return -EBUSY;
34337
34338 switch (encoding)
34339 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34340
34341 /* arbitrate between network and tty opens */
34342 spin_lock_irqsave(&info->netlock, flags);
34343 - if (info->port.count != 0 || info->netcount != 0) {
34344 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34345 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34346 spin_unlock_irqrestore(&info->netlock, flags);
34347 return -EBUSY;
34348 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34349 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34350
34351 /* return error if TTY interface open */
34352 - if (info->port.count)
34353 + if (atomic_read(&info->port.count))
34354 return -EBUSY;
34355
34356 if (cmd != SIOCWANDEV)
34357 diff --git a/drivers/char/random.c b/drivers/char/random.c
34358 index 57d4b15..253207b 100644
34359 --- a/drivers/char/random.c
34360 +++ b/drivers/char/random.c
34361 @@ -272,8 +272,13 @@
34362 /*
34363 * Configuration information
34364 */
34365 +#ifdef CONFIG_GRKERNSEC_RANDNET
34366 +#define INPUT_POOL_WORDS 512
34367 +#define OUTPUT_POOL_WORDS 128
34368 +#else
34369 #define INPUT_POOL_WORDS 128
34370 #define OUTPUT_POOL_WORDS 32
34371 +#endif
34372 #define SEC_XFER_SIZE 512
34373 #define EXTRACT_SIZE 10
34374
34375 @@ -313,10 +318,17 @@ static struct poolinfo {
34376 int poolwords;
34377 int tap1, tap2, tap3, tap4, tap5;
34378 } poolinfo_table[] = {
34379 +#ifdef CONFIG_GRKERNSEC_RANDNET
34380 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34381 + { 512, 411, 308, 208, 104, 1 },
34382 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34383 + { 128, 103, 76, 51, 25, 1 },
34384 +#else
34385 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34386 { 128, 103, 76, 51, 25, 1 },
34387 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34388 { 32, 26, 20, 14, 7, 1 },
34389 +#endif
34390 #if 0
34391 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34392 { 2048, 1638, 1231, 819, 411, 1 },
34393 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34394 input_rotate += i ? 7 : 14;
34395 }
34396
34397 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34398 - ACCESS_ONCE(r->add_ptr) = i;
34399 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34400 + ACCESS_ONCE_RW(r->add_ptr) = i;
34401 smp_wmb();
34402
34403 if (out)
34404 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34405
34406 extract_buf(r, tmp);
34407 i = min_t(int, nbytes, EXTRACT_SIZE);
34408 - if (copy_to_user(buf, tmp, i)) {
34409 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34410 ret = -EFAULT;
34411 break;
34412 }
34413 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34414 #include <linux/sysctl.h>
34415
34416 static int min_read_thresh = 8, min_write_thresh;
34417 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34418 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34419 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34420 static char sysctl_bootid[16];
34421
34422 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34423 static int proc_do_uuid(ctl_table *table, int write,
34424 void __user *buffer, size_t *lenp, loff_t *ppos)
34425 {
34426 - ctl_table fake_table;
34427 + ctl_table_no_const fake_table;
34428 unsigned char buf[64], tmp_uuid[16], *uuid;
34429
34430 uuid = table->data;
34431 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34432 index d780295..b29f3a8 100644
34433 --- a/drivers/char/sonypi.c
34434 +++ b/drivers/char/sonypi.c
34435 @@ -54,6 +54,7 @@
34436
34437 #include <asm/uaccess.h>
34438 #include <asm/io.h>
34439 +#include <asm/local.h>
34440
34441 #include <linux/sonypi.h>
34442
34443 @@ -490,7 +491,7 @@ static struct sonypi_device {
34444 spinlock_t fifo_lock;
34445 wait_queue_head_t fifo_proc_list;
34446 struct fasync_struct *fifo_async;
34447 - int open_count;
34448 + local_t open_count;
34449 int model;
34450 struct input_dev *input_jog_dev;
34451 struct input_dev *input_key_dev;
34452 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34453 static int sonypi_misc_release(struct inode *inode, struct file *file)
34454 {
34455 mutex_lock(&sonypi_device.lock);
34456 - sonypi_device.open_count--;
34457 + local_dec(&sonypi_device.open_count);
34458 mutex_unlock(&sonypi_device.lock);
34459 return 0;
34460 }
34461 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34462 {
34463 mutex_lock(&sonypi_device.lock);
34464 /* Flush input queue on first open */
34465 - if (!sonypi_device.open_count)
34466 + if (!local_read(&sonypi_device.open_count))
34467 kfifo_reset(&sonypi_device.fifo);
34468 - sonypi_device.open_count++;
34469 + local_inc(&sonypi_device.open_count);
34470 mutex_unlock(&sonypi_device.lock);
34471
34472 return 0;
34473 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34474 index ba780b7..cdb8a9c 100644
34475 --- a/drivers/char/tpm/tpm.c
34476 +++ b/drivers/char/tpm/tpm.c
34477 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34478 chip->vendor.req_complete_val)
34479 goto out_recv;
34480
34481 - if ((status == chip->vendor.req_canceled)) {
34482 + if (status == chip->vendor.req_canceled) {
34483 dev_err(chip->dev, "Operation Canceled\n");
34484 rc = -ECANCELED;
34485 goto out;
34486 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34487 index 56051d0..11cf3b7 100644
34488 --- a/drivers/char/tpm/tpm_acpi.c
34489 +++ b/drivers/char/tpm/tpm_acpi.c
34490 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34491 virt = acpi_os_map_memory(start, len);
34492 if (!virt) {
34493 kfree(log->bios_event_log);
34494 + log->bios_event_log = NULL;
34495 printk("%s: ERROR - Unable to map memory\n", __func__);
34496 return -EIO;
34497 }
34498
34499 - memcpy_fromio(log->bios_event_log, virt, len);
34500 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34501
34502 acpi_os_unmap_memory(virt, len);
34503 return 0;
34504 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34505 index 84ddc55..1d32f1e 100644
34506 --- a/drivers/char/tpm/tpm_eventlog.c
34507 +++ b/drivers/char/tpm/tpm_eventlog.c
34508 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34509 event = addr;
34510
34511 if ((event->event_type == 0 && event->event_size == 0) ||
34512 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34513 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34514 return NULL;
34515
34516 return addr;
34517 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34518 return NULL;
34519
34520 if ((event->event_type == 0 && event->event_size == 0) ||
34521 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34522 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34523 return NULL;
34524
34525 (*pos)++;
34526 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34527 int i;
34528
34529 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34530 - seq_putc(m, data[i]);
34531 + if (!seq_putc(m, data[i]))
34532 + return -EFAULT;
34533
34534 return 0;
34535 }
34536 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34537 index a4b7aa0..2faa0bc 100644
34538 --- a/drivers/char/virtio_console.c
34539 +++ b/drivers/char/virtio_console.c
34540 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34541 if (to_user) {
34542 ssize_t ret;
34543
34544 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34545 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34546 if (ret)
34547 return -EFAULT;
34548 } else {
34549 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34550 if (!port_has_data(port) && !port->host_connected)
34551 return 0;
34552
34553 - return fill_readbuf(port, ubuf, count, true);
34554 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34555 }
34556
34557 static int wait_port_writable(struct port *port, bool nonblock)
34558 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34559 index 8ae1a61..9c00613 100644
34560 --- a/drivers/clocksource/arm_generic.c
34561 +++ b/drivers/clocksource/arm_generic.c
34562 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34563 return NOTIFY_OK;
34564 }
34565
34566 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34567 +static struct notifier_block arch_timer_cpu_nb = {
34568 .notifier_call = arch_timer_cpu_notify,
34569 };
34570
34571 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34572 index 7b0d49d..134fac9 100644
34573 --- a/drivers/cpufreq/acpi-cpufreq.c
34574 +++ b/drivers/cpufreq/acpi-cpufreq.c
34575 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34576 return sprintf(buf, "%u\n", boost_enabled);
34577 }
34578
34579 -static struct global_attr global_boost = __ATTR(boost, 0644,
34580 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34581 show_global_boost,
34582 store_global_boost);
34583
34584 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34585 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34586 per_cpu(acfreq_data, cpu) = data;
34587
34588 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34589 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34590 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34591 + pax_open_kernel();
34592 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34593 + pax_close_kernel();
34594 + }
34595
34596 result = acpi_processor_register_performance(data->acpi_data, cpu);
34597 if (result)
34598 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34599 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34600 break;
34601 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34602 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34603 + pax_open_kernel();
34604 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34605 + pax_close_kernel();
34606 policy->cur = get_cur_freq_on_cpu(cpu);
34607 break;
34608 default:
34609 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34610 acpi_processor_notify_smm(THIS_MODULE);
34611
34612 /* Check for APERF/MPERF support in hardware */
34613 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34614 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34615 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34616 + pax_open_kernel();
34617 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34618 + pax_close_kernel();
34619 + }
34620
34621 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34622 for (i = 0; i < perf->state_count; i++)
34623 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34624 index 1f93dbd..305cef1 100644
34625 --- a/drivers/cpufreq/cpufreq.c
34626 +++ b/drivers/cpufreq/cpufreq.c
34627 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34628 return NOTIFY_OK;
34629 }
34630
34631 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34632 +static struct notifier_block cpufreq_cpu_notifier = {
34633 .notifier_call = cpufreq_cpu_callback,
34634 };
34635
34636 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34637
34638 pr_debug("trying to register driver %s\n", driver_data->name);
34639
34640 - if (driver_data->setpolicy)
34641 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34642 + if (driver_data->setpolicy) {
34643 + pax_open_kernel();
34644 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34645 + pax_close_kernel();
34646 + }
34647
34648 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34649 if (cpufreq_driver) {
34650 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34651 index 6c5f1d3..c7e2f35e 100644
34652 --- a/drivers/cpufreq/cpufreq_governor.c
34653 +++ b/drivers/cpufreq/cpufreq_governor.c
34654 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34655 * governor, thus we are bound to jiffes/HZ
34656 */
34657 if (dbs_data->governor == GOV_CONSERVATIVE) {
34658 - struct cs_ops *ops = dbs_data->gov_ops;
34659 + const struct cs_ops *ops = dbs_data->gov_ops;
34660
34661 cpufreq_register_notifier(ops->notifier_block,
34662 CPUFREQ_TRANSITION_NOTIFIER);
34663 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34664 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34665 jiffies_to_usecs(10);
34666 } else {
34667 - struct od_ops *ops = dbs_data->gov_ops;
34668 + const struct od_ops *ops = dbs_data->gov_ops;
34669
34670 od_tuners->io_is_busy = ops->io_busy();
34671 }
34672 @@ -268,7 +268,7 @@ second_time:
34673 cs_dbs_info->enable = 1;
34674 cs_dbs_info->requested_freq = policy->cur;
34675 } else {
34676 - struct od_ops *ops = dbs_data->gov_ops;
34677 + const struct od_ops *ops = dbs_data->gov_ops;
34678 od_dbs_info->rate_mult = 1;
34679 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34680 ops->powersave_bias_init_cpu(cpu);
34681 @@ -289,7 +289,7 @@ second_time:
34682 mutex_destroy(&cpu_cdbs->timer_mutex);
34683 dbs_data->enable--;
34684 if (!dbs_data->enable) {
34685 - struct cs_ops *ops = dbs_data->gov_ops;
34686 + const struct cs_ops *ops = dbs_data->gov_ops;
34687
34688 sysfs_remove_group(cpufreq_global_kobject,
34689 dbs_data->attr_group);
34690 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34691 index f661654..6c8e638 100644
34692 --- a/drivers/cpufreq/cpufreq_governor.h
34693 +++ b/drivers/cpufreq/cpufreq_governor.h
34694 @@ -142,7 +142,7 @@ struct dbs_data {
34695 void (*gov_check_cpu)(int cpu, unsigned int load);
34696
34697 /* Governor specific ops, see below */
34698 - void *gov_ops;
34699 + const void *gov_ops;
34700 };
34701
34702 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34703 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34704 index 9d7732b..0b1a793 100644
34705 --- a/drivers/cpufreq/cpufreq_stats.c
34706 +++ b/drivers/cpufreq/cpufreq_stats.c
34707 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34708 }
34709
34710 /* priority=1 so this will get called before cpufreq_remove_dev */
34711 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34712 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34713 .notifier_call = cpufreq_stat_cpu_callback,
34714 .priority = 1,
34715 };
34716 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34717 index 827629c9..0bc6a03 100644
34718 --- a/drivers/cpufreq/p4-clockmod.c
34719 +++ b/drivers/cpufreq/p4-clockmod.c
34720 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34721 case 0x0F: /* Core Duo */
34722 case 0x16: /* Celeron Core */
34723 case 0x1C: /* Atom */
34724 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34725 + pax_open_kernel();
34726 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34727 + pax_close_kernel();
34728 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34729 case 0x0D: /* Pentium M (Dothan) */
34730 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34731 + pax_open_kernel();
34732 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34733 + pax_close_kernel();
34734 /* fall through */
34735 case 0x09: /* Pentium M (Banias) */
34736 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34737 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34738
34739 /* on P-4s, the TSC runs with constant frequency independent whether
34740 * throttling is active or not. */
34741 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34742 + pax_open_kernel();
34743 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34744 + pax_close_kernel();
34745
34746 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34747 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34748 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34749 index 3a953d5..f5993f6 100644
34750 --- a/drivers/cpufreq/speedstep-centrino.c
34751 +++ b/drivers/cpufreq/speedstep-centrino.c
34752 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34753 !cpu_has(cpu, X86_FEATURE_EST))
34754 return -ENODEV;
34755
34756 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34757 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34758 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34759 + pax_open_kernel();
34760 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34761 + pax_close_kernel();
34762 + }
34763
34764 if (policy->cpu != 0)
34765 return -ENODEV;
34766 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34767 index e1f6860..f8de20b 100644
34768 --- a/drivers/cpuidle/cpuidle.c
34769 +++ b/drivers/cpuidle/cpuidle.c
34770 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34771
34772 static void poll_idle_init(struct cpuidle_driver *drv)
34773 {
34774 - struct cpuidle_state *state = &drv->states[0];
34775 + cpuidle_state_no_const *state = &drv->states[0];
34776
34777 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34778 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34779 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34780 index ea2f8e7..70ac501 100644
34781 --- a/drivers/cpuidle/governor.c
34782 +++ b/drivers/cpuidle/governor.c
34783 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34784 mutex_lock(&cpuidle_lock);
34785 if (__cpuidle_find_governor(gov->name) == NULL) {
34786 ret = 0;
34787 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34788 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34789 if (!cpuidle_curr_governor ||
34790 cpuidle_curr_governor->rating < gov->rating)
34791 cpuidle_switch_governor(gov);
34792 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34793 new_gov = cpuidle_replace_governor(gov->rating);
34794 cpuidle_switch_governor(new_gov);
34795 }
34796 - list_del(&gov->governor_list);
34797 + pax_list_del((struct list_head *)&gov->governor_list);
34798 mutex_unlock(&cpuidle_lock);
34799 }
34800
34801 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34802 index 428754a..8bdf9cc 100644
34803 --- a/drivers/cpuidle/sysfs.c
34804 +++ b/drivers/cpuidle/sysfs.c
34805 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34806 NULL
34807 };
34808
34809 -static struct attribute_group cpuidle_attr_group = {
34810 +static attribute_group_no_const cpuidle_attr_group = {
34811 .attrs = cpuidle_default_attrs,
34812 .name = "cpuidle",
34813 };
34814 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34815 index 3b36797..289c16a 100644
34816 --- a/drivers/devfreq/devfreq.c
34817 +++ b/drivers/devfreq/devfreq.c
34818 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34819 goto err_out;
34820 }
34821
34822 - list_add(&governor->node, &devfreq_governor_list);
34823 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34824
34825 list_for_each_entry(devfreq, &devfreq_list, node) {
34826 int ret = 0;
34827 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34828 }
34829 }
34830
34831 - list_del(&governor->node);
34832 + pax_list_del((struct list_head *)&governor->node);
34833 err_out:
34834 mutex_unlock(&devfreq_list_lock);
34835
34836 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34837 index b70709b..1d8d02a 100644
34838 --- a/drivers/dma/sh/shdma.c
34839 +++ b/drivers/dma/sh/shdma.c
34840 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34841 return ret;
34842 }
34843
34844 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34845 +static struct notifier_block sh_dmae_nmi_notifier = {
34846 .notifier_call = sh_dmae_nmi_handler,
34847
34848 /* Run before NMI debug handler and KGDB */
34849 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34850 index 0ca1ca7..6e6f454 100644
34851 --- a/drivers/edac/edac_mc_sysfs.c
34852 +++ b/drivers/edac/edac_mc_sysfs.c
34853 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34854 struct dev_ch_attribute {
34855 struct device_attribute attr;
34856 int channel;
34857 -};
34858 +} __do_const;
34859
34860 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34861 struct dev_ch_attribute dev_attr_legacy_##_name = \
34862 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34863 index 0056c4d..23b54d9 100644
34864 --- a/drivers/edac/edac_pci_sysfs.c
34865 +++ b/drivers/edac/edac_pci_sysfs.c
34866 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34867 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34868 static int edac_pci_poll_msec = 1000; /* one second workq period */
34869
34870 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34871 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34872 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34873 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34874
34875 static struct kobject *edac_pci_top_main_kobj;
34876 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34877 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34878 void *value;
34879 ssize_t(*show) (void *, char *);
34880 ssize_t(*store) (void *, const char *, size_t);
34881 -};
34882 +} __do_const;
34883
34884 /* Set of show/store abstract level functions for PCI Parity object */
34885 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34886 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34887 edac_printk(KERN_CRIT, EDAC_PCI,
34888 "Signaled System Error on %s\n",
34889 pci_name(dev));
34890 - atomic_inc(&pci_nonparity_count);
34891 + atomic_inc_unchecked(&pci_nonparity_count);
34892 }
34893
34894 if (status & (PCI_STATUS_PARITY)) {
34895 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34896 "Master Data Parity Error on %s\n",
34897 pci_name(dev));
34898
34899 - atomic_inc(&pci_parity_count);
34900 + atomic_inc_unchecked(&pci_parity_count);
34901 }
34902
34903 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34904 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34905 "Detected Parity Error on %s\n",
34906 pci_name(dev));
34907
34908 - atomic_inc(&pci_parity_count);
34909 + atomic_inc_unchecked(&pci_parity_count);
34910 }
34911 }
34912
34913 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34914 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34915 "Signaled System Error on %s\n",
34916 pci_name(dev));
34917 - atomic_inc(&pci_nonparity_count);
34918 + atomic_inc_unchecked(&pci_nonparity_count);
34919 }
34920
34921 if (status & (PCI_STATUS_PARITY)) {
34922 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34923 "Master Data Parity Error on "
34924 "%s\n", pci_name(dev));
34925
34926 - atomic_inc(&pci_parity_count);
34927 + atomic_inc_unchecked(&pci_parity_count);
34928 }
34929
34930 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34931 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34932 "Detected Parity Error on %s\n",
34933 pci_name(dev));
34934
34935 - atomic_inc(&pci_parity_count);
34936 + atomic_inc_unchecked(&pci_parity_count);
34937 }
34938 }
34939 }
34940 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34941 if (!check_pci_errors)
34942 return;
34943
34944 - before_count = atomic_read(&pci_parity_count);
34945 + before_count = atomic_read_unchecked(&pci_parity_count);
34946
34947 /* scan all PCI devices looking for a Parity Error on devices and
34948 * bridges.
34949 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34950 /* Only if operator has selected panic on PCI Error */
34951 if (edac_pci_get_panic_on_pe()) {
34952 /* If the count is different 'after' from 'before' */
34953 - if (before_count != atomic_read(&pci_parity_count))
34954 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34955 panic("EDAC: PCI Parity Error");
34956 }
34957 }
34958 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34959 index 6796799..99e8377 100644
34960 --- a/drivers/edac/mce_amd.h
34961 +++ b/drivers/edac/mce_amd.h
34962 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34963 struct amd_decoder_ops {
34964 bool (*mc0_mce)(u16, u8);
34965 bool (*mc1_mce)(u16, u8);
34966 -};
34967 +} __no_const;
34968
34969 void amd_report_gart_errors(bool);
34970 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34971 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34972 index 57ea7f4..789e3c3 100644
34973 --- a/drivers/firewire/core-card.c
34974 +++ b/drivers/firewire/core-card.c
34975 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34976
34977 void fw_core_remove_card(struct fw_card *card)
34978 {
34979 - struct fw_card_driver dummy_driver = dummy_driver_template;
34980 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34981
34982 card->driver->update_phy_reg(card, 4,
34983 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34984 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34985 index f8d2287..5aaf4db 100644
34986 --- a/drivers/firewire/core-cdev.c
34987 +++ b/drivers/firewire/core-cdev.c
34988 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34989 int ret;
34990
34991 if ((request->channels == 0 && request->bandwidth == 0) ||
34992 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34993 - request->bandwidth < 0)
34994 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34995 return -EINVAL;
34996
34997 r = kmalloc(sizeof(*r), GFP_KERNEL);
34998 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34999 index af3e8aa..eb2f227 100644
35000 --- a/drivers/firewire/core-device.c
35001 +++ b/drivers/firewire/core-device.c
35002 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35003 struct config_rom_attribute {
35004 struct device_attribute attr;
35005 u32 key;
35006 -};
35007 +} __do_const;
35008
35009 static ssize_t show_immediate(struct device *dev,
35010 struct device_attribute *dattr, char *buf)
35011 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35012 index 28a94c7..58da63a 100644
35013 --- a/drivers/firewire/core-transaction.c
35014 +++ b/drivers/firewire/core-transaction.c
35015 @@ -38,6 +38,7 @@
35016 #include <linux/timer.h>
35017 #include <linux/types.h>
35018 #include <linux/workqueue.h>
35019 +#include <linux/sched.h>
35020
35021 #include <asm/byteorder.h>
35022
35023 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35024 index 515a42c..5ecf3ba 100644
35025 --- a/drivers/firewire/core.h
35026 +++ b/drivers/firewire/core.h
35027 @@ -111,6 +111,7 @@ struct fw_card_driver {
35028
35029 int (*stop_iso)(struct fw_iso_context *ctx);
35030 };
35031 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35032
35033 void fw_card_initialize(struct fw_card *card,
35034 const struct fw_card_driver *driver, struct device *device);
35035 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35036 index 94a58a0..f5eba42 100644
35037 --- a/drivers/firmware/dmi-id.c
35038 +++ b/drivers/firmware/dmi-id.c
35039 @@ -16,7 +16,7 @@
35040 struct dmi_device_attribute{
35041 struct device_attribute dev_attr;
35042 int field;
35043 -};
35044 +} __do_const;
35045 #define to_dmi_dev_attr(_dev_attr) \
35046 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35047
35048 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35049 index 4cd392d..4b629e1 100644
35050 --- a/drivers/firmware/dmi_scan.c
35051 +++ b/drivers/firmware/dmi_scan.c
35052 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35053 }
35054 }
35055 else {
35056 - /*
35057 - * no iounmap() for that ioremap(); it would be a no-op, but
35058 - * it's so early in setup that sucker gets confused into doing
35059 - * what it shouldn't if we actually call it.
35060 - */
35061 p = dmi_ioremap(0xF0000, 0x10000);
35062 if (p == NULL)
35063 goto error;
35064 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35065 if (buf == NULL)
35066 return -1;
35067
35068 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35069 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35070
35071 iounmap(buf);
35072 return 0;
35073 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35074 index b07cb37..2a51037 100644
35075 --- a/drivers/firmware/efivars.c
35076 +++ b/drivers/firmware/efivars.c
35077 @@ -138,7 +138,7 @@ struct efivar_attribute {
35078 };
35079
35080 static struct efivars __efivars;
35081 -static struct efivar_operations ops;
35082 +static efivar_operations_no_const ops __read_only;
35083
35084 #define PSTORE_EFI_ATTRIBUTES \
35085 (EFI_VARIABLE_NON_VOLATILE | \
35086 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35087 static int
35088 create_efivars_bin_attributes(struct efivars *efivars)
35089 {
35090 - struct bin_attribute *attr;
35091 + bin_attribute_no_const *attr;
35092 int error;
35093
35094 /* new_var */
35095 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35096 index 2a90ba6..07f3733 100644
35097 --- a/drivers/firmware/google/memconsole.c
35098 +++ b/drivers/firmware/google/memconsole.c
35099 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35100 if (!found_memconsole())
35101 return -ENODEV;
35102
35103 - memconsole_bin_attr.size = memconsole_length;
35104 + pax_open_kernel();
35105 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35106 + pax_close_kernel();
35107
35108 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35109
35110 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35111 index 6f2306d..af9476a 100644
35112 --- a/drivers/gpio/gpio-ich.c
35113 +++ b/drivers/gpio/gpio-ich.c
35114 @@ -69,7 +69,7 @@ struct ichx_desc {
35115 /* Some chipsets have quirks, let these use their own request/get */
35116 int (*request)(struct gpio_chip *chip, unsigned offset);
35117 int (*get)(struct gpio_chip *chip, unsigned offset);
35118 -};
35119 +} __do_const;
35120
35121 static struct {
35122 spinlock_t lock;
35123 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35124 index 9902732..64b62dd 100644
35125 --- a/drivers/gpio/gpio-vr41xx.c
35126 +++ b/drivers/gpio/gpio-vr41xx.c
35127 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35128 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35129 maskl, pendl, maskh, pendh);
35130
35131 - atomic_inc(&irq_err_count);
35132 + atomic_inc_unchecked(&irq_err_count);
35133
35134 return -EINVAL;
35135 }
35136 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35137 index 7b2d378..cc947ea 100644
35138 --- a/drivers/gpu/drm/drm_crtc_helper.c
35139 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35140 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35141 struct drm_crtc *tmp;
35142 int crtc_mask = 1;
35143
35144 - WARN(!crtc, "checking null crtc?\n");
35145 + BUG_ON(!crtc);
35146
35147 dev = crtc->dev;
35148
35149 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35150 index be174ca..7f38143 100644
35151 --- a/drivers/gpu/drm/drm_drv.c
35152 +++ b/drivers/gpu/drm/drm_drv.c
35153 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35154 /**
35155 * Copy and IOCTL return string to user space
35156 */
35157 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35158 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35159 {
35160 int len;
35161
35162 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35163 struct drm_file *file_priv = filp->private_data;
35164 struct drm_device *dev;
35165 struct drm_ioctl_desc *ioctl;
35166 - drm_ioctl_t *func;
35167 + drm_ioctl_no_const_t func;
35168 unsigned int nr = DRM_IOCTL_NR(cmd);
35169 int retcode = -EINVAL;
35170 char stack_kdata[128];
35171 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35172 return -ENODEV;
35173
35174 atomic_inc(&dev->ioctl_count);
35175 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35176 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35177 ++file_priv->ioctl_count;
35178
35179 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35180 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35181 index 32d7775..c8be5e1 100644
35182 --- a/drivers/gpu/drm/drm_fops.c
35183 +++ b/drivers/gpu/drm/drm_fops.c
35184 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35185 }
35186
35187 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35188 - atomic_set(&dev->counts[i], 0);
35189 + atomic_set_unchecked(&dev->counts[i], 0);
35190
35191 dev->sigdata.lock = NULL;
35192
35193 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35194 if (drm_device_is_unplugged(dev))
35195 return -ENODEV;
35196
35197 - if (!dev->open_count++)
35198 + if (local_inc_return(&dev->open_count) == 1)
35199 need_setup = 1;
35200 mutex_lock(&dev->struct_mutex);
35201 old_imapping = inode->i_mapping;
35202 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35203 retcode = drm_open_helper(inode, filp, dev);
35204 if (retcode)
35205 goto err_undo;
35206 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35207 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35208 if (need_setup) {
35209 retcode = drm_setup(dev);
35210 if (retcode)
35211 @@ -166,7 +166,7 @@ err_undo:
35212 iput(container_of(dev->dev_mapping, struct inode, i_data));
35213 dev->dev_mapping = old_mapping;
35214 mutex_unlock(&dev->struct_mutex);
35215 - dev->open_count--;
35216 + local_dec(&dev->open_count);
35217 return retcode;
35218 }
35219 EXPORT_SYMBOL(drm_open);
35220 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35221
35222 mutex_lock(&drm_global_mutex);
35223
35224 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35225 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35226
35227 if (dev->driver->preclose)
35228 dev->driver->preclose(dev, file_priv);
35229 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35230 * Begin inline drm_release
35231 */
35232
35233 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35234 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35235 task_pid_nr(current),
35236 (long)old_encode_dev(file_priv->minor->device),
35237 - dev->open_count);
35238 + local_read(&dev->open_count));
35239
35240 /* Release any auth tokens that might point to this file_priv,
35241 (do that under the drm_global_mutex) */
35242 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35243 * End inline drm_release
35244 */
35245
35246 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35247 - if (!--dev->open_count) {
35248 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35249 + if (local_dec_and_test(&dev->open_count)) {
35250 if (atomic_read(&dev->ioctl_count)) {
35251 DRM_ERROR("Device busy: %d\n",
35252 atomic_read(&dev->ioctl_count));
35253 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35254 index f731116..629842c 100644
35255 --- a/drivers/gpu/drm/drm_global.c
35256 +++ b/drivers/gpu/drm/drm_global.c
35257 @@ -36,7 +36,7 @@
35258 struct drm_global_item {
35259 struct mutex mutex;
35260 void *object;
35261 - int refcount;
35262 + atomic_t refcount;
35263 };
35264
35265 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35266 @@ -49,7 +49,7 @@ void drm_global_init(void)
35267 struct drm_global_item *item = &glob[i];
35268 mutex_init(&item->mutex);
35269 item->object = NULL;
35270 - item->refcount = 0;
35271 + atomic_set(&item->refcount, 0);
35272 }
35273 }
35274
35275 @@ -59,7 +59,7 @@ void drm_global_release(void)
35276 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35277 struct drm_global_item *item = &glob[i];
35278 BUG_ON(item->object != NULL);
35279 - BUG_ON(item->refcount != 0);
35280 + BUG_ON(atomic_read(&item->refcount) != 0);
35281 }
35282 }
35283
35284 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35285 void *object;
35286
35287 mutex_lock(&item->mutex);
35288 - if (item->refcount == 0) {
35289 + if (atomic_read(&item->refcount) == 0) {
35290 item->object = kzalloc(ref->size, GFP_KERNEL);
35291 if (unlikely(item->object == NULL)) {
35292 ret = -ENOMEM;
35293 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35294 goto out_err;
35295
35296 }
35297 - ++item->refcount;
35298 + atomic_inc(&item->refcount);
35299 ref->object = item->object;
35300 object = item->object;
35301 mutex_unlock(&item->mutex);
35302 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35303 struct drm_global_item *item = &glob[ref->global_type];
35304
35305 mutex_lock(&item->mutex);
35306 - BUG_ON(item->refcount == 0);
35307 + BUG_ON(atomic_read(&item->refcount) == 0);
35308 BUG_ON(ref->object != item->object);
35309 - if (--item->refcount == 0) {
35310 + if (atomic_dec_and_test(&item->refcount)) {
35311 ref->release(ref);
35312 item->object = NULL;
35313 }
35314 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35315 index d4b20ce..77a8d41 100644
35316 --- a/drivers/gpu/drm/drm_info.c
35317 +++ b/drivers/gpu/drm/drm_info.c
35318 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35319 struct drm_local_map *map;
35320 struct drm_map_list *r_list;
35321
35322 - /* Hardcoded from _DRM_FRAME_BUFFER,
35323 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35324 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35325 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35326 + static const char * const types[] = {
35327 + [_DRM_FRAME_BUFFER] = "FB",
35328 + [_DRM_REGISTERS] = "REG",
35329 + [_DRM_SHM] = "SHM",
35330 + [_DRM_AGP] = "AGP",
35331 + [_DRM_SCATTER_GATHER] = "SG",
35332 + [_DRM_CONSISTENT] = "PCI",
35333 + [_DRM_GEM] = "GEM" };
35334 const char *type;
35335 int i;
35336
35337 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35338 map = r_list->map;
35339 if (!map)
35340 continue;
35341 - if (map->type < 0 || map->type > 5)
35342 + if (map->type >= ARRAY_SIZE(types))
35343 type = "??";
35344 else
35345 type = types[map->type];
35346 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35347 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35348 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35349 vma->vm_flags & VM_IO ? 'i' : '-',
35350 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35351 + 0);
35352 +#else
35353 vma->vm_pgoff);
35354 +#endif
35355
35356 #if defined(__i386__)
35357 pgprot = pgprot_val(vma->vm_page_prot);
35358 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35359 index 2f4c434..dd12cd2 100644
35360 --- a/drivers/gpu/drm/drm_ioc32.c
35361 +++ b/drivers/gpu/drm/drm_ioc32.c
35362 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35363 request = compat_alloc_user_space(nbytes);
35364 if (!access_ok(VERIFY_WRITE, request, nbytes))
35365 return -EFAULT;
35366 - list = (struct drm_buf_desc *) (request + 1);
35367 + list = (struct drm_buf_desc __user *) (request + 1);
35368
35369 if (__put_user(count, &request->count)
35370 || __put_user(list, &request->list))
35371 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35372 request = compat_alloc_user_space(nbytes);
35373 if (!access_ok(VERIFY_WRITE, request, nbytes))
35374 return -EFAULT;
35375 - list = (struct drm_buf_pub *) (request + 1);
35376 + list = (struct drm_buf_pub __user *) (request + 1);
35377
35378 if (__put_user(count, &request->count)
35379 || __put_user(list, &request->list))
35380 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35381 return 0;
35382 }
35383
35384 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35385 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35386 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35387 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35388 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35389 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35390 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35391 {
35392 unsigned int nr = DRM_IOCTL_NR(cmd);
35393 - drm_ioctl_compat_t *fn;
35394 int ret;
35395
35396 /* Assume that ioctls without an explicit compat routine will just
35397 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35398 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35399 return drm_ioctl(filp, cmd, arg);
35400
35401 - fn = drm_compat_ioctls[nr];
35402 -
35403 - if (fn != NULL)
35404 - ret = (*fn) (filp, cmd, arg);
35405 + if (drm_compat_ioctls[nr] != NULL)
35406 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35407 else
35408 ret = drm_ioctl(filp, cmd, arg);
35409
35410 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35411 index e77bd8b..1571b85 100644
35412 --- a/drivers/gpu/drm/drm_ioctl.c
35413 +++ b/drivers/gpu/drm/drm_ioctl.c
35414 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35415 stats->data[i].value =
35416 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35417 else
35418 - stats->data[i].value = atomic_read(&dev->counts[i]);
35419 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35420 stats->data[i].type = dev->types[i];
35421 }
35422
35423 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35424 index d752c96..fe08455 100644
35425 --- a/drivers/gpu/drm/drm_lock.c
35426 +++ b/drivers/gpu/drm/drm_lock.c
35427 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35428 if (drm_lock_take(&master->lock, lock->context)) {
35429 master->lock.file_priv = file_priv;
35430 master->lock.lock_time = jiffies;
35431 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35432 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35433 break; /* Got lock */
35434 }
35435
35436 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35437 return -EINVAL;
35438 }
35439
35440 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35441 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35442
35443 if (drm_lock_free(&master->lock, lock->context)) {
35444 /* FIXME: Should really bail out here. */
35445 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35446 index 200e104..59facda 100644
35447 --- a/drivers/gpu/drm/drm_stub.c
35448 +++ b/drivers/gpu/drm/drm_stub.c
35449 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35450
35451 drm_device_set_unplugged(dev);
35452
35453 - if (dev->open_count == 0) {
35454 + if (local_read(&dev->open_count) == 0) {
35455 drm_put_dev(dev);
35456 }
35457 mutex_unlock(&drm_global_mutex);
35458 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35459 index 004ecdf..db1f6e0 100644
35460 --- a/drivers/gpu/drm/i810/i810_dma.c
35461 +++ b/drivers/gpu/drm/i810/i810_dma.c
35462 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35463 dma->buflist[vertex->idx],
35464 vertex->discard, vertex->used);
35465
35466 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35467 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35468 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35469 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35470 sarea_priv->last_enqueue = dev_priv->counter - 1;
35471 sarea_priv->last_dispatch = (int)hw_status[5];
35472
35473 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35474 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35475 mc->last_render);
35476
35477 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35478 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35479 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35480 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35481 sarea_priv->last_enqueue = dev_priv->counter - 1;
35482 sarea_priv->last_dispatch = (int)hw_status[5];
35483
35484 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35485 index 6e0acad..93c8289 100644
35486 --- a/drivers/gpu/drm/i810/i810_drv.h
35487 +++ b/drivers/gpu/drm/i810/i810_drv.h
35488 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35489 int page_flipping;
35490
35491 wait_queue_head_t irq_queue;
35492 - atomic_t irq_received;
35493 - atomic_t irq_emitted;
35494 + atomic_unchecked_t irq_received;
35495 + atomic_unchecked_t irq_emitted;
35496
35497 int front_offset;
35498 } drm_i810_private_t;
35499 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35500 index 261efc8e..27af8a5 100644
35501 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35502 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35503 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35504 I915_READ(GTIMR));
35505 }
35506 seq_printf(m, "Interrupts received: %d\n",
35507 - atomic_read(&dev_priv->irq_received));
35508 + atomic_read_unchecked(&dev_priv->irq_received));
35509 for_each_ring(ring, dev_priv, i) {
35510 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35511 seq_printf(m,
35512 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35513 index 99daa89..84ebd44 100644
35514 --- a/drivers/gpu/drm/i915/i915_dma.c
35515 +++ b/drivers/gpu/drm/i915/i915_dma.c
35516 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35517 bool can_switch;
35518
35519 spin_lock(&dev->count_lock);
35520 - can_switch = (dev->open_count == 0);
35521 + can_switch = (local_read(&dev->open_count) == 0);
35522 spin_unlock(&dev->count_lock);
35523 return can_switch;
35524 }
35525 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35526 index 7339a4b..445aaba 100644
35527 --- a/drivers/gpu/drm/i915/i915_drv.h
35528 +++ b/drivers/gpu/drm/i915/i915_drv.h
35529 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35530 drm_dma_handle_t *status_page_dmah;
35531 struct resource mch_res;
35532
35533 - atomic_t irq_received;
35534 + atomic_unchecked_t irq_received;
35535
35536 /* protects the irq masks */
35537 spinlock_t irq_lock;
35538 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35539 * will be page flipped away on the next vblank. When it
35540 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35541 */
35542 - atomic_t pending_flip;
35543 + atomic_unchecked_t pending_flip;
35544 };
35545 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35546
35547 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35548 struct drm_i915_private *dev_priv, unsigned port);
35549 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35550 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35551 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35552 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35553 {
35554 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35555 }
35556 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35557 index ba8805a..39d5330 100644
35558 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35559 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35560 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35561 i915_gem_clflush_object(obj);
35562
35563 if (obj->base.pending_write_domain)
35564 - flips |= atomic_read(&obj->pending_flip);
35565 + flips |= atomic_read_unchecked(&obj->pending_flip);
35566
35567 flush_domains |= obj->base.write_domain;
35568 }
35569 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35570
35571 static int
35572 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35573 - int count)
35574 + unsigned int count)
35575 {
35576 - int i;
35577 + unsigned int i;
35578 int relocs_total = 0;
35579 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35580
35581 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35582 return -ENOMEM;
35583 }
35584 ret = copy_from_user(exec2_list,
35585 - (struct drm_i915_relocation_entry __user *)
35586 + (struct drm_i915_gem_exec_object2 __user *)
35587 (uintptr_t) args->buffers_ptr,
35588 sizeof(*exec2_list) * args->buffer_count);
35589 if (ret != 0) {
35590 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35591 index 3c59584..500f2e9 100644
35592 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35593 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35594 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35595 (unsigned long)request);
35596 }
35597
35598 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35599 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35600 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35601 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35602 [DRM_I915_GETPARAM] = compat_i915_getparam,
35603 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35604 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35605 {
35606 unsigned int nr = DRM_IOCTL_NR(cmd);
35607 - drm_ioctl_compat_t *fn = NULL;
35608 int ret;
35609
35610 if (nr < DRM_COMMAND_BASE)
35611 return drm_compat_ioctl(filp, cmd, arg);
35612
35613 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35614 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35615 -
35616 - if (fn != NULL)
35617 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35618 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35619 ret = (*fn) (filp, cmd, arg);
35620 - else
35621 + } else
35622 ret = drm_ioctl(filp, cmd, arg);
35623
35624 return ret;
35625 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35626 index fe84338..a863190 100644
35627 --- a/drivers/gpu/drm/i915/i915_irq.c
35628 +++ b/drivers/gpu/drm/i915/i915_irq.c
35629 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35630 u32 pipe_stats[I915_MAX_PIPES];
35631 bool blc_event;
35632
35633 - atomic_inc(&dev_priv->irq_received);
35634 + atomic_inc_unchecked(&dev_priv->irq_received);
35635
35636 while (true) {
35637 iir = I915_READ(VLV_IIR);
35638 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35639 irqreturn_t ret = IRQ_NONE;
35640 int i;
35641
35642 - atomic_inc(&dev_priv->irq_received);
35643 + atomic_inc_unchecked(&dev_priv->irq_received);
35644
35645 /* disable master interrupt before clearing iir */
35646 de_ier = I915_READ(DEIER);
35647 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35648 int ret = IRQ_NONE;
35649 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35650
35651 - atomic_inc(&dev_priv->irq_received);
35652 + atomic_inc_unchecked(&dev_priv->irq_received);
35653
35654 /* disable master interrupt before clearing iir */
35655 de_ier = I915_READ(DEIER);
35656 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35657 {
35658 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35659
35660 - atomic_set(&dev_priv->irq_received, 0);
35661 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35662
35663 I915_WRITE(HWSTAM, 0xeffe);
35664
35665 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35666 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35667 int pipe;
35668
35669 - atomic_set(&dev_priv->irq_received, 0);
35670 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35671
35672 /* VLV magic */
35673 I915_WRITE(VLV_IMR, 0);
35674 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35675 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35676 int pipe;
35677
35678 - atomic_set(&dev_priv->irq_received, 0);
35679 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35680
35681 for_each_pipe(pipe)
35682 I915_WRITE(PIPESTAT(pipe), 0);
35683 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35684 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35685 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35686
35687 - atomic_inc(&dev_priv->irq_received);
35688 + atomic_inc_unchecked(&dev_priv->irq_received);
35689
35690 iir = I915_READ16(IIR);
35691 if (iir == 0)
35692 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35693 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35694 int pipe;
35695
35696 - atomic_set(&dev_priv->irq_received, 0);
35697 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35698
35699 if (I915_HAS_HOTPLUG(dev)) {
35700 I915_WRITE(PORT_HOTPLUG_EN, 0);
35701 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35702 };
35703 int pipe, ret = IRQ_NONE;
35704
35705 - atomic_inc(&dev_priv->irq_received);
35706 + atomic_inc_unchecked(&dev_priv->irq_received);
35707
35708 iir = I915_READ(IIR);
35709 do {
35710 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35711 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35712 int pipe;
35713
35714 - atomic_set(&dev_priv->irq_received, 0);
35715 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35716
35717 I915_WRITE(PORT_HOTPLUG_EN, 0);
35718 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35719 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35720 int irq_received;
35721 int ret = IRQ_NONE, pipe;
35722
35723 - atomic_inc(&dev_priv->irq_received);
35724 + atomic_inc_unchecked(&dev_priv->irq_received);
35725
35726 iir = I915_READ(IIR);
35727
35728 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35729 index d3f834a..0ad1b37 100644
35730 --- a/drivers/gpu/drm/i915/intel_display.c
35731 +++ b/drivers/gpu/drm/i915/intel_display.c
35732 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35733
35734 wait_event(dev_priv->pending_flip_queue,
35735 atomic_read(&dev_priv->mm.wedged) ||
35736 - atomic_read(&obj->pending_flip) == 0);
35737 + atomic_read_unchecked(&obj->pending_flip) == 0);
35738
35739 /* Big Hammer, we also need to ensure that any pending
35740 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35741 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35742
35743 obj = work->old_fb_obj;
35744
35745 - atomic_clear_mask(1 << intel_crtc->plane,
35746 - &obj->pending_flip.counter);
35747 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35748 wake_up(&dev_priv->pending_flip_queue);
35749
35750 queue_work(dev_priv->wq, &work->work);
35751 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35752 /* Block clients from rendering to the new back buffer until
35753 * the flip occurs and the object is no longer visible.
35754 */
35755 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35756 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35757 atomic_inc(&intel_crtc->unpin_work_count);
35758
35759 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35760 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35761 cleanup_pending:
35762 atomic_dec(&intel_crtc->unpin_work_count);
35763 crtc->fb = old_fb;
35764 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35765 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35766 drm_gem_object_unreference(&work->old_fb_obj->base);
35767 drm_gem_object_unreference(&obj->base);
35768 mutex_unlock(&dev->struct_mutex);
35769 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35770 int subsystem_vendor;
35771 int subsystem_device;
35772 void (*hook)(struct drm_device *dev);
35773 -};
35774 +} __do_const;
35775
35776 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35777 struct intel_dmi_quirk {
35778 void (*hook)(struct drm_device *dev);
35779 const struct dmi_system_id (*dmi_id_list)[];
35780 -};
35781 +} __do_const;
35782
35783 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35784 {
35785 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35786 return 1;
35787 }
35788
35789 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35790 + {
35791 + .callback = intel_dmi_reverse_brightness,
35792 + .ident = "NCR Corporation",
35793 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35794 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35795 + },
35796 + },
35797 + { } /* terminating entry */
35798 +};
35799 +
35800 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35801 {
35802 - .dmi_id_list = &(const struct dmi_system_id[]) {
35803 - {
35804 - .callback = intel_dmi_reverse_brightness,
35805 - .ident = "NCR Corporation",
35806 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35807 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35808 - },
35809 - },
35810 - { } /* terminating entry */
35811 - },
35812 + .dmi_id_list = &intel_dmi_quirks_table,
35813 .hook = quirk_invert_brightness,
35814 },
35815 };
35816 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35817 index 54558a0..2d97005 100644
35818 --- a/drivers/gpu/drm/mga/mga_drv.h
35819 +++ b/drivers/gpu/drm/mga/mga_drv.h
35820 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35821 u32 clear_cmd;
35822 u32 maccess;
35823
35824 - atomic_t vbl_received; /**< Number of vblanks received. */
35825 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35826 wait_queue_head_t fence_queue;
35827 - atomic_t last_fence_retired;
35828 + atomic_unchecked_t last_fence_retired;
35829 u32 next_fence_to_post;
35830
35831 unsigned int fb_cpp;
35832 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35833 index 709e90d..89a1c0d 100644
35834 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35835 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35836 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35837 return 0;
35838 }
35839
35840 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35841 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35842 [DRM_MGA_INIT] = compat_mga_init,
35843 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35844 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35845 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35846 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35847 {
35848 unsigned int nr = DRM_IOCTL_NR(cmd);
35849 - drm_ioctl_compat_t *fn = NULL;
35850 int ret;
35851
35852 if (nr < DRM_COMMAND_BASE)
35853 return drm_compat_ioctl(filp, cmd, arg);
35854
35855 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35856 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35857 -
35858 - if (fn != NULL)
35859 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35860 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35861 ret = (*fn) (filp, cmd, arg);
35862 - else
35863 + } else
35864 ret = drm_ioctl(filp, cmd, arg);
35865
35866 return ret;
35867 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35868 index 598c281..60d590e 100644
35869 --- a/drivers/gpu/drm/mga/mga_irq.c
35870 +++ b/drivers/gpu/drm/mga/mga_irq.c
35871 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35872 if (crtc != 0)
35873 return 0;
35874
35875 - return atomic_read(&dev_priv->vbl_received);
35876 + return atomic_read_unchecked(&dev_priv->vbl_received);
35877 }
35878
35879
35880 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35881 /* VBLANK interrupt */
35882 if (status & MGA_VLINEPEN) {
35883 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35884 - atomic_inc(&dev_priv->vbl_received);
35885 + atomic_inc_unchecked(&dev_priv->vbl_received);
35886 drm_handle_vblank(dev, 0);
35887 handled = 1;
35888 }
35889 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35890 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35891 MGA_WRITE(MGA_PRIMEND, prim_end);
35892
35893 - atomic_inc(&dev_priv->last_fence_retired);
35894 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35895 DRM_WAKEUP(&dev_priv->fence_queue);
35896 handled = 1;
35897 }
35898 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35899 * using fences.
35900 */
35901 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35902 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35903 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35904 - *sequence) <= (1 << 23)));
35905
35906 *sequence = cur_fence;
35907 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35908 index 865eddf..62c4cc3 100644
35909 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35910 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35911 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35912 struct bit_table {
35913 const char id;
35914 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35915 -};
35916 +} __no_const;
35917
35918 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35919
35920 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35921 index aa89eb9..d45d38b 100644
35922 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35923 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35924 @@ -80,7 +80,7 @@ struct nouveau_drm {
35925 struct drm_global_reference mem_global_ref;
35926 struct ttm_bo_global_ref bo_global_ref;
35927 struct ttm_bo_device bdev;
35928 - atomic_t validate_sequence;
35929 + atomic_unchecked_t validate_sequence;
35930 int (*move)(struct nouveau_channel *,
35931 struct ttm_buffer_object *,
35932 struct ttm_mem_reg *, struct ttm_mem_reg *);
35933 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35934 index cdb83ac..27f0a16 100644
35935 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35936 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35937 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35938 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35939 struct nouveau_channel *);
35940 u32 (*read)(struct nouveau_channel *);
35941 -};
35942 +} __no_const;
35943
35944 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35945
35946 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35947 index 8bf695c..9fbc90a 100644
35948 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35949 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35950 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35951 int trycnt = 0;
35952 int ret, i;
35953
35954 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35955 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35956 retry:
35957 if (++trycnt > 100000) {
35958 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35959 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35960 index 08214bc..9208577 100644
35961 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35962 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35963 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35964 unsigned long arg)
35965 {
35966 unsigned int nr = DRM_IOCTL_NR(cmd);
35967 - drm_ioctl_compat_t *fn = NULL;
35968 + drm_ioctl_compat_t fn = NULL;
35969 int ret;
35970
35971 if (nr < DRM_COMMAND_BASE)
35972 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35973 index 25d3495..d81aaf6 100644
35974 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35975 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35976 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35977 bool can_switch;
35978
35979 spin_lock(&dev->count_lock);
35980 - can_switch = (dev->open_count == 0);
35981 + can_switch = (local_read(&dev->open_count) == 0);
35982 spin_unlock(&dev->count_lock);
35983 return can_switch;
35984 }
35985 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35986 index d4660cf..70dbe65 100644
35987 --- a/drivers/gpu/drm/r128/r128_cce.c
35988 +++ b/drivers/gpu/drm/r128/r128_cce.c
35989 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35990
35991 /* GH: Simple idle check.
35992 */
35993 - atomic_set(&dev_priv->idle_count, 0);
35994 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35995
35996 /* We don't support anything other than bus-mastering ring mode,
35997 * but the ring can be in either AGP or PCI space for the ring
35998 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35999 index 930c71b..499aded 100644
36000 --- a/drivers/gpu/drm/r128/r128_drv.h
36001 +++ b/drivers/gpu/drm/r128/r128_drv.h
36002 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36003 int is_pci;
36004 unsigned long cce_buffers_offset;
36005
36006 - atomic_t idle_count;
36007 + atomic_unchecked_t idle_count;
36008
36009 int page_flipping;
36010 int current_page;
36011 u32 crtc_offset;
36012 u32 crtc_offset_cntl;
36013
36014 - atomic_t vbl_received;
36015 + atomic_unchecked_t vbl_received;
36016
36017 u32 color_fmt;
36018 unsigned int front_offset;
36019 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36020 index a954c54..9cc595c 100644
36021 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36022 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36023 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36024 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36025 }
36026
36027 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36028 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36029 [DRM_R128_INIT] = compat_r128_init,
36030 [DRM_R128_DEPTH] = compat_r128_depth,
36031 [DRM_R128_STIPPLE] = compat_r128_stipple,
36032 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36033 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36034 {
36035 unsigned int nr = DRM_IOCTL_NR(cmd);
36036 - drm_ioctl_compat_t *fn = NULL;
36037 int ret;
36038
36039 if (nr < DRM_COMMAND_BASE)
36040 return drm_compat_ioctl(filp, cmd, arg);
36041
36042 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36043 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36044 -
36045 - if (fn != NULL)
36046 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36047 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36048 ret = (*fn) (filp, cmd, arg);
36049 - else
36050 + } else
36051 ret = drm_ioctl(filp, cmd, arg);
36052
36053 return ret;
36054 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36055 index 2ea4f09..d391371 100644
36056 --- a/drivers/gpu/drm/r128/r128_irq.c
36057 +++ b/drivers/gpu/drm/r128/r128_irq.c
36058 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36059 if (crtc != 0)
36060 return 0;
36061
36062 - return atomic_read(&dev_priv->vbl_received);
36063 + return atomic_read_unchecked(&dev_priv->vbl_received);
36064 }
36065
36066 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36067 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36068 /* VBLANK interrupt */
36069 if (status & R128_CRTC_VBLANK_INT) {
36070 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36071 - atomic_inc(&dev_priv->vbl_received);
36072 + atomic_inc_unchecked(&dev_priv->vbl_received);
36073 drm_handle_vblank(dev, 0);
36074 return IRQ_HANDLED;
36075 }
36076 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36077 index 19bb7e6..de7e2a2 100644
36078 --- a/drivers/gpu/drm/r128/r128_state.c
36079 +++ b/drivers/gpu/drm/r128/r128_state.c
36080 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36081
36082 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36083 {
36084 - if (atomic_read(&dev_priv->idle_count) == 0)
36085 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36086 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36087 else
36088 - atomic_set(&dev_priv->idle_count, 0);
36089 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36090 }
36091
36092 #endif
36093 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36094 index 5a82b6b..9e69c73 100644
36095 --- a/drivers/gpu/drm/radeon/mkregtable.c
36096 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36097 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36098 regex_t mask_rex;
36099 regmatch_t match[4];
36100 char buf[1024];
36101 - size_t end;
36102 + long end;
36103 int len;
36104 int done = 0;
36105 int r;
36106 unsigned o;
36107 struct offset *offset;
36108 char last_reg_s[10];
36109 - int last_reg;
36110 + unsigned long last_reg;
36111
36112 if (regcomp
36113 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36114 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36115 index 0d6562b..a154330 100644
36116 --- a/drivers/gpu/drm/radeon/radeon_device.c
36117 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36118 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36119 bool can_switch;
36120
36121 spin_lock(&dev->count_lock);
36122 - can_switch = (dev->open_count == 0);
36123 + can_switch = (local_read(&dev->open_count) == 0);
36124 spin_unlock(&dev->count_lock);
36125 return can_switch;
36126 }
36127 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36128 index e7fdf16..f4f6490 100644
36129 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36130 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36131 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36132
36133 /* SW interrupt */
36134 wait_queue_head_t swi_queue;
36135 - atomic_t swi_emitted;
36136 + atomic_unchecked_t swi_emitted;
36137 int vblank_crtc;
36138 uint32_t irq_enable_reg;
36139 uint32_t r500_disp_irq_reg;
36140 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36141 index c180df8..5fd8186 100644
36142 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36143 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36144 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36145 request = compat_alloc_user_space(sizeof(*request));
36146 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36147 || __put_user(req32.param, &request->param)
36148 - || __put_user((void __user *)(unsigned long)req32.value,
36149 + || __put_user((unsigned long)req32.value,
36150 &request->value))
36151 return -EFAULT;
36152
36153 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36154 #define compat_radeon_cp_setparam NULL
36155 #endif /* X86_64 || IA64 */
36156
36157 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36158 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36159 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36160 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36161 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36162 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36163 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36164 {
36165 unsigned int nr = DRM_IOCTL_NR(cmd);
36166 - drm_ioctl_compat_t *fn = NULL;
36167 int ret;
36168
36169 if (nr < DRM_COMMAND_BASE)
36170 return drm_compat_ioctl(filp, cmd, arg);
36171
36172 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36173 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36174 -
36175 - if (fn != NULL)
36176 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36177 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36178 ret = (*fn) (filp, cmd, arg);
36179 - else
36180 + } else
36181 ret = drm_ioctl(filp, cmd, arg);
36182
36183 return ret;
36184 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36185 index e771033..a0bc6b3 100644
36186 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36187 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36188 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36189 unsigned int ret;
36190 RING_LOCALS;
36191
36192 - atomic_inc(&dev_priv->swi_emitted);
36193 - ret = atomic_read(&dev_priv->swi_emitted);
36194 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36195 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36196
36197 BEGIN_RING(4);
36198 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36199 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36200 drm_radeon_private_t *dev_priv =
36201 (drm_radeon_private_t *) dev->dev_private;
36202
36203 - atomic_set(&dev_priv->swi_emitted, 0);
36204 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36205 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36206
36207 dev->max_vblank_count = 0x001fffff;
36208 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36209 index 8e9057b..af6dacb 100644
36210 --- a/drivers/gpu/drm/radeon/radeon_state.c
36211 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36212 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36213 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36214 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36215
36216 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36217 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36218 sarea_priv->nbox * sizeof(depth_boxes[0])))
36219 return -EFAULT;
36220
36221 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36222 {
36223 drm_radeon_private_t *dev_priv = dev->dev_private;
36224 drm_radeon_getparam_t *param = data;
36225 - int value;
36226 + int value = 0;
36227
36228 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36229
36230 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36231 index 93f760e..8088227 100644
36232 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36233 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36234 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36235 man->size = size >> PAGE_SHIFT;
36236 }
36237
36238 -static struct vm_operations_struct radeon_ttm_vm_ops;
36239 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36240 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36241
36242 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36243 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36244 }
36245 if (unlikely(ttm_vm_ops == NULL)) {
36246 ttm_vm_ops = vma->vm_ops;
36247 + pax_open_kernel();
36248 radeon_ttm_vm_ops = *ttm_vm_ops;
36249 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36250 + pax_close_kernel();
36251 }
36252 vma->vm_ops = &radeon_ttm_vm_ops;
36253 return 0;
36254 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36255 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36256 else
36257 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36258 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36259 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36260 - radeon_mem_types_list[i].driver_features = 0;
36261 + pax_open_kernel();
36262 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36263 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36264 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36265 if (i == 0)
36266 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36267 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36268 else
36269 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36270 -
36271 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36272 + pax_close_kernel();
36273 }
36274 /* Add ttm page pool to debugfs */
36275 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36276 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36277 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36278 - radeon_mem_types_list[i].driver_features = 0;
36279 - radeon_mem_types_list[i++].data = NULL;
36280 + pax_open_kernel();
36281 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36282 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36283 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36284 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36285 + pax_close_kernel();
36286 #ifdef CONFIG_SWIOTLB
36287 if (swiotlb_nr_tbl()) {
36288 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36289 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36290 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36291 - radeon_mem_types_list[i].driver_features = 0;
36292 - radeon_mem_types_list[i++].data = NULL;
36293 + pax_open_kernel();
36294 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36295 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36296 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36297 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36298 + pax_close_kernel();
36299 }
36300 #endif
36301 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36302 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36303 index 5706d2a..17aedaa 100644
36304 --- a/drivers/gpu/drm/radeon/rs690.c
36305 +++ b/drivers/gpu/drm/radeon/rs690.c
36306 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36307 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36308 rdev->pm.sideport_bandwidth.full)
36309 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36310 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36311 + read_delay_latency.full = dfixed_const(800 * 1000);
36312 read_delay_latency.full = dfixed_div(read_delay_latency,
36313 rdev->pm.igp_sideport_mclk);
36314 + a.full = dfixed_const(370);
36315 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36316 } else {
36317 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36318 rdev->pm.k8_bandwidth.full)
36319 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36320 index bd2a3b4..122d9ad 100644
36321 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36322 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36323 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36324 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36325 struct shrink_control *sc)
36326 {
36327 - static atomic_t start_pool = ATOMIC_INIT(0);
36328 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36329 unsigned i;
36330 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36331 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36332 struct ttm_page_pool *pool;
36333 int shrink_pages = sc->nr_to_scan;
36334
36335 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36336 index 1eb060c..188b1fc 100644
36337 --- a/drivers/gpu/drm/udl/udl_fb.c
36338 +++ b/drivers/gpu/drm/udl/udl_fb.c
36339 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36340 fb_deferred_io_cleanup(info);
36341 kfree(info->fbdefio);
36342 info->fbdefio = NULL;
36343 - info->fbops->fb_mmap = udl_fb_mmap;
36344 }
36345
36346 pr_warn("released /dev/fb%d user=%d count=%d\n",
36347 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36348 index 893a650..6190d3b 100644
36349 --- a/drivers/gpu/drm/via/via_drv.h
36350 +++ b/drivers/gpu/drm/via/via_drv.h
36351 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36352 typedef uint32_t maskarray_t[5];
36353
36354 typedef struct drm_via_irq {
36355 - atomic_t irq_received;
36356 + atomic_unchecked_t irq_received;
36357 uint32_t pending_mask;
36358 uint32_t enable_mask;
36359 wait_queue_head_t irq_queue;
36360 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36361 struct timeval last_vblank;
36362 int last_vblank_valid;
36363 unsigned usec_per_vblank;
36364 - atomic_t vbl_received;
36365 + atomic_unchecked_t vbl_received;
36366 drm_via_state_t hc_state;
36367 char pci_buf[VIA_PCI_BUF_SIZE];
36368 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36369 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36370 index ac98964..5dbf512 100644
36371 --- a/drivers/gpu/drm/via/via_irq.c
36372 +++ b/drivers/gpu/drm/via/via_irq.c
36373 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36374 if (crtc != 0)
36375 return 0;
36376
36377 - return atomic_read(&dev_priv->vbl_received);
36378 + return atomic_read_unchecked(&dev_priv->vbl_received);
36379 }
36380
36381 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36382 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36383
36384 status = VIA_READ(VIA_REG_INTERRUPT);
36385 if (status & VIA_IRQ_VBLANK_PENDING) {
36386 - atomic_inc(&dev_priv->vbl_received);
36387 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36388 + atomic_inc_unchecked(&dev_priv->vbl_received);
36389 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36390 do_gettimeofday(&cur_vblank);
36391 if (dev_priv->last_vblank_valid) {
36392 dev_priv->usec_per_vblank =
36393 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36394 dev_priv->last_vblank = cur_vblank;
36395 dev_priv->last_vblank_valid = 1;
36396 }
36397 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36398 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36399 DRM_DEBUG("US per vblank is: %u\n",
36400 dev_priv->usec_per_vblank);
36401 }
36402 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36403
36404 for (i = 0; i < dev_priv->num_irqs; ++i) {
36405 if (status & cur_irq->pending_mask) {
36406 - atomic_inc(&cur_irq->irq_received);
36407 + atomic_inc_unchecked(&cur_irq->irq_received);
36408 DRM_WAKEUP(&cur_irq->irq_queue);
36409 handled = 1;
36410 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36411 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36412 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36413 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36414 masks[irq][4]));
36415 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36416 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36417 } else {
36418 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36419 (((cur_irq_sequence =
36420 - atomic_read(&cur_irq->irq_received)) -
36421 + atomic_read_unchecked(&cur_irq->irq_received)) -
36422 *sequence) <= (1 << 23)));
36423 }
36424 *sequence = cur_irq_sequence;
36425 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36426 }
36427
36428 for (i = 0; i < dev_priv->num_irqs; ++i) {
36429 - atomic_set(&cur_irq->irq_received, 0);
36430 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36431 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36432 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36433 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36434 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36435 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36436 case VIA_IRQ_RELATIVE:
36437 irqwait->request.sequence +=
36438 - atomic_read(&cur_irq->irq_received);
36439 + atomic_read_unchecked(&cur_irq->irq_received);
36440 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36441 case VIA_IRQ_ABSOLUTE:
36442 break;
36443 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36444 index 13aeda7..4a952d1 100644
36445 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36446 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36447 @@ -290,7 +290,7 @@ struct vmw_private {
36448 * Fencing and IRQs.
36449 */
36450
36451 - atomic_t marker_seq;
36452 + atomic_unchecked_t marker_seq;
36453 wait_queue_head_t fence_queue;
36454 wait_queue_head_t fifo_queue;
36455 int fence_queue_waiters; /* Protected by hw_mutex */
36456 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36457 index 3eb1486..0a47ee9 100644
36458 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36459 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36460 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36461 (unsigned int) min,
36462 (unsigned int) fifo->capabilities);
36463
36464 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36465 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36466 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36467 vmw_marker_queue_init(&fifo->marker_queue);
36468 return vmw_fifo_send_fence(dev_priv, &dummy);
36469 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36470 if (reserveable)
36471 iowrite32(bytes, fifo_mem +
36472 SVGA_FIFO_RESERVED);
36473 - return fifo_mem + (next_cmd >> 2);
36474 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36475 } else {
36476 need_bounce = true;
36477 }
36478 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36479
36480 fm = vmw_fifo_reserve(dev_priv, bytes);
36481 if (unlikely(fm == NULL)) {
36482 - *seqno = atomic_read(&dev_priv->marker_seq);
36483 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36484 ret = -ENOMEM;
36485 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36486 false, 3*HZ);
36487 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36488 }
36489
36490 do {
36491 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36492 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36493 } while (*seqno == 0);
36494
36495 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36496 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36497 index 4640adb..e1384ed 100644
36498 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36499 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36500 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36501 * emitted. Then the fence is stale and signaled.
36502 */
36503
36504 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36505 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36506 > VMW_FENCE_WRAP);
36507
36508 return ret;
36509 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36510
36511 if (fifo_idle)
36512 down_read(&fifo_state->rwsem);
36513 - signal_seq = atomic_read(&dev_priv->marker_seq);
36514 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36515 ret = 0;
36516
36517 for (;;) {
36518 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36519 index 8a8725c..afed796 100644
36520 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36521 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36522 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36523 while (!vmw_lag_lt(queue, us)) {
36524 spin_lock(&queue->lock);
36525 if (list_empty(&queue->head))
36526 - seqno = atomic_read(&dev_priv->marker_seq);
36527 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36528 else {
36529 marker = list_first_entry(&queue->head,
36530 struct vmw_marker, head);
36531 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36532 index ceb3040..6160c5c 100644
36533 --- a/drivers/hid/hid-core.c
36534 +++ b/drivers/hid/hid-core.c
36535 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36536
36537 int hid_add_device(struct hid_device *hdev)
36538 {
36539 - static atomic_t id = ATOMIC_INIT(0);
36540 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36541 int ret;
36542
36543 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36544 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36545 /* XXX hack, any other cleaner solution after the driver core
36546 * is converted to allow more than 20 bytes as the device name? */
36547 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36548 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36549 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36550
36551 hid_debug_register(hdev, dev_name(&hdev->dev));
36552 ret = device_add(&hdev->dev);
36553 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36554 index eec3291..8ed706b 100644
36555 --- a/drivers/hid/hid-wiimote-debug.c
36556 +++ b/drivers/hid/hid-wiimote-debug.c
36557 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36558 else if (size == 0)
36559 return -EIO;
36560
36561 - if (copy_to_user(u, buf, size))
36562 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36563 return -EFAULT;
36564
36565 *off += size;
36566 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36567 index 773a2f2..7ce08bc 100644
36568 --- a/drivers/hv/channel.c
36569 +++ b/drivers/hv/channel.c
36570 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36571 int ret = 0;
36572 int t;
36573
36574 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36575 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36576 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36577 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36578
36579 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36580 if (ret)
36581 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36582 index 3648f8f..30ef30d 100644
36583 --- a/drivers/hv/hv.c
36584 +++ b/drivers/hv/hv.c
36585 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36586 u64 output_address = (output) ? virt_to_phys(output) : 0;
36587 u32 output_address_hi = output_address >> 32;
36588 u32 output_address_lo = output_address & 0xFFFFFFFF;
36589 - void *hypercall_page = hv_context.hypercall_page;
36590 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36591
36592 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36593 "=a"(hv_status_lo) : "d" (control_hi),
36594 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36595 index d8d1fad..b91caf7 100644
36596 --- a/drivers/hv/hyperv_vmbus.h
36597 +++ b/drivers/hv/hyperv_vmbus.h
36598 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36599 struct vmbus_connection {
36600 enum vmbus_connect_state conn_state;
36601
36602 - atomic_t next_gpadl_handle;
36603 + atomic_unchecked_t next_gpadl_handle;
36604
36605 /*
36606 * Represents channel interrupts. Each bit position represents a
36607 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36608 index 8e1a9ec..4687821 100644
36609 --- a/drivers/hv/vmbus_drv.c
36610 +++ b/drivers/hv/vmbus_drv.c
36611 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36612 {
36613 int ret = 0;
36614
36615 - static atomic_t device_num = ATOMIC_INIT(0);
36616 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36617
36618 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36619 - atomic_inc_return(&device_num));
36620 + atomic_inc_return_unchecked(&device_num));
36621
36622 child_device_obj->device.bus = &hv_bus;
36623 child_device_obj->device.parent = &hv_acpi_dev->dev;
36624 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36625 index 1672e2a..4a6297c 100644
36626 --- a/drivers/hwmon/acpi_power_meter.c
36627 +++ b/drivers/hwmon/acpi_power_meter.c
36628 @@ -117,7 +117,7 @@ struct sensor_template {
36629 struct device_attribute *devattr,
36630 const char *buf, size_t count);
36631 int index;
36632 -};
36633 +} __do_const;
36634
36635 /* Averaging interval */
36636 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36637 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36638 struct sensor_template *attrs)
36639 {
36640 struct device *dev = &resource->acpi_dev->dev;
36641 - struct sensor_device_attribute *sensors =
36642 + sensor_device_attribute_no_const *sensors =
36643 &resource->sensors[resource->num_sensors];
36644 int res = 0;
36645
36646 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36647 index b41baff..4953e4d 100644
36648 --- a/drivers/hwmon/applesmc.c
36649 +++ b/drivers/hwmon/applesmc.c
36650 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36651 {
36652 struct applesmc_node_group *grp;
36653 struct applesmc_dev_attr *node;
36654 - struct attribute *attr;
36655 + attribute_no_const *attr;
36656 int ret, i;
36657
36658 for (grp = groups; grp->format; grp++) {
36659 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36660 index 56dbcfb..9874bf1 100644
36661 --- a/drivers/hwmon/asus_atk0110.c
36662 +++ b/drivers/hwmon/asus_atk0110.c
36663 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36664 struct atk_sensor_data {
36665 struct list_head list;
36666 struct atk_data *data;
36667 - struct device_attribute label_attr;
36668 - struct device_attribute input_attr;
36669 - struct device_attribute limit1_attr;
36670 - struct device_attribute limit2_attr;
36671 + device_attribute_no_const label_attr;
36672 + device_attribute_no_const input_attr;
36673 + device_attribute_no_const limit1_attr;
36674 + device_attribute_no_const limit2_attr;
36675 char label_attr_name[ATTR_NAME_SIZE];
36676 char input_attr_name[ATTR_NAME_SIZE];
36677 char limit1_attr_name[ATTR_NAME_SIZE];
36678 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36679 static struct device_attribute atk_name_attr =
36680 __ATTR(name, 0444, atk_name_show, NULL);
36681
36682 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36683 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36684 sysfs_show_func show)
36685 {
36686 sysfs_attr_init(&attr->attr);
36687 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36688 index d64923d..72591e8 100644
36689 --- a/drivers/hwmon/coretemp.c
36690 +++ b/drivers/hwmon/coretemp.c
36691 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36692 return NOTIFY_OK;
36693 }
36694
36695 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36696 +static struct notifier_block coretemp_cpu_notifier = {
36697 .notifier_call = coretemp_cpu_callback,
36698 };
36699
36700 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36701 index a14f634..2916ee2 100644
36702 --- a/drivers/hwmon/ibmaem.c
36703 +++ b/drivers/hwmon/ibmaem.c
36704 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36705 struct aem_rw_sensor_template *rw)
36706 {
36707 struct device *dev = &data->pdev->dev;
36708 - struct sensor_device_attribute *sensors = data->sensors;
36709 + sensor_device_attribute_no_const *sensors = data->sensors;
36710 int err;
36711
36712 /* Set up read-only sensors */
36713 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36714 index 7d19b1b..8fdaaac 100644
36715 --- a/drivers/hwmon/pmbus/pmbus_core.c
36716 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36717 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36718
36719 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36720 do { \
36721 - struct sensor_device_attribute *a \
36722 + sensor_device_attribute_no_const *a \
36723 = &data->_type##s[data->num_##_type##s].attribute; \
36724 BUG_ON(data->num_attributes >= data->max_attributes); \
36725 sysfs_attr_init(&a->dev_attr.attr); \
36726 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36727 index 8047fed..1e956f0 100644
36728 --- a/drivers/hwmon/sht15.c
36729 +++ b/drivers/hwmon/sht15.c
36730 @@ -169,7 +169,7 @@ struct sht15_data {
36731 int supply_uV;
36732 bool supply_uV_valid;
36733 struct work_struct update_supply_work;
36734 - atomic_t interrupt_handled;
36735 + atomic_unchecked_t interrupt_handled;
36736 };
36737
36738 /**
36739 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36740 return ret;
36741
36742 gpio_direction_input(data->pdata->gpio_data);
36743 - atomic_set(&data->interrupt_handled, 0);
36744 + atomic_set_unchecked(&data->interrupt_handled, 0);
36745
36746 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36747 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36748 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36749 /* Only relevant if the interrupt hasn't occurred. */
36750 - if (!atomic_read(&data->interrupt_handled))
36751 + if (!atomic_read_unchecked(&data->interrupt_handled))
36752 schedule_work(&data->read_work);
36753 }
36754 ret = wait_event_timeout(data->wait_queue,
36755 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36756
36757 /* First disable the interrupt */
36758 disable_irq_nosync(irq);
36759 - atomic_inc(&data->interrupt_handled);
36760 + atomic_inc_unchecked(&data->interrupt_handled);
36761 /* Then schedule a reading work struct */
36762 if (data->state != SHT15_READING_NOTHING)
36763 schedule_work(&data->read_work);
36764 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36765 * If not, then start the interrupt again - care here as could
36766 * have gone low in meantime so verify it hasn't!
36767 */
36768 - atomic_set(&data->interrupt_handled, 0);
36769 + atomic_set_unchecked(&data->interrupt_handled, 0);
36770 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36771 /* If still not occurred or another handler was scheduled */
36772 if (gpio_get_value(data->pdata->gpio_data)
36773 - || atomic_read(&data->interrupt_handled))
36774 + || atomic_read_unchecked(&data->interrupt_handled))
36775 return;
36776 }
36777
36778 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36779 index 76f157b..9c0db1b 100644
36780 --- a/drivers/hwmon/via-cputemp.c
36781 +++ b/drivers/hwmon/via-cputemp.c
36782 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36783 return NOTIFY_OK;
36784 }
36785
36786 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36787 +static struct notifier_block via_cputemp_cpu_notifier = {
36788 .notifier_call = via_cputemp_cpu_callback,
36789 };
36790
36791 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36792 index 378fcb5..5e91fa8 100644
36793 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36794 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36795 @@ -43,7 +43,7 @@
36796 extern struct i2c_adapter amd756_smbus;
36797
36798 static struct i2c_adapter *s4882_adapter;
36799 -static struct i2c_algorithm *s4882_algo;
36800 +static i2c_algorithm_no_const *s4882_algo;
36801
36802 /* Wrapper access functions for multiplexed SMBus */
36803 static DEFINE_MUTEX(amd756_lock);
36804 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36805 index 29015eb..af2d8e9 100644
36806 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36807 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36808 @@ -41,7 +41,7 @@
36809 extern struct i2c_adapter *nforce2_smbus;
36810
36811 static struct i2c_adapter *s4985_adapter;
36812 -static struct i2c_algorithm *s4985_algo;
36813 +static i2c_algorithm_no_const *s4985_algo;
36814
36815 /* Wrapper access functions for multiplexed SMBus */
36816 static DEFINE_MUTEX(nforce2_lock);
36817 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36818 index 8126824..55a2798 100644
36819 --- a/drivers/ide/ide-cd.c
36820 +++ b/drivers/ide/ide-cd.c
36821 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36822 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36823 if ((unsigned long)buf & alignment
36824 || blk_rq_bytes(rq) & q->dma_pad_mask
36825 - || object_is_on_stack(buf))
36826 + || object_starts_on_stack(buf))
36827 drive->dma = 0;
36828 }
36829 }
36830 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36831 index 8848f16..f8e6dd8 100644
36832 --- a/drivers/iio/industrialio-core.c
36833 +++ b/drivers/iio/industrialio-core.c
36834 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36835 }
36836
36837 static
36838 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36839 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36840 const char *postfix,
36841 struct iio_chan_spec const *chan,
36842 ssize_t (*readfunc)(struct device *dev,
36843 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36844 index 394fea2..c833880 100644
36845 --- a/drivers/infiniband/core/cm.c
36846 +++ b/drivers/infiniband/core/cm.c
36847 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36848
36849 struct cm_counter_group {
36850 struct kobject obj;
36851 - atomic_long_t counter[CM_ATTR_COUNT];
36852 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36853 };
36854
36855 struct cm_counter_attribute {
36856 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36857 struct ib_mad_send_buf *msg = NULL;
36858 int ret;
36859
36860 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36861 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36862 counter[CM_REQ_COUNTER]);
36863
36864 /* Quick state check to discard duplicate REQs. */
36865 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36866 if (!cm_id_priv)
36867 return;
36868
36869 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36870 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36871 counter[CM_REP_COUNTER]);
36872 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36873 if (ret)
36874 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36875 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36876 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36877 spin_unlock_irq(&cm_id_priv->lock);
36878 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36879 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36880 counter[CM_RTU_COUNTER]);
36881 goto out;
36882 }
36883 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36884 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36885 dreq_msg->local_comm_id);
36886 if (!cm_id_priv) {
36887 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36888 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36889 counter[CM_DREQ_COUNTER]);
36890 cm_issue_drep(work->port, work->mad_recv_wc);
36891 return -EINVAL;
36892 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36893 case IB_CM_MRA_REP_RCVD:
36894 break;
36895 case IB_CM_TIMEWAIT:
36896 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36897 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36898 counter[CM_DREQ_COUNTER]);
36899 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36900 goto unlock;
36901 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36902 cm_free_msg(msg);
36903 goto deref;
36904 case IB_CM_DREQ_RCVD:
36905 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36906 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36907 counter[CM_DREQ_COUNTER]);
36908 goto unlock;
36909 default:
36910 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36911 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36912 cm_id_priv->msg, timeout)) {
36913 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36914 - atomic_long_inc(&work->port->
36915 + atomic_long_inc_unchecked(&work->port->
36916 counter_group[CM_RECV_DUPLICATES].
36917 counter[CM_MRA_COUNTER]);
36918 goto out;
36919 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36920 break;
36921 case IB_CM_MRA_REQ_RCVD:
36922 case IB_CM_MRA_REP_RCVD:
36923 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36924 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36925 counter[CM_MRA_COUNTER]);
36926 /* fall through */
36927 default:
36928 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36929 case IB_CM_LAP_IDLE:
36930 break;
36931 case IB_CM_MRA_LAP_SENT:
36932 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36933 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36934 counter[CM_LAP_COUNTER]);
36935 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36936 goto unlock;
36937 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36938 cm_free_msg(msg);
36939 goto deref;
36940 case IB_CM_LAP_RCVD:
36941 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36942 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36943 counter[CM_LAP_COUNTER]);
36944 goto unlock;
36945 default:
36946 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36947 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36948 if (cur_cm_id_priv) {
36949 spin_unlock_irq(&cm.lock);
36950 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36951 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36952 counter[CM_SIDR_REQ_COUNTER]);
36953 goto out; /* Duplicate message. */
36954 }
36955 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36956 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36957 msg->retries = 1;
36958
36959 - atomic_long_add(1 + msg->retries,
36960 + atomic_long_add_unchecked(1 + msg->retries,
36961 &port->counter_group[CM_XMIT].counter[attr_index]);
36962 if (msg->retries)
36963 - atomic_long_add(msg->retries,
36964 + atomic_long_add_unchecked(msg->retries,
36965 &port->counter_group[CM_XMIT_RETRIES].
36966 counter[attr_index]);
36967
36968 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36969 }
36970
36971 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36972 - atomic_long_inc(&port->counter_group[CM_RECV].
36973 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36974 counter[attr_id - CM_ATTR_ID_OFFSET]);
36975
36976 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36977 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36978 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36979
36980 return sprintf(buf, "%ld\n",
36981 - atomic_long_read(&group->counter[cm_attr->index]));
36982 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36983 }
36984
36985 static const struct sysfs_ops cm_counter_ops = {
36986 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36987 index 176c8f9..2627b62 100644
36988 --- a/drivers/infiniband/core/fmr_pool.c
36989 +++ b/drivers/infiniband/core/fmr_pool.c
36990 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36991
36992 struct task_struct *thread;
36993
36994 - atomic_t req_ser;
36995 - atomic_t flush_ser;
36996 + atomic_unchecked_t req_ser;
36997 + atomic_unchecked_t flush_ser;
36998
36999 wait_queue_head_t force_wait;
37000 };
37001 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37002 struct ib_fmr_pool *pool = pool_ptr;
37003
37004 do {
37005 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37006 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37007 ib_fmr_batch_release(pool);
37008
37009 - atomic_inc(&pool->flush_ser);
37010 + atomic_inc_unchecked(&pool->flush_ser);
37011 wake_up_interruptible(&pool->force_wait);
37012
37013 if (pool->flush_function)
37014 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37015 }
37016
37017 set_current_state(TASK_INTERRUPTIBLE);
37018 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37019 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37020 !kthread_should_stop())
37021 schedule();
37022 __set_current_state(TASK_RUNNING);
37023 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37024 pool->dirty_watermark = params->dirty_watermark;
37025 pool->dirty_len = 0;
37026 spin_lock_init(&pool->pool_lock);
37027 - atomic_set(&pool->req_ser, 0);
37028 - atomic_set(&pool->flush_ser, 0);
37029 + atomic_set_unchecked(&pool->req_ser, 0);
37030 + atomic_set_unchecked(&pool->flush_ser, 0);
37031 init_waitqueue_head(&pool->force_wait);
37032
37033 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37034 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37035 }
37036 spin_unlock_irq(&pool->pool_lock);
37037
37038 - serial = atomic_inc_return(&pool->req_ser);
37039 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37040 wake_up_process(pool->thread);
37041
37042 if (wait_event_interruptible(pool->force_wait,
37043 - atomic_read(&pool->flush_ser) - serial >= 0))
37044 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37045 return -EINTR;
37046
37047 return 0;
37048 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37049 } else {
37050 list_add_tail(&fmr->list, &pool->dirty_list);
37051 if (++pool->dirty_len >= pool->dirty_watermark) {
37052 - atomic_inc(&pool->req_ser);
37053 + atomic_inc_unchecked(&pool->req_ser);
37054 wake_up_process(pool->thread);
37055 }
37056 }
37057 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37058 index afd8179..598063f 100644
37059 --- a/drivers/infiniband/hw/cxgb4/mem.c
37060 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37061 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37062 int err;
37063 struct fw_ri_tpte tpt;
37064 u32 stag_idx;
37065 - static atomic_t key;
37066 + static atomic_unchecked_t key;
37067
37068 if (c4iw_fatal_error(rdev))
37069 return -EIO;
37070 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37071 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37072 rdev->stats.stag.max = rdev->stats.stag.cur;
37073 mutex_unlock(&rdev->stats.lock);
37074 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37075 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37076 }
37077 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37078 __func__, stag_state, type, pdid, stag_idx);
37079 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37080 index 79b3dbc..96e5fcc 100644
37081 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37082 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37083 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37084 struct ib_atomic_eth *ateth;
37085 struct ipath_ack_entry *e;
37086 u64 vaddr;
37087 - atomic64_t *maddr;
37088 + atomic64_unchecked_t *maddr;
37089 u64 sdata;
37090 u32 rkey;
37091 u8 next;
37092 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37093 IB_ACCESS_REMOTE_ATOMIC)))
37094 goto nack_acc_unlck;
37095 /* Perform atomic OP and save result. */
37096 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37097 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37098 sdata = be64_to_cpu(ateth->swap_data);
37099 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37100 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37101 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37102 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37103 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37104 be64_to_cpu(ateth->compare_data),
37105 sdata);
37106 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37107 index 1f95bba..9530f87 100644
37108 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37109 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37110 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37111 unsigned long flags;
37112 struct ib_wc wc;
37113 u64 sdata;
37114 - atomic64_t *maddr;
37115 + atomic64_unchecked_t *maddr;
37116 enum ib_wc_status send_status;
37117
37118 /*
37119 @@ -382,11 +382,11 @@ again:
37120 IB_ACCESS_REMOTE_ATOMIC)))
37121 goto acc_err;
37122 /* Perform atomic OP and save result. */
37123 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37124 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37125 sdata = wqe->wr.wr.atomic.compare_add;
37126 *(u64 *) sqp->s_sge.sge.vaddr =
37127 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37128 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37129 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37130 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37131 sdata, wqe->wr.wr.atomic.swap);
37132 goto send_comp;
37133 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37134 index 9d3e5c1..d9afe4a 100644
37135 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37136 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37137 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37138 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37139 }
37140
37141 -int mthca_QUERY_FW(struct mthca_dev *dev)
37142 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37143 {
37144 struct mthca_mailbox *mailbox;
37145 u32 *outbox;
37146 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37147 index ed9a989..e0c5871 100644
37148 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37149 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37150 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37151 return key;
37152 }
37153
37154 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37155 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37156 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37157 {
37158 struct mthca_mailbox *mailbox;
37159 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37160 index 5b152a3..c1f3e83 100644
37161 --- a/drivers/infiniband/hw/nes/nes.c
37162 +++ b/drivers/infiniband/hw/nes/nes.c
37163 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37164 LIST_HEAD(nes_adapter_list);
37165 static LIST_HEAD(nes_dev_list);
37166
37167 -atomic_t qps_destroyed;
37168 +atomic_unchecked_t qps_destroyed;
37169
37170 static unsigned int ee_flsh_adapter;
37171 static unsigned int sysfs_nonidx_addr;
37172 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37173 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37174 struct nes_adapter *nesadapter = nesdev->nesadapter;
37175
37176 - atomic_inc(&qps_destroyed);
37177 + atomic_inc_unchecked(&qps_destroyed);
37178
37179 /* Free the control structures */
37180
37181 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37182 index 33cc589..3bd6538 100644
37183 --- a/drivers/infiniband/hw/nes/nes.h
37184 +++ b/drivers/infiniband/hw/nes/nes.h
37185 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37186 extern unsigned int wqm_quanta;
37187 extern struct list_head nes_adapter_list;
37188
37189 -extern atomic_t cm_connects;
37190 -extern atomic_t cm_accepts;
37191 -extern atomic_t cm_disconnects;
37192 -extern atomic_t cm_closes;
37193 -extern atomic_t cm_connecteds;
37194 -extern atomic_t cm_connect_reqs;
37195 -extern atomic_t cm_rejects;
37196 -extern atomic_t mod_qp_timouts;
37197 -extern atomic_t qps_created;
37198 -extern atomic_t qps_destroyed;
37199 -extern atomic_t sw_qps_destroyed;
37200 +extern atomic_unchecked_t cm_connects;
37201 +extern atomic_unchecked_t cm_accepts;
37202 +extern atomic_unchecked_t cm_disconnects;
37203 +extern atomic_unchecked_t cm_closes;
37204 +extern atomic_unchecked_t cm_connecteds;
37205 +extern atomic_unchecked_t cm_connect_reqs;
37206 +extern atomic_unchecked_t cm_rejects;
37207 +extern atomic_unchecked_t mod_qp_timouts;
37208 +extern atomic_unchecked_t qps_created;
37209 +extern atomic_unchecked_t qps_destroyed;
37210 +extern atomic_unchecked_t sw_qps_destroyed;
37211 extern u32 mh_detected;
37212 extern u32 mh_pauses_sent;
37213 extern u32 cm_packets_sent;
37214 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37215 extern u32 cm_packets_received;
37216 extern u32 cm_packets_dropped;
37217 extern u32 cm_packets_retrans;
37218 -extern atomic_t cm_listens_created;
37219 -extern atomic_t cm_listens_destroyed;
37220 +extern atomic_unchecked_t cm_listens_created;
37221 +extern atomic_unchecked_t cm_listens_destroyed;
37222 extern u32 cm_backlog_drops;
37223 -extern atomic_t cm_loopbacks;
37224 -extern atomic_t cm_nodes_created;
37225 -extern atomic_t cm_nodes_destroyed;
37226 -extern atomic_t cm_accel_dropped_pkts;
37227 -extern atomic_t cm_resets_recvd;
37228 -extern atomic_t pau_qps_created;
37229 -extern atomic_t pau_qps_destroyed;
37230 +extern atomic_unchecked_t cm_loopbacks;
37231 +extern atomic_unchecked_t cm_nodes_created;
37232 +extern atomic_unchecked_t cm_nodes_destroyed;
37233 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37234 +extern atomic_unchecked_t cm_resets_recvd;
37235 +extern atomic_unchecked_t pau_qps_created;
37236 +extern atomic_unchecked_t pau_qps_destroyed;
37237
37238 extern u32 int_mod_timer_init;
37239 extern u32 int_mod_cq_depth_256;
37240 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37241 index 22ea67e..dcbe3bc 100644
37242 --- a/drivers/infiniband/hw/nes/nes_cm.c
37243 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37244 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37245 u32 cm_packets_retrans;
37246 u32 cm_packets_created;
37247 u32 cm_packets_received;
37248 -atomic_t cm_listens_created;
37249 -atomic_t cm_listens_destroyed;
37250 +atomic_unchecked_t cm_listens_created;
37251 +atomic_unchecked_t cm_listens_destroyed;
37252 u32 cm_backlog_drops;
37253 -atomic_t cm_loopbacks;
37254 -atomic_t cm_nodes_created;
37255 -atomic_t cm_nodes_destroyed;
37256 -atomic_t cm_accel_dropped_pkts;
37257 -atomic_t cm_resets_recvd;
37258 +atomic_unchecked_t cm_loopbacks;
37259 +atomic_unchecked_t cm_nodes_created;
37260 +atomic_unchecked_t cm_nodes_destroyed;
37261 +atomic_unchecked_t cm_accel_dropped_pkts;
37262 +atomic_unchecked_t cm_resets_recvd;
37263
37264 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37265 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37266 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37267
37268 static struct nes_cm_core *g_cm_core;
37269
37270 -atomic_t cm_connects;
37271 -atomic_t cm_accepts;
37272 -atomic_t cm_disconnects;
37273 -atomic_t cm_closes;
37274 -atomic_t cm_connecteds;
37275 -atomic_t cm_connect_reqs;
37276 -atomic_t cm_rejects;
37277 +atomic_unchecked_t cm_connects;
37278 +atomic_unchecked_t cm_accepts;
37279 +atomic_unchecked_t cm_disconnects;
37280 +atomic_unchecked_t cm_closes;
37281 +atomic_unchecked_t cm_connecteds;
37282 +atomic_unchecked_t cm_connect_reqs;
37283 +atomic_unchecked_t cm_rejects;
37284
37285 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37286 {
37287 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37288 kfree(listener);
37289 listener = NULL;
37290 ret = 0;
37291 - atomic_inc(&cm_listens_destroyed);
37292 + atomic_inc_unchecked(&cm_listens_destroyed);
37293 } else {
37294 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37295 }
37296 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37297 cm_node->rem_mac);
37298
37299 add_hte_node(cm_core, cm_node);
37300 - atomic_inc(&cm_nodes_created);
37301 + atomic_inc_unchecked(&cm_nodes_created);
37302
37303 return cm_node;
37304 }
37305 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37306 }
37307
37308 atomic_dec(&cm_core->node_cnt);
37309 - atomic_inc(&cm_nodes_destroyed);
37310 + atomic_inc_unchecked(&cm_nodes_destroyed);
37311 nesqp = cm_node->nesqp;
37312 if (nesqp) {
37313 nesqp->cm_node = NULL;
37314 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37315
37316 static void drop_packet(struct sk_buff *skb)
37317 {
37318 - atomic_inc(&cm_accel_dropped_pkts);
37319 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37320 dev_kfree_skb_any(skb);
37321 }
37322
37323 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37324 {
37325
37326 int reset = 0; /* whether to send reset in case of err.. */
37327 - atomic_inc(&cm_resets_recvd);
37328 + atomic_inc_unchecked(&cm_resets_recvd);
37329 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37330 " refcnt=%d\n", cm_node, cm_node->state,
37331 atomic_read(&cm_node->ref_count));
37332 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37333 rem_ref_cm_node(cm_node->cm_core, cm_node);
37334 return NULL;
37335 }
37336 - atomic_inc(&cm_loopbacks);
37337 + atomic_inc_unchecked(&cm_loopbacks);
37338 loopbackremotenode->loopbackpartner = cm_node;
37339 loopbackremotenode->tcp_cntxt.rcv_wscale =
37340 NES_CM_DEFAULT_RCV_WND_SCALE;
37341 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37342 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37343 else {
37344 rem_ref_cm_node(cm_core, cm_node);
37345 - atomic_inc(&cm_accel_dropped_pkts);
37346 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37347 dev_kfree_skb_any(skb);
37348 }
37349 break;
37350 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37351
37352 if ((cm_id) && (cm_id->event_handler)) {
37353 if (issue_disconn) {
37354 - atomic_inc(&cm_disconnects);
37355 + atomic_inc_unchecked(&cm_disconnects);
37356 cm_event.event = IW_CM_EVENT_DISCONNECT;
37357 cm_event.status = disconn_status;
37358 cm_event.local_addr = cm_id->local_addr;
37359 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37360 }
37361
37362 if (issue_close) {
37363 - atomic_inc(&cm_closes);
37364 + atomic_inc_unchecked(&cm_closes);
37365 nes_disconnect(nesqp, 1);
37366
37367 cm_id->provider_data = nesqp;
37368 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37369
37370 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37371 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37372 - atomic_inc(&cm_accepts);
37373 + atomic_inc_unchecked(&cm_accepts);
37374
37375 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37376 netdev_refcnt_read(nesvnic->netdev));
37377 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37378 struct nes_cm_core *cm_core;
37379 u8 *start_buff;
37380
37381 - atomic_inc(&cm_rejects);
37382 + atomic_inc_unchecked(&cm_rejects);
37383 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37384 loopback = cm_node->loopbackpartner;
37385 cm_core = cm_node->cm_core;
37386 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37387 ntohl(cm_id->local_addr.sin_addr.s_addr),
37388 ntohs(cm_id->local_addr.sin_port));
37389
37390 - atomic_inc(&cm_connects);
37391 + atomic_inc_unchecked(&cm_connects);
37392 nesqp->active_conn = 1;
37393
37394 /* cache the cm_id in the qp */
37395 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37396 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37397 return err;
37398 }
37399 - atomic_inc(&cm_listens_created);
37400 + atomic_inc_unchecked(&cm_listens_created);
37401 }
37402
37403 cm_id->add_ref(cm_id);
37404 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37405
37406 if (nesqp->destroyed)
37407 return;
37408 - atomic_inc(&cm_connecteds);
37409 + atomic_inc_unchecked(&cm_connecteds);
37410 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37411 " local port 0x%04X. jiffies = %lu.\n",
37412 nesqp->hwqp.qp_id,
37413 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37414
37415 cm_id->add_ref(cm_id);
37416 ret = cm_id->event_handler(cm_id, &cm_event);
37417 - atomic_inc(&cm_closes);
37418 + atomic_inc_unchecked(&cm_closes);
37419 cm_event.event = IW_CM_EVENT_CLOSE;
37420 cm_event.status = 0;
37421 cm_event.provider_data = cm_id->provider_data;
37422 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37423 return;
37424 cm_id = cm_node->cm_id;
37425
37426 - atomic_inc(&cm_connect_reqs);
37427 + atomic_inc_unchecked(&cm_connect_reqs);
37428 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37429 cm_node, cm_id, jiffies);
37430
37431 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37432 return;
37433 cm_id = cm_node->cm_id;
37434
37435 - atomic_inc(&cm_connect_reqs);
37436 + atomic_inc_unchecked(&cm_connect_reqs);
37437 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37438 cm_node, cm_id, jiffies);
37439
37440 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37441 index 4166452..fc952c3 100644
37442 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37443 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37444 @@ -40,8 +40,8 @@
37445 #include "nes.h"
37446 #include "nes_mgt.h"
37447
37448 -atomic_t pau_qps_created;
37449 -atomic_t pau_qps_destroyed;
37450 +atomic_unchecked_t pau_qps_created;
37451 +atomic_unchecked_t pau_qps_destroyed;
37452
37453 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37454 {
37455 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37456 {
37457 struct sk_buff *skb;
37458 unsigned long flags;
37459 - atomic_inc(&pau_qps_destroyed);
37460 + atomic_inc_unchecked(&pau_qps_destroyed);
37461
37462 /* Free packets that have not yet been forwarded */
37463 /* Lock is acquired by skb_dequeue when removing the skb */
37464 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37465 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37466 skb_queue_head_init(&nesqp->pau_list);
37467 spin_lock_init(&nesqp->pau_lock);
37468 - atomic_inc(&pau_qps_created);
37469 + atomic_inc_unchecked(&pau_qps_created);
37470 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37471 }
37472
37473 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37474 index 9542e16..a008c40 100644
37475 --- a/drivers/infiniband/hw/nes/nes_nic.c
37476 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37477 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37478 target_stat_values[++index] = mh_detected;
37479 target_stat_values[++index] = mh_pauses_sent;
37480 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37481 - target_stat_values[++index] = atomic_read(&cm_connects);
37482 - target_stat_values[++index] = atomic_read(&cm_accepts);
37483 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37484 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37485 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37486 - target_stat_values[++index] = atomic_read(&cm_rejects);
37487 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37488 - target_stat_values[++index] = atomic_read(&qps_created);
37489 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37490 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37491 - target_stat_values[++index] = atomic_read(&cm_closes);
37492 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37493 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37494 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37495 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37496 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37497 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37498 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37499 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37500 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37501 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37502 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37503 target_stat_values[++index] = cm_packets_sent;
37504 target_stat_values[++index] = cm_packets_bounced;
37505 target_stat_values[++index] = cm_packets_created;
37506 target_stat_values[++index] = cm_packets_received;
37507 target_stat_values[++index] = cm_packets_dropped;
37508 target_stat_values[++index] = cm_packets_retrans;
37509 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37510 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37511 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37512 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37513 target_stat_values[++index] = cm_backlog_drops;
37514 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37515 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37516 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37517 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37518 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37519 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37520 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37521 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37522 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37523 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37524 target_stat_values[++index] = nesadapter->free_4kpbl;
37525 target_stat_values[++index] = nesadapter->free_256pbl;
37526 target_stat_values[++index] = int_mod_timer_init;
37527 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37528 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37529 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37530 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37531 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37532 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37533 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37534 }
37535
37536 /**
37537 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37538 index 07e4fba..685f041 100644
37539 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37540 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37541 @@ -46,9 +46,9 @@
37542
37543 #include <rdma/ib_umem.h>
37544
37545 -atomic_t mod_qp_timouts;
37546 -atomic_t qps_created;
37547 -atomic_t sw_qps_destroyed;
37548 +atomic_unchecked_t mod_qp_timouts;
37549 +atomic_unchecked_t qps_created;
37550 +atomic_unchecked_t sw_qps_destroyed;
37551
37552 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37553
37554 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37555 if (init_attr->create_flags)
37556 return ERR_PTR(-EINVAL);
37557
37558 - atomic_inc(&qps_created);
37559 + atomic_inc_unchecked(&qps_created);
37560 switch (init_attr->qp_type) {
37561 case IB_QPT_RC:
37562 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37563 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37564 struct iw_cm_event cm_event;
37565 int ret = 0;
37566
37567 - atomic_inc(&sw_qps_destroyed);
37568 + atomic_inc_unchecked(&sw_qps_destroyed);
37569 nesqp->destroyed = 1;
37570
37571 /* Blow away the connection if it exists. */
37572 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37573 index 4d11575..3e890e5 100644
37574 --- a/drivers/infiniband/hw/qib/qib.h
37575 +++ b/drivers/infiniband/hw/qib/qib.h
37576 @@ -51,6 +51,7 @@
37577 #include <linux/completion.h>
37578 #include <linux/kref.h>
37579 #include <linux/sched.h>
37580 +#include <linux/slab.h>
37581
37582 #include "qib_common.h"
37583 #include "qib_verbs.h"
37584 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37585 index da739d9..da1c7f4 100644
37586 --- a/drivers/input/gameport/gameport.c
37587 +++ b/drivers/input/gameport/gameport.c
37588 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37589 */
37590 static void gameport_init_port(struct gameport *gameport)
37591 {
37592 - static atomic_t gameport_no = ATOMIC_INIT(0);
37593 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37594
37595 __module_get(THIS_MODULE);
37596
37597 mutex_init(&gameport->drv_mutex);
37598 device_initialize(&gameport->dev);
37599 dev_set_name(&gameport->dev, "gameport%lu",
37600 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37601 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37602 gameport->dev.bus = &gameport_bus;
37603 gameport->dev.release = gameport_release_port;
37604 if (gameport->parent)
37605 diff --git a/drivers/input/input.c b/drivers/input/input.c
37606 index c044699..174d71a 100644
37607 --- a/drivers/input/input.c
37608 +++ b/drivers/input/input.c
37609 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37610 */
37611 int input_register_device(struct input_dev *dev)
37612 {
37613 - static atomic_t input_no = ATOMIC_INIT(0);
37614 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37615 struct input_devres *devres = NULL;
37616 struct input_handler *handler;
37617 unsigned int packet_size;
37618 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37619 dev->setkeycode = input_default_setkeycode;
37620
37621 dev_set_name(&dev->dev, "input%ld",
37622 - (unsigned long) atomic_inc_return(&input_no) - 1);
37623 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37624
37625 error = device_add(&dev->dev);
37626 if (error)
37627 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37628 index 04c69af..5f92d00 100644
37629 --- a/drivers/input/joystick/sidewinder.c
37630 +++ b/drivers/input/joystick/sidewinder.c
37631 @@ -30,6 +30,7 @@
37632 #include <linux/kernel.h>
37633 #include <linux/module.h>
37634 #include <linux/slab.h>
37635 +#include <linux/sched.h>
37636 #include <linux/init.h>
37637 #include <linux/input.h>
37638 #include <linux/gameport.h>
37639 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37640 index d6cbfe9..6225402 100644
37641 --- a/drivers/input/joystick/xpad.c
37642 +++ b/drivers/input/joystick/xpad.c
37643 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37644
37645 static int xpad_led_probe(struct usb_xpad *xpad)
37646 {
37647 - static atomic_t led_seq = ATOMIC_INIT(0);
37648 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37649 long led_no;
37650 struct xpad_led *led;
37651 struct led_classdev *led_cdev;
37652 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37653 if (!led)
37654 return -ENOMEM;
37655
37656 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37657 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37658
37659 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37660 led->xpad = xpad;
37661 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37662 index fe1df23..5b710f3 100644
37663 --- a/drivers/input/mouse/psmouse.h
37664 +++ b/drivers/input/mouse/psmouse.h
37665 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37666 ssize_t (*set)(struct psmouse *psmouse, void *data,
37667 const char *buf, size_t count);
37668 bool protect;
37669 -};
37670 +} __do_const;
37671 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37672
37673 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37674 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37675 index 4c842c3..590b0bf 100644
37676 --- a/drivers/input/mousedev.c
37677 +++ b/drivers/input/mousedev.c
37678 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37679
37680 spin_unlock_irq(&client->packet_lock);
37681
37682 - if (copy_to_user(buffer, data, count))
37683 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37684 return -EFAULT;
37685
37686 return count;
37687 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37688 index 25fc597..558bf3b 100644
37689 --- a/drivers/input/serio/serio.c
37690 +++ b/drivers/input/serio/serio.c
37691 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37692 */
37693 static void serio_init_port(struct serio *serio)
37694 {
37695 - static atomic_t serio_no = ATOMIC_INIT(0);
37696 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37697
37698 __module_get(THIS_MODULE);
37699
37700 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37701 mutex_init(&serio->drv_mutex);
37702 device_initialize(&serio->dev);
37703 dev_set_name(&serio->dev, "serio%ld",
37704 - (long)atomic_inc_return(&serio_no) - 1);
37705 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37706 serio->dev.bus = &serio_bus;
37707 serio->dev.release = serio_release_port;
37708 serio->dev.groups = serio_device_attr_groups;
37709 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37710 index ddbdaca..be18a78 100644
37711 --- a/drivers/iommu/iommu.c
37712 +++ b/drivers/iommu/iommu.c
37713 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37714 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37715 {
37716 bus_register_notifier(bus, &iommu_bus_nb);
37717 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37718 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37719 }
37720
37721 /**
37722 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37723 index 89562a8..218999b 100644
37724 --- a/drivers/isdn/capi/capi.c
37725 +++ b/drivers/isdn/capi/capi.c
37726 @@ -81,8 +81,8 @@ struct capiminor {
37727
37728 struct capi20_appl *ap;
37729 u32 ncci;
37730 - atomic_t datahandle;
37731 - atomic_t msgid;
37732 + atomic_unchecked_t datahandle;
37733 + atomic_unchecked_t msgid;
37734
37735 struct tty_port port;
37736 int ttyinstop;
37737 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37738 capimsg_setu16(s, 2, mp->ap->applid);
37739 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37740 capimsg_setu8 (s, 5, CAPI_RESP);
37741 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37742 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37743 capimsg_setu32(s, 8, mp->ncci);
37744 capimsg_setu16(s, 12, datahandle);
37745 }
37746 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37747 mp->outbytes -= len;
37748 spin_unlock_bh(&mp->outlock);
37749
37750 - datahandle = atomic_inc_return(&mp->datahandle);
37751 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37752 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37753 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37754 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37755 capimsg_setu16(skb->data, 2, mp->ap->applid);
37756 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37757 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37758 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37759 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37760 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37761 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37762 capimsg_setu16(skb->data, 16, len); /* Data length */
37763 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37764 index 67abf3f..076b3a6 100644
37765 --- a/drivers/isdn/gigaset/interface.c
37766 +++ b/drivers/isdn/gigaset/interface.c
37767 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37768 }
37769 tty->driver_data = cs;
37770
37771 - ++cs->port.count;
37772 + atomic_inc(&cs->port.count);
37773
37774 - if (cs->port.count == 1) {
37775 + if (atomic_read(&cs->port.count) == 1) {
37776 tty_port_tty_set(&cs->port, tty);
37777 tty->low_latency = 1;
37778 }
37779 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37780
37781 if (!cs->connected)
37782 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37783 - else if (!cs->port.count)
37784 + else if (!atomic_read(&cs->port.count))
37785 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37786 - else if (!--cs->port.count)
37787 + else if (!atomic_dec_return(&cs->port.count))
37788 tty_port_tty_set(&cs->port, NULL);
37789
37790 mutex_unlock(&cs->mutex);
37791 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37792 index 821f7ac..28d4030 100644
37793 --- a/drivers/isdn/hardware/avm/b1.c
37794 +++ b/drivers/isdn/hardware/avm/b1.c
37795 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37796 }
37797 if (left) {
37798 if (t4file->user) {
37799 - if (copy_from_user(buf, dp, left))
37800 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37801 return -EFAULT;
37802 } else {
37803 memcpy(buf, dp, left);
37804 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37805 }
37806 if (left) {
37807 if (config->user) {
37808 - if (copy_from_user(buf, dp, left))
37809 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37810 return -EFAULT;
37811 } else {
37812 memcpy(buf, dp, left);
37813 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37814 index e09dc8a..15e2efb 100644
37815 --- a/drivers/isdn/i4l/isdn_tty.c
37816 +++ b/drivers/isdn/i4l/isdn_tty.c
37817 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37818
37819 #ifdef ISDN_DEBUG_MODEM_OPEN
37820 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37821 - port->count);
37822 + atomic_read(&port->count));
37823 #endif
37824 - port->count++;
37825 + atomic_inc(&port->count);
37826 port->tty = tty;
37827 /*
37828 * Start up serial port
37829 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37830 #endif
37831 return;
37832 }
37833 - if ((tty->count == 1) && (port->count != 1)) {
37834 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37835 /*
37836 * Uh, oh. tty->count is 1, which means that the tty
37837 * structure will be freed. Info->count should always
37838 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37839 * serial port won't be shutdown.
37840 */
37841 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37842 - "info->count is %d\n", port->count);
37843 - port->count = 1;
37844 + "info->count is %d\n", atomic_read(&port->count));
37845 + atomic_set(&port->count, 1);
37846 }
37847 - if (--port->count < 0) {
37848 + if (atomic_dec_return(&port->count) < 0) {
37849 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37850 - info->line, port->count);
37851 - port->count = 0;
37852 + info->line, atomic_read(&port->count));
37853 + atomic_set(&port->count, 0);
37854 }
37855 - if (port->count) {
37856 + if (atomic_read(&port->count)) {
37857 #ifdef ISDN_DEBUG_MODEM_OPEN
37858 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37859 #endif
37860 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37861 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37862 return;
37863 isdn_tty_shutdown(info);
37864 - port->count = 0;
37865 + atomic_set(&port->count, 0);
37866 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37867 port->tty = NULL;
37868 wake_up_interruptible(&port->open_wait);
37869 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37870 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37871 modem_info *info = &dev->mdm.info[i];
37872
37873 - if (info->port.count == 0)
37874 + if (atomic_read(&info->port.count) == 0)
37875 continue;
37876 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37877 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37878 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37879 index e74df7c..03a03ba 100644
37880 --- a/drivers/isdn/icn/icn.c
37881 +++ b/drivers/isdn/icn/icn.c
37882 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37883 if (count > len)
37884 count = len;
37885 if (user) {
37886 - if (copy_from_user(msg, buf, count))
37887 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37888 return -EFAULT;
37889 } else
37890 memcpy(msg, buf, count);
37891 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37892 index 6a8405d..0bd1c7e 100644
37893 --- a/drivers/leds/leds-clevo-mail.c
37894 +++ b/drivers/leds/leds-clevo-mail.c
37895 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37896 * detected as working, but in reality it is not) as low as
37897 * possible.
37898 */
37899 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37900 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37901 {
37902 .callback = clevo_mail_led_dmi_callback,
37903 .ident = "Clevo D410J",
37904 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37905 index ec9b287..65c9bf4 100644
37906 --- a/drivers/leds/leds-ss4200.c
37907 +++ b/drivers/leds/leds-ss4200.c
37908 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37909 * detected as working, but in reality it is not) as low as
37910 * possible.
37911 */
37912 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37913 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37914 {
37915 .callback = ss4200_led_dmi_callback,
37916 .ident = "Intel SS4200-E",
37917 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37918 index a5ebc00..982886f 100644
37919 --- a/drivers/lguest/core.c
37920 +++ b/drivers/lguest/core.c
37921 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37922 * it's worked so far. The end address needs +1 because __get_vm_area
37923 * allocates an extra guard page, so we need space for that.
37924 */
37925 +
37926 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37927 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37928 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37929 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37930 +#else
37931 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37932 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37933 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37934 +#endif
37935 +
37936 if (!switcher_vma) {
37937 err = -ENOMEM;
37938 printk("lguest: could not map switcher pages high\n");
37939 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37940 * Now the Switcher is mapped at the right address, we can't fail!
37941 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37942 */
37943 - memcpy(switcher_vma->addr, start_switcher_text,
37944 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37945 end_switcher_text - start_switcher_text);
37946
37947 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37948 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37949 index 3b62be16..e33134a 100644
37950 --- a/drivers/lguest/page_tables.c
37951 +++ b/drivers/lguest/page_tables.c
37952 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37953 /*:*/
37954
37955 #ifdef CONFIG_X86_PAE
37956 -static void release_pmd(pmd_t *spmd)
37957 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37958 {
37959 /* If the entry's not present, there's nothing to release. */
37960 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37961 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37962 index 4af12e1..0e89afe 100644
37963 --- a/drivers/lguest/x86/core.c
37964 +++ b/drivers/lguest/x86/core.c
37965 @@ -59,7 +59,7 @@ static struct {
37966 /* Offset from where switcher.S was compiled to where we've copied it */
37967 static unsigned long switcher_offset(void)
37968 {
37969 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37970 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37971 }
37972
37973 /* This cpu's struct lguest_pages. */
37974 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37975 * These copies are pretty cheap, so we do them unconditionally: */
37976 /* Save the current Host top-level page directory.
37977 */
37978 +
37979 +#ifdef CONFIG_PAX_PER_CPU_PGD
37980 + pages->state.host_cr3 = read_cr3();
37981 +#else
37982 pages->state.host_cr3 = __pa(current->mm->pgd);
37983 +#endif
37984 +
37985 /*
37986 * Set up the Guest's page tables to see this CPU's pages (and no
37987 * other CPU's pages).
37988 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37989 * compiled-in switcher code and the high-mapped copy we just made.
37990 */
37991 for (i = 0; i < IDT_ENTRIES; i++)
37992 - default_idt_entries[i] += switcher_offset();
37993 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37994
37995 /*
37996 * Set up the Switcher's per-cpu areas.
37997 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37998 * it will be undisturbed when we switch. To change %cs and jump we
37999 * need this structure to feed to Intel's "lcall" instruction.
38000 */
38001 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38002 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38003 lguest_entry.segment = LGUEST_CS;
38004
38005 /*
38006 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38007 index 40634b0..4f5855e 100644
38008 --- a/drivers/lguest/x86/switcher_32.S
38009 +++ b/drivers/lguest/x86/switcher_32.S
38010 @@ -87,6 +87,7 @@
38011 #include <asm/page.h>
38012 #include <asm/segment.h>
38013 #include <asm/lguest.h>
38014 +#include <asm/processor-flags.h>
38015
38016 // We mark the start of the code to copy
38017 // It's placed in .text tho it's never run here
38018 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38019 // Changes type when we load it: damn Intel!
38020 // For after we switch over our page tables
38021 // That entry will be read-only: we'd crash.
38022 +
38023 +#ifdef CONFIG_PAX_KERNEXEC
38024 + mov %cr0, %edx
38025 + xor $X86_CR0_WP, %edx
38026 + mov %edx, %cr0
38027 +#endif
38028 +
38029 movl $(GDT_ENTRY_TSS*8), %edx
38030 ltr %dx
38031
38032 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38033 // Let's clear it again for our return.
38034 // The GDT descriptor of the Host
38035 // Points to the table after two "size" bytes
38036 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38037 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38038 // Clear "used" from type field (byte 5, bit 2)
38039 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38040 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38041 +
38042 +#ifdef CONFIG_PAX_KERNEXEC
38043 + mov %cr0, %eax
38044 + xor $X86_CR0_WP, %eax
38045 + mov %eax, %cr0
38046 +#endif
38047
38048 // Once our page table's switched, the Guest is live!
38049 // The Host fades as we run this final step.
38050 @@ -295,13 +309,12 @@ deliver_to_host:
38051 // I consulted gcc, and it gave
38052 // These instructions, which I gladly credit:
38053 leal (%edx,%ebx,8), %eax
38054 - movzwl (%eax),%edx
38055 - movl 4(%eax), %eax
38056 - xorw %ax, %ax
38057 - orl %eax, %edx
38058 + movl 4(%eax), %edx
38059 + movw (%eax), %dx
38060 // Now the address of the handler's in %edx
38061 // We call it now: its "iret" drops us home.
38062 - jmp *%edx
38063 + ljmp $__KERNEL_CS, $1f
38064 +1: jmp *%edx
38065
38066 // Every interrupt can come to us here
38067 // But we must truly tell each apart.
38068 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38069 index 7155945..4bcc562 100644
38070 --- a/drivers/md/bitmap.c
38071 +++ b/drivers/md/bitmap.c
38072 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38073 chunk_kb ? "KB" : "B");
38074 if (bitmap->storage.file) {
38075 seq_printf(seq, ", file: ");
38076 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38077 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38078 }
38079
38080 seq_printf(seq, "\n");
38081 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38082 index eee353d..74504c4 100644
38083 --- a/drivers/md/dm-ioctl.c
38084 +++ b/drivers/md/dm-ioctl.c
38085 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38086 cmd == DM_LIST_VERSIONS_CMD)
38087 return 0;
38088
38089 - if ((cmd == DM_DEV_CREATE_CMD)) {
38090 + if (cmd == DM_DEV_CREATE_CMD) {
38091 if (!*param->name) {
38092 DMWARN("name not supplied when creating device");
38093 return -EINVAL;
38094 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38095 index 7f24190..0e18099 100644
38096 --- a/drivers/md/dm-raid1.c
38097 +++ b/drivers/md/dm-raid1.c
38098 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38099
38100 struct mirror {
38101 struct mirror_set *ms;
38102 - atomic_t error_count;
38103 + atomic_unchecked_t error_count;
38104 unsigned long error_type;
38105 struct dm_dev *dev;
38106 sector_t offset;
38107 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38108 struct mirror *m;
38109
38110 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38111 - if (!atomic_read(&m->error_count))
38112 + if (!atomic_read_unchecked(&m->error_count))
38113 return m;
38114
38115 return NULL;
38116 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38117 * simple way to tell if a device has encountered
38118 * errors.
38119 */
38120 - atomic_inc(&m->error_count);
38121 + atomic_inc_unchecked(&m->error_count);
38122
38123 if (test_and_set_bit(error_type, &m->error_type))
38124 return;
38125 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38126 struct mirror *m = get_default_mirror(ms);
38127
38128 do {
38129 - if (likely(!atomic_read(&m->error_count)))
38130 + if (likely(!atomic_read_unchecked(&m->error_count)))
38131 return m;
38132
38133 if (m-- == ms->mirror)
38134 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38135 {
38136 struct mirror *default_mirror = get_default_mirror(m->ms);
38137
38138 - return !atomic_read(&default_mirror->error_count);
38139 + return !atomic_read_unchecked(&default_mirror->error_count);
38140 }
38141
38142 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38143 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38144 */
38145 if (likely(region_in_sync(ms, region, 1)))
38146 m = choose_mirror(ms, bio->bi_sector);
38147 - else if (m && atomic_read(&m->error_count))
38148 + else if (m && atomic_read_unchecked(&m->error_count))
38149 m = NULL;
38150
38151 if (likely(m))
38152 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38153 }
38154
38155 ms->mirror[mirror].ms = ms;
38156 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38157 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38158 ms->mirror[mirror].error_type = 0;
38159 ms->mirror[mirror].offset = offset;
38160
38161 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38162 */
38163 static char device_status_char(struct mirror *m)
38164 {
38165 - if (!atomic_read(&(m->error_count)))
38166 + if (!atomic_read_unchecked(&(m->error_count)))
38167 return 'A';
38168
38169 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38170 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38171 index aaecefa..23b3026 100644
38172 --- a/drivers/md/dm-stripe.c
38173 +++ b/drivers/md/dm-stripe.c
38174 @@ -20,7 +20,7 @@ struct stripe {
38175 struct dm_dev *dev;
38176 sector_t physical_start;
38177
38178 - atomic_t error_count;
38179 + atomic_unchecked_t error_count;
38180 };
38181
38182 struct stripe_c {
38183 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38184 kfree(sc);
38185 return r;
38186 }
38187 - atomic_set(&(sc->stripe[i].error_count), 0);
38188 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38189 }
38190
38191 ti->private = sc;
38192 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38193 DMEMIT("%d ", sc->stripes);
38194 for (i = 0; i < sc->stripes; i++) {
38195 DMEMIT("%s ", sc->stripe[i].dev->name);
38196 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38197 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38198 'D' : 'A';
38199 }
38200 buffer[i] = '\0';
38201 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38202 */
38203 for (i = 0; i < sc->stripes; i++)
38204 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38205 - atomic_inc(&(sc->stripe[i].error_count));
38206 - if (atomic_read(&(sc->stripe[i].error_count)) <
38207 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38208 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38209 DM_IO_ERROR_THRESHOLD)
38210 schedule_work(&sc->trigger_event);
38211 }
38212 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38213 index daf25d0..d74f49f 100644
38214 --- a/drivers/md/dm-table.c
38215 +++ b/drivers/md/dm-table.c
38216 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38217 if (!dev_size)
38218 return 0;
38219
38220 - if ((start >= dev_size) || (start + len > dev_size)) {
38221 + if ((start >= dev_size) || (len > dev_size - start)) {
38222 DMWARN("%s: %s too small for target: "
38223 "start=%llu, len=%llu, dev_size=%llu",
38224 dm_device_name(ti->table->md), bdevname(bdev, b),
38225 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38226 index 4d6e853..a234157 100644
38227 --- a/drivers/md/dm-thin-metadata.c
38228 +++ b/drivers/md/dm-thin-metadata.c
38229 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38230 {
38231 pmd->info.tm = pmd->tm;
38232 pmd->info.levels = 2;
38233 - pmd->info.value_type.context = pmd->data_sm;
38234 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38235 pmd->info.value_type.size = sizeof(__le64);
38236 pmd->info.value_type.inc = data_block_inc;
38237 pmd->info.value_type.dec = data_block_dec;
38238 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38239
38240 pmd->bl_info.tm = pmd->tm;
38241 pmd->bl_info.levels = 1;
38242 - pmd->bl_info.value_type.context = pmd->data_sm;
38243 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38244 pmd->bl_info.value_type.size = sizeof(__le64);
38245 pmd->bl_info.value_type.inc = data_block_inc;
38246 pmd->bl_info.value_type.dec = data_block_dec;
38247 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38248 index 0d8f086..f5a91d5 100644
38249 --- a/drivers/md/dm.c
38250 +++ b/drivers/md/dm.c
38251 @@ -170,9 +170,9 @@ struct mapped_device {
38252 /*
38253 * Event handling.
38254 */
38255 - atomic_t event_nr;
38256 + atomic_unchecked_t event_nr;
38257 wait_queue_head_t eventq;
38258 - atomic_t uevent_seq;
38259 + atomic_unchecked_t uevent_seq;
38260 struct list_head uevent_list;
38261 spinlock_t uevent_lock; /* Protect access to uevent_list */
38262
38263 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38264 rwlock_init(&md->map_lock);
38265 atomic_set(&md->holders, 1);
38266 atomic_set(&md->open_count, 0);
38267 - atomic_set(&md->event_nr, 0);
38268 - atomic_set(&md->uevent_seq, 0);
38269 + atomic_set_unchecked(&md->event_nr, 0);
38270 + atomic_set_unchecked(&md->uevent_seq, 0);
38271 INIT_LIST_HEAD(&md->uevent_list);
38272 spin_lock_init(&md->uevent_lock);
38273
38274 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38275
38276 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38277
38278 - atomic_inc(&md->event_nr);
38279 + atomic_inc_unchecked(&md->event_nr);
38280 wake_up(&md->eventq);
38281 }
38282
38283 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38284
38285 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38286 {
38287 - return atomic_add_return(1, &md->uevent_seq);
38288 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38289 }
38290
38291 uint32_t dm_get_event_nr(struct mapped_device *md)
38292 {
38293 - return atomic_read(&md->event_nr);
38294 + return atomic_read_unchecked(&md->event_nr);
38295 }
38296
38297 int dm_wait_event(struct mapped_device *md, int event_nr)
38298 {
38299 return wait_event_interruptible(md->eventq,
38300 - (event_nr != atomic_read(&md->event_nr)));
38301 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38302 }
38303
38304 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38305 diff --git a/drivers/md/md.c b/drivers/md/md.c
38306 index 0411bde..5a023ff 100644
38307 --- a/drivers/md/md.c
38308 +++ b/drivers/md/md.c
38309 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38310 * start build, activate spare
38311 */
38312 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38313 -static atomic_t md_event_count;
38314 +static atomic_unchecked_t md_event_count;
38315 void md_new_event(struct mddev *mddev)
38316 {
38317 - atomic_inc(&md_event_count);
38318 + atomic_inc_unchecked(&md_event_count);
38319 wake_up(&md_event_waiters);
38320 }
38321 EXPORT_SYMBOL_GPL(md_new_event);
38322 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38323 */
38324 static void md_new_event_inintr(struct mddev *mddev)
38325 {
38326 - atomic_inc(&md_event_count);
38327 + atomic_inc_unchecked(&md_event_count);
38328 wake_up(&md_event_waiters);
38329 }
38330
38331 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38332 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38333 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38334 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38335 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38336 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38337
38338 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38339 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38340 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38341 else
38342 sb->resync_offset = cpu_to_le64(0);
38343
38344 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38345 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38346
38347 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38348 sb->size = cpu_to_le64(mddev->dev_sectors);
38349 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38350 static ssize_t
38351 errors_show(struct md_rdev *rdev, char *page)
38352 {
38353 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38354 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38355 }
38356
38357 static ssize_t
38358 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38359 char *e;
38360 unsigned long n = simple_strtoul(buf, &e, 10);
38361 if (*buf && (*e == 0 || *e == '\n')) {
38362 - atomic_set(&rdev->corrected_errors, n);
38363 + atomic_set_unchecked(&rdev->corrected_errors, n);
38364 return len;
38365 }
38366 return -EINVAL;
38367 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38368 rdev->sb_loaded = 0;
38369 rdev->bb_page = NULL;
38370 atomic_set(&rdev->nr_pending, 0);
38371 - atomic_set(&rdev->read_errors, 0);
38372 - atomic_set(&rdev->corrected_errors, 0);
38373 + atomic_set_unchecked(&rdev->read_errors, 0);
38374 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38375
38376 INIT_LIST_HEAD(&rdev->same_set);
38377 init_waitqueue_head(&rdev->blocked_wait);
38378 @@ -6984,7 +6984,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38379
38380 spin_unlock(&pers_lock);
38381 seq_printf(seq, "\n");
38382 - seq->poll_event = atomic_read(&md_event_count);
38383 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38384 return 0;
38385 }
38386 if (v == (void*)2) {
38387 @@ -7087,7 +7087,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38388 return error;
38389
38390 seq = file->private_data;
38391 - seq->poll_event = atomic_read(&md_event_count);
38392 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38393 return error;
38394 }
38395
38396 @@ -7101,7 +7101,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38397 /* always allow read */
38398 mask = POLLIN | POLLRDNORM;
38399
38400 - if (seq->poll_event != atomic_read(&md_event_count))
38401 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38402 mask |= POLLERR | POLLPRI;
38403 return mask;
38404 }
38405 @@ -7145,7 +7145,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38406 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38407 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38408 (int)part_stat_read(&disk->part0, sectors[1]) -
38409 - atomic_read(&disk->sync_io);
38410 + atomic_read_unchecked(&disk->sync_io);
38411 /* sync IO will cause sync_io to increase before the disk_stats
38412 * as sync_io is counted when a request starts, and
38413 * disk_stats is counted when it completes.
38414 diff --git a/drivers/md/md.h b/drivers/md/md.h
38415 index eca59c3..7c42285 100644
38416 --- a/drivers/md/md.h
38417 +++ b/drivers/md/md.h
38418 @@ -94,13 +94,13 @@ struct md_rdev {
38419 * only maintained for arrays that
38420 * support hot removal
38421 */
38422 - atomic_t read_errors; /* number of consecutive read errors that
38423 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38424 * we have tried to ignore.
38425 */
38426 struct timespec last_read_error; /* monotonic time since our
38427 * last read error
38428 */
38429 - atomic_t corrected_errors; /* number of corrected read errors,
38430 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38431 * for reporting to userspace and storing
38432 * in superblock.
38433 */
38434 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38435
38436 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38437 {
38438 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38439 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38440 }
38441
38442 struct md_personality
38443 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38444 index 1cbfc6b..56e1dbb 100644
38445 --- a/drivers/md/persistent-data/dm-space-map.h
38446 +++ b/drivers/md/persistent-data/dm-space-map.h
38447 @@ -60,6 +60,7 @@ struct dm_space_map {
38448 int (*root_size)(struct dm_space_map *sm, size_t *result);
38449 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38450 };
38451 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38452
38453 /*----------------------------------------------------------------*/
38454
38455 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38456 index 6af167f..40c25a1 100644
38457 --- a/drivers/md/raid1.c
38458 +++ b/drivers/md/raid1.c
38459 @@ -1826,7 +1826,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38460 if (r1_sync_page_io(rdev, sect, s,
38461 bio->bi_io_vec[idx].bv_page,
38462 READ) != 0)
38463 - atomic_add(s, &rdev->corrected_errors);
38464 + atomic_add_unchecked(s, &rdev->corrected_errors);
38465 }
38466 sectors -= s;
38467 sect += s;
38468 @@ -2048,7 +2048,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38469 test_bit(In_sync, &rdev->flags)) {
38470 if (r1_sync_page_io(rdev, sect, s,
38471 conf->tmppage, READ)) {
38472 - atomic_add(s, &rdev->corrected_errors);
38473 + atomic_add_unchecked(s, &rdev->corrected_errors);
38474 printk(KERN_INFO
38475 "md/raid1:%s: read error corrected "
38476 "(%d sectors at %llu on %s)\n",
38477 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38478 index 61ab219..7b232b3 100644
38479 --- a/drivers/md/raid10.c
38480 +++ b/drivers/md/raid10.c
38481 @@ -1886,7 +1886,7 @@ static void end_sync_read(struct bio *bio, int error)
38482 /* The write handler will notice the lack of
38483 * R10BIO_Uptodate and record any errors etc
38484 */
38485 - atomic_add(r10_bio->sectors,
38486 + atomic_add_unchecked(r10_bio->sectors,
38487 &conf->mirrors[d].rdev->corrected_errors);
38488
38489 /* for reconstruct, we always reschedule after a read.
38490 @@ -2235,7 +2235,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38491 {
38492 struct timespec cur_time_mon;
38493 unsigned long hours_since_last;
38494 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38495 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38496
38497 ktime_get_ts(&cur_time_mon);
38498
38499 @@ -2257,9 +2257,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38500 * overflowing the shift of read_errors by hours_since_last.
38501 */
38502 if (hours_since_last >= 8 * sizeof(read_errors))
38503 - atomic_set(&rdev->read_errors, 0);
38504 + atomic_set_unchecked(&rdev->read_errors, 0);
38505 else
38506 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38507 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38508 }
38509
38510 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38511 @@ -2313,8 +2313,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38512 return;
38513
38514 check_decay_read_errors(mddev, rdev);
38515 - atomic_inc(&rdev->read_errors);
38516 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38517 + atomic_inc_unchecked(&rdev->read_errors);
38518 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38519 char b[BDEVNAME_SIZE];
38520 bdevname(rdev->bdev, b);
38521
38522 @@ -2322,7 +2322,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38523 "md/raid10:%s: %s: Raid device exceeded "
38524 "read_error threshold [cur %d:max %d]\n",
38525 mdname(mddev), b,
38526 - atomic_read(&rdev->read_errors), max_read_errors);
38527 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38528 printk(KERN_NOTICE
38529 "md/raid10:%s: %s: Failing raid device\n",
38530 mdname(mddev), b);
38531 @@ -2477,7 +2477,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38532 sect +
38533 choose_data_offset(r10_bio, rdev)),
38534 bdevname(rdev->bdev, b));
38535 - atomic_add(s, &rdev->corrected_errors);
38536 + atomic_add_unchecked(s, &rdev->corrected_errors);
38537 }
38538
38539 rdev_dec_pending(rdev, mddev);
38540 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38541 index 94ce78e..df99e24 100644
38542 --- a/drivers/md/raid5.c
38543 +++ b/drivers/md/raid5.c
38544 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38545 mdname(conf->mddev), STRIPE_SECTORS,
38546 (unsigned long long)s,
38547 bdevname(rdev->bdev, b));
38548 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38549 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38550 clear_bit(R5_ReadError, &sh->dev[i].flags);
38551 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38552 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38553 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38554
38555 - if (atomic_read(&rdev->read_errors))
38556 - atomic_set(&rdev->read_errors, 0);
38557 + if (atomic_read_unchecked(&rdev->read_errors))
38558 + atomic_set_unchecked(&rdev->read_errors, 0);
38559 } else {
38560 const char *bdn = bdevname(rdev->bdev, b);
38561 int retry = 0;
38562 int set_bad = 0;
38563
38564 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38565 - atomic_inc(&rdev->read_errors);
38566 + atomic_inc_unchecked(&rdev->read_errors);
38567 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38568 printk_ratelimited(
38569 KERN_WARNING
38570 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38571 mdname(conf->mddev),
38572 (unsigned long long)s,
38573 bdn);
38574 - } else if (atomic_read(&rdev->read_errors)
38575 + } else if (atomic_read_unchecked(&rdev->read_errors)
38576 > conf->max_nr_stripes)
38577 printk(KERN_WARNING
38578 "md/raid:%s: Too many read errors, failing device %s.\n",
38579 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38580 index d33101a..6b13069 100644
38581 --- a/drivers/media/dvb-core/dvbdev.c
38582 +++ b/drivers/media/dvb-core/dvbdev.c
38583 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38584 const struct dvb_device *template, void *priv, int type)
38585 {
38586 struct dvb_device *dvbdev;
38587 - struct file_operations *dvbdevfops;
38588 + file_operations_no_const *dvbdevfops;
38589 struct device *clsdev;
38590 int minor;
38591 int id;
38592 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38593 index 404f63a..4796533 100644
38594 --- a/drivers/media/dvb-frontends/dib3000.h
38595 +++ b/drivers/media/dvb-frontends/dib3000.h
38596 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38597 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38598 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38599 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38600 -};
38601 +} __no_const;
38602
38603 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38604 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38605 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38606 index bc78354..42c9459 100644
38607 --- a/drivers/media/pci/cx88/cx88-video.c
38608 +++ b/drivers/media/pci/cx88/cx88-video.c
38609 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38610
38611 /* ------------------------------------------------------------------ */
38612
38613 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38614 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38615 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38616 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38617 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38618 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38619
38620 module_param_array(video_nr, int, NULL, 0444);
38621 module_param_array(vbi_nr, int, NULL, 0444);
38622 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38623 index 8e9a668..78d6310 100644
38624 --- a/drivers/media/platform/omap/omap_vout.c
38625 +++ b/drivers/media/platform/omap/omap_vout.c
38626 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38627 OMAP_VIDEO2,
38628 };
38629
38630 -static struct videobuf_queue_ops video_vbq_ops;
38631 /* Variables configurable through module params*/
38632 static u32 video1_numbuffers = 3;
38633 static u32 video2_numbuffers = 3;
38634 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38635 {
38636 struct videobuf_queue *q;
38637 struct omap_vout_device *vout = NULL;
38638 + static struct videobuf_queue_ops video_vbq_ops = {
38639 + .buf_setup = omap_vout_buffer_setup,
38640 + .buf_prepare = omap_vout_buffer_prepare,
38641 + .buf_release = omap_vout_buffer_release,
38642 + .buf_queue = omap_vout_buffer_queue,
38643 + };
38644
38645 vout = video_drvdata(file);
38646 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38647 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38648 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38649
38650 q = &vout->vbq;
38651 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38652 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38653 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38654 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38655 spin_lock_init(&vout->vbq_lock);
38656
38657 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38658 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38659 index b671e20..34088b7 100644
38660 --- a/drivers/media/platform/s5p-tv/mixer.h
38661 +++ b/drivers/media/platform/s5p-tv/mixer.h
38662 @@ -155,7 +155,7 @@ struct mxr_layer {
38663 /** layer index (unique identifier) */
38664 int idx;
38665 /** callbacks for layer methods */
38666 - struct mxr_layer_ops ops;
38667 + struct mxr_layer_ops *ops;
38668 /** format array */
38669 const struct mxr_format **fmt_array;
38670 /** size of format array */
38671 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38672 index b93a21f..2535195 100644
38673 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38674 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38675 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38676 {
38677 struct mxr_layer *layer;
38678 int ret;
38679 - struct mxr_layer_ops ops = {
38680 + static struct mxr_layer_ops ops = {
38681 .release = mxr_graph_layer_release,
38682 .buffer_set = mxr_graph_buffer_set,
38683 .stream_set = mxr_graph_stream_set,
38684 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38685 index 3b1670a..595c939 100644
38686 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38687 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38688 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38689 layer->update_buf = next;
38690 }
38691
38692 - layer->ops.buffer_set(layer, layer->update_buf);
38693 + layer->ops->buffer_set(layer, layer->update_buf);
38694
38695 if (done && done != layer->shadow_buf)
38696 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38697 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38698 index 1f3b743..e839271 100644
38699 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38700 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38701 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38702 layer->geo.src.height = layer->geo.src.full_height;
38703
38704 mxr_geometry_dump(mdev, &layer->geo);
38705 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38706 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38707 mxr_geometry_dump(mdev, &layer->geo);
38708 }
38709
38710 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38711 layer->geo.dst.full_width = mbus_fmt.width;
38712 layer->geo.dst.full_height = mbus_fmt.height;
38713 layer->geo.dst.field = mbus_fmt.field;
38714 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38715 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38716
38717 mxr_geometry_dump(mdev, &layer->geo);
38718 }
38719 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38720 /* set source size to highest accepted value */
38721 geo->src.full_width = max(geo->dst.full_width, pix->width);
38722 geo->src.full_height = max(geo->dst.full_height, pix->height);
38723 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38724 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38725 mxr_geometry_dump(mdev, &layer->geo);
38726 /* set cropping to total visible screen */
38727 geo->src.width = pix->width;
38728 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38729 geo->src.x_offset = 0;
38730 geo->src.y_offset = 0;
38731 /* assure consistency of geometry */
38732 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38733 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38734 mxr_geometry_dump(mdev, &layer->geo);
38735 /* set full size to lowest possible value */
38736 geo->src.full_width = 0;
38737 geo->src.full_height = 0;
38738 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38739 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38740 mxr_geometry_dump(mdev, &layer->geo);
38741
38742 /* returning results */
38743 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38744 target->width = s->r.width;
38745 target->height = s->r.height;
38746
38747 - layer->ops.fix_geometry(layer, stage, s->flags);
38748 + layer->ops->fix_geometry(layer, stage, s->flags);
38749
38750 /* retrieve update selection rectangle */
38751 res.left = target->x_offset;
38752 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38753 mxr_output_get(mdev);
38754
38755 mxr_layer_update_output(layer);
38756 - layer->ops.format_set(layer);
38757 + layer->ops->format_set(layer);
38758 /* enabling layer in hardware */
38759 spin_lock_irqsave(&layer->enq_slock, flags);
38760 layer->state = MXR_LAYER_STREAMING;
38761 spin_unlock_irqrestore(&layer->enq_slock, flags);
38762
38763 - layer->ops.stream_set(layer, MXR_ENABLE);
38764 + layer->ops->stream_set(layer, MXR_ENABLE);
38765 mxr_streamer_get(mdev);
38766
38767 return 0;
38768 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38769 spin_unlock_irqrestore(&layer->enq_slock, flags);
38770
38771 /* disabling layer in hardware */
38772 - layer->ops.stream_set(layer, MXR_DISABLE);
38773 + layer->ops->stream_set(layer, MXR_DISABLE);
38774 /* remove one streamer */
38775 mxr_streamer_put(mdev);
38776 /* allow changes in output configuration */
38777 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38778
38779 void mxr_layer_release(struct mxr_layer *layer)
38780 {
38781 - if (layer->ops.release)
38782 - layer->ops.release(layer);
38783 + if (layer->ops->release)
38784 + layer->ops->release(layer);
38785 }
38786
38787 void mxr_base_layer_release(struct mxr_layer *layer)
38788 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38789
38790 layer->mdev = mdev;
38791 layer->idx = idx;
38792 - layer->ops = *ops;
38793 + layer->ops = ops;
38794
38795 spin_lock_init(&layer->enq_slock);
38796 INIT_LIST_HEAD(&layer->enq_list);
38797 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38798 index 3d13a63..da31bf1 100644
38799 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38800 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38801 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38802 {
38803 struct mxr_layer *layer;
38804 int ret;
38805 - struct mxr_layer_ops ops = {
38806 + static struct mxr_layer_ops ops = {
38807 .release = mxr_vp_layer_release,
38808 .buffer_set = mxr_vp_buffer_set,
38809 .stream_set = mxr_vp_stream_set,
38810 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38811 index 643d80a..56bb96b 100644
38812 --- a/drivers/media/radio/radio-cadet.c
38813 +++ b/drivers/media/radio/radio-cadet.c
38814 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38815 unsigned char readbuf[RDS_BUFFER];
38816 int i = 0;
38817
38818 + if (count > RDS_BUFFER)
38819 + return -EFAULT;
38820 mutex_lock(&dev->lock);
38821 if (dev->rdsstat == 0)
38822 cadet_start_rds(dev);
38823 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38824 while (i < count && dev->rdsin != dev->rdsout)
38825 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38826
38827 - if (i && copy_to_user(data, readbuf, i))
38828 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38829 i = -EFAULT;
38830 unlock:
38831 mutex_unlock(&dev->lock);
38832 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38833 index 3940bb0..fb3952a 100644
38834 --- a/drivers/media/usb/dvb-usb/cxusb.c
38835 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38836 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38837
38838 struct dib0700_adapter_state {
38839 int (*set_param_save) (struct dvb_frontend *);
38840 -};
38841 +} __no_const;
38842
38843 static int dib7070_set_param_override(struct dvb_frontend *fe)
38844 {
38845 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38846 index 9382895..ac8093c 100644
38847 --- a/drivers/media/usb/dvb-usb/dw2102.c
38848 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38849 @@ -95,7 +95,7 @@ struct su3000_state {
38850
38851 struct s6x0_state {
38852 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38853 -};
38854 +} __no_const;
38855
38856 /* debug */
38857 static int dvb_usb_dw2102_debug;
38858 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38859 index aa6e7c7..4cd8061 100644
38860 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38861 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38862 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38863 struct file *file, void *fh, void *p);
38864 } u;
38865 void (*debug)(const void *arg, bool write_only);
38866 -};
38867 +} __do_const;
38868 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38869
38870 /* This control needs a priority check */
38871 #define INFO_FL_PRIO (1 << 0)
38872 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38873 struct video_device *vfd = video_devdata(file);
38874 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38875 bool write_only = false;
38876 - struct v4l2_ioctl_info default_info;
38877 + v4l2_ioctl_info_no_const default_info;
38878 const struct v4l2_ioctl_info *info;
38879 void *fh = file->private_data;
38880 struct v4l2_fh *vfh = NULL;
38881 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38882 index 29b2172..a7c5b31 100644
38883 --- a/drivers/memstick/host/r592.c
38884 +++ b/drivers/memstick/host/r592.c
38885 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38886 /* Executes one TPC (data is read/written from small or large fifo) */
38887 static void r592_execute_tpc(struct r592_device *dev)
38888 {
38889 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38890 + bool is_write;
38891 int len, error;
38892 u32 status, reg;
38893
38894 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38895 return;
38896 }
38897
38898 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38899 len = dev->req->long_data ?
38900 dev->req->sg.length : dev->req->data_len;
38901
38902 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38903 index fb69baa..3aeea2e 100644
38904 --- a/drivers/message/fusion/mptbase.c
38905 +++ b/drivers/message/fusion/mptbase.c
38906 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38907 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38908 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38909
38910 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38911 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38912 +#else
38913 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38914 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38915 +#endif
38916 +
38917 /*
38918 * Rounding UP to nearest 4-kB boundary here...
38919 */
38920 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38921 ioc->facts.GlobalCredits);
38922
38923 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38924 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38925 + NULL, NULL);
38926 +#else
38927 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38928 +#endif
38929 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38930 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38931 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38932 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38933 index fa43c39..daeb158 100644
38934 --- a/drivers/message/fusion/mptsas.c
38935 +++ b/drivers/message/fusion/mptsas.c
38936 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38937 return 0;
38938 }
38939
38940 +static inline void
38941 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38942 +{
38943 + if (phy_info->port_details) {
38944 + phy_info->port_details->rphy = rphy;
38945 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38946 + ioc->name, rphy));
38947 + }
38948 +
38949 + if (rphy) {
38950 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38951 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38952 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38953 + ioc->name, rphy, rphy->dev.release));
38954 + }
38955 +}
38956 +
38957 /* no mutex */
38958 static void
38959 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38960 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38961 return NULL;
38962 }
38963
38964 -static inline void
38965 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38966 -{
38967 - if (phy_info->port_details) {
38968 - phy_info->port_details->rphy = rphy;
38969 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38970 - ioc->name, rphy));
38971 - }
38972 -
38973 - if (rphy) {
38974 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38975 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38976 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38977 - ioc->name, rphy, rphy->dev.release));
38978 - }
38979 -}
38980 -
38981 static inline struct sas_port *
38982 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38983 {
38984 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38985 index 164afa7..b6b2e74 100644
38986 --- a/drivers/message/fusion/mptscsih.c
38987 +++ b/drivers/message/fusion/mptscsih.c
38988 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38989
38990 h = shost_priv(SChost);
38991
38992 - if (h) {
38993 - if (h->info_kbuf == NULL)
38994 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38995 - return h->info_kbuf;
38996 - h->info_kbuf[0] = '\0';
38997 + if (!h)
38998 + return NULL;
38999
39000 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39001 - h->info_kbuf[size-1] = '\0';
39002 - }
39003 + if (h->info_kbuf == NULL)
39004 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39005 + return h->info_kbuf;
39006 + h->info_kbuf[0] = '\0';
39007 +
39008 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39009 + h->info_kbuf[size-1] = '\0';
39010
39011 return h->info_kbuf;
39012 }
39013 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39014 index 8001aa6..b137580 100644
39015 --- a/drivers/message/i2o/i2o_proc.c
39016 +++ b/drivers/message/i2o/i2o_proc.c
39017 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39018 "Array Controller Device"
39019 };
39020
39021 -static char *chtostr(char *tmp, u8 *chars, int n)
39022 -{
39023 - tmp[0] = 0;
39024 - return strncat(tmp, (char *)chars, n);
39025 -}
39026 -
39027 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39028 char *group)
39029 {
39030 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39031 } *result;
39032
39033 i2o_exec_execute_ddm_table ddm_table;
39034 - char tmp[28 + 1];
39035
39036 result = kmalloc(sizeof(*result), GFP_KERNEL);
39037 if (!result)
39038 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39039
39040 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39041 seq_printf(seq, "%-#8x", ddm_table.module_id);
39042 - seq_printf(seq, "%-29s",
39043 - chtostr(tmp, ddm_table.module_name_version, 28));
39044 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39045 seq_printf(seq, "%9d ", ddm_table.data_size);
39046 seq_printf(seq, "%8d", ddm_table.code_size);
39047
39048 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39049
39050 i2o_driver_result_table *result;
39051 i2o_driver_store_table *dst;
39052 - char tmp[28 + 1];
39053
39054 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39055 if (result == NULL)
39056 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39057
39058 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39059 seq_printf(seq, "%-#8x", dst->module_id);
39060 - seq_printf(seq, "%-29s",
39061 - chtostr(tmp, dst->module_name_version, 28));
39062 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39063 + seq_printf(seq, "%-.28s", dst->module_name_version);
39064 + seq_printf(seq, "%-.8s", dst->date);
39065 seq_printf(seq, "%8d ", dst->module_size);
39066 seq_printf(seq, "%8d ", dst->mpb_size);
39067 seq_printf(seq, "0x%04x", dst->module_flags);
39068 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39069 // == (allow) 512d bytes (max)
39070 static u16 *work16 = (u16 *) work32;
39071 int token;
39072 - char tmp[16 + 1];
39073
39074 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39075
39076 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39077 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39078 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39079 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39080 - seq_printf(seq, "Vendor info : %s\n",
39081 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39082 - seq_printf(seq, "Product info : %s\n",
39083 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39084 - seq_printf(seq, "Description : %s\n",
39085 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39086 - seq_printf(seq, "Product rev. : %s\n",
39087 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39088 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39089 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39090 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39091 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39092
39093 seq_printf(seq, "Serial number : ");
39094 print_serial_number(seq, (u8 *) (work32 + 16),
39095 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39096 u8 pad[256]; // allow up to 256 byte (max) serial number
39097 } result;
39098
39099 - char tmp[24 + 1];
39100 -
39101 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39102
39103 if (token < 0) {
39104 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39105 }
39106
39107 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39108 - seq_printf(seq, "Module name : %s\n",
39109 - chtostr(tmp, result.module_name, 24));
39110 - seq_printf(seq, "Module revision : %s\n",
39111 - chtostr(tmp, result.module_rev, 8));
39112 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39113 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39114
39115 seq_printf(seq, "Serial number : ");
39116 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39117 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39118 u8 instance_number[4];
39119 } result;
39120
39121 - char tmp[64 + 1];
39122 -
39123 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39124
39125 if (token < 0) {
39126 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39127 return 0;
39128 }
39129
39130 - seq_printf(seq, "Device name : %s\n",
39131 - chtostr(tmp, result.device_name, 64));
39132 - seq_printf(seq, "Service name : %s\n",
39133 - chtostr(tmp, result.service_name, 64));
39134 - seq_printf(seq, "Physical name : %s\n",
39135 - chtostr(tmp, result.physical_location, 64));
39136 - seq_printf(seq, "Instance number : %s\n",
39137 - chtostr(tmp, result.instance_number, 4));
39138 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39139 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39140 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39141 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39142
39143 return 0;
39144 }
39145 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39146 index a8c08f3..155fe3d 100644
39147 --- a/drivers/message/i2o/iop.c
39148 +++ b/drivers/message/i2o/iop.c
39149 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39150
39151 spin_lock_irqsave(&c->context_list_lock, flags);
39152
39153 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39154 - atomic_inc(&c->context_list_counter);
39155 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39156 + atomic_inc_unchecked(&c->context_list_counter);
39157
39158 - entry->context = atomic_read(&c->context_list_counter);
39159 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39160
39161 list_add(&entry->list, &c->context_list);
39162
39163 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39164
39165 #if BITS_PER_LONG == 64
39166 spin_lock_init(&c->context_list_lock);
39167 - atomic_set(&c->context_list_counter, 0);
39168 + atomic_set_unchecked(&c->context_list_counter, 0);
39169 INIT_LIST_HEAD(&c->context_list);
39170 #endif
39171
39172 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39173 index 45ece11..8efa218 100644
39174 --- a/drivers/mfd/janz-cmodio.c
39175 +++ b/drivers/mfd/janz-cmodio.c
39176 @@ -13,6 +13,7 @@
39177
39178 #include <linux/kernel.h>
39179 #include <linux/module.h>
39180 +#include <linux/slab.h>
39181 #include <linux/init.h>
39182 #include <linux/pci.h>
39183 #include <linux/interrupt.h>
39184 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39185 index a5f9888..1c0ed56 100644
39186 --- a/drivers/mfd/twl4030-irq.c
39187 +++ b/drivers/mfd/twl4030-irq.c
39188 @@ -35,6 +35,7 @@
39189 #include <linux/of.h>
39190 #include <linux/irqdomain.h>
39191 #include <linux/i2c/twl.h>
39192 +#include <asm/pgtable.h>
39193
39194 #include "twl-core.h"
39195
39196 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39197 * Install an irq handler for each of the SIH modules;
39198 * clone dummy irq_chip since PIH can't *do* anything
39199 */
39200 - twl4030_irq_chip = dummy_irq_chip;
39201 - twl4030_irq_chip.name = "twl4030";
39202 + pax_open_kernel();
39203 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39204 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39205
39206 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39207 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39208 + pax_close_kernel();
39209
39210 for (i = irq_base; i < irq_end; i++) {
39211 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39212 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39213 index 277a8db..0e0b754 100644
39214 --- a/drivers/mfd/twl6030-irq.c
39215 +++ b/drivers/mfd/twl6030-irq.c
39216 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39217 * install an irq handler for each of the modules;
39218 * clone dummy irq_chip since PIH can't *do* anything
39219 */
39220 - twl6030_irq_chip = dummy_irq_chip;
39221 - twl6030_irq_chip.name = "twl6030";
39222 - twl6030_irq_chip.irq_set_type = NULL;
39223 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39224 + pax_open_kernel();
39225 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39226 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39227 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39228 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39229 + pax_close_kernel();
39230
39231 for (i = irq_base; i < irq_end; i++) {
39232 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39233 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39234 index f428d86..274c368 100644
39235 --- a/drivers/misc/c2port/core.c
39236 +++ b/drivers/misc/c2port/core.c
39237 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39238 mutex_init(&c2dev->mutex);
39239
39240 /* Create binary file */
39241 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39242 + pax_open_kernel();
39243 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39244 + pax_close_kernel();
39245 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39246 if (unlikely(ret))
39247 goto error_device_create_bin_file;
39248 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39249 index 3aa9a96..59cf685 100644
39250 --- a/drivers/misc/kgdbts.c
39251 +++ b/drivers/misc/kgdbts.c
39252 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39253 char before[BREAK_INSTR_SIZE];
39254 char after[BREAK_INSTR_SIZE];
39255
39256 - probe_kernel_read(before, (char *)kgdbts_break_test,
39257 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39258 BREAK_INSTR_SIZE);
39259 init_simple_test();
39260 ts.tst = plant_and_detach_test;
39261 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39262 /* Activate test with initial breakpoint */
39263 if (!is_early)
39264 kgdb_breakpoint();
39265 - probe_kernel_read(after, (char *)kgdbts_break_test,
39266 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39267 BREAK_INSTR_SIZE);
39268 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39269 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39270 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39271 index 4a87e5c..76bdf5c 100644
39272 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39273 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39274 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39275 * the lid is closed. This leads to interrupts as soon as a little move
39276 * is done.
39277 */
39278 - atomic_inc(&lis3->count);
39279 + atomic_inc_unchecked(&lis3->count);
39280
39281 wake_up_interruptible(&lis3->misc_wait);
39282 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39283 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39284 if (lis3->pm_dev)
39285 pm_runtime_get_sync(lis3->pm_dev);
39286
39287 - atomic_set(&lis3->count, 0);
39288 + atomic_set_unchecked(&lis3->count, 0);
39289 return 0;
39290 }
39291
39292 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39293 add_wait_queue(&lis3->misc_wait, &wait);
39294 while (true) {
39295 set_current_state(TASK_INTERRUPTIBLE);
39296 - data = atomic_xchg(&lis3->count, 0);
39297 + data = atomic_xchg_unchecked(&lis3->count, 0);
39298 if (data)
39299 break;
39300
39301 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39302 struct lis3lv02d, miscdev);
39303
39304 poll_wait(file, &lis3->misc_wait, wait);
39305 - if (atomic_read(&lis3->count))
39306 + if (atomic_read_unchecked(&lis3->count))
39307 return POLLIN | POLLRDNORM;
39308 return 0;
39309 }
39310 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39311 index c439c82..1f20f57 100644
39312 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39313 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39314 @@ -297,7 +297,7 @@ struct lis3lv02d {
39315 struct input_polled_dev *idev; /* input device */
39316 struct platform_device *pdev; /* platform device */
39317 struct regulator_bulk_data regulators[2];
39318 - atomic_t count; /* interrupt count after last read */
39319 + atomic_unchecked_t count; /* interrupt count after last read */
39320 union axis_conversion ac; /* hw -> logical axis */
39321 int mapped_btns[3];
39322
39323 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39324 index 2f30bad..c4c13d0 100644
39325 --- a/drivers/misc/sgi-gru/gruhandles.c
39326 +++ b/drivers/misc/sgi-gru/gruhandles.c
39327 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39328 unsigned long nsec;
39329
39330 nsec = CLKS2NSEC(clks);
39331 - atomic_long_inc(&mcs_op_statistics[op].count);
39332 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39333 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39334 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39335 if (mcs_op_statistics[op].max < nsec)
39336 mcs_op_statistics[op].max = nsec;
39337 }
39338 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39339 index 950dbe9..eeef0f8 100644
39340 --- a/drivers/misc/sgi-gru/gruprocfs.c
39341 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39342 @@ -32,9 +32,9 @@
39343
39344 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39345
39346 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39347 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39348 {
39349 - unsigned long val = atomic_long_read(v);
39350 + unsigned long val = atomic_long_read_unchecked(v);
39351
39352 seq_printf(s, "%16lu %s\n", val, id);
39353 }
39354 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39355
39356 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39357 for (op = 0; op < mcsop_last; op++) {
39358 - count = atomic_long_read(&mcs_op_statistics[op].count);
39359 - total = atomic_long_read(&mcs_op_statistics[op].total);
39360 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39361 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39362 max = mcs_op_statistics[op].max;
39363 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39364 count ? total / count : 0, max);
39365 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39366 index 5c3ce24..4915ccb 100644
39367 --- a/drivers/misc/sgi-gru/grutables.h
39368 +++ b/drivers/misc/sgi-gru/grutables.h
39369 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39370 * GRU statistics.
39371 */
39372 struct gru_stats_s {
39373 - atomic_long_t vdata_alloc;
39374 - atomic_long_t vdata_free;
39375 - atomic_long_t gts_alloc;
39376 - atomic_long_t gts_free;
39377 - atomic_long_t gms_alloc;
39378 - atomic_long_t gms_free;
39379 - atomic_long_t gts_double_allocate;
39380 - atomic_long_t assign_context;
39381 - atomic_long_t assign_context_failed;
39382 - atomic_long_t free_context;
39383 - atomic_long_t load_user_context;
39384 - atomic_long_t load_kernel_context;
39385 - atomic_long_t lock_kernel_context;
39386 - atomic_long_t unlock_kernel_context;
39387 - atomic_long_t steal_user_context;
39388 - atomic_long_t steal_kernel_context;
39389 - atomic_long_t steal_context_failed;
39390 - atomic_long_t nopfn;
39391 - atomic_long_t asid_new;
39392 - atomic_long_t asid_next;
39393 - atomic_long_t asid_wrap;
39394 - atomic_long_t asid_reuse;
39395 - atomic_long_t intr;
39396 - atomic_long_t intr_cbr;
39397 - atomic_long_t intr_tfh;
39398 - atomic_long_t intr_spurious;
39399 - atomic_long_t intr_mm_lock_failed;
39400 - atomic_long_t call_os;
39401 - atomic_long_t call_os_wait_queue;
39402 - atomic_long_t user_flush_tlb;
39403 - atomic_long_t user_unload_context;
39404 - atomic_long_t user_exception;
39405 - atomic_long_t set_context_option;
39406 - atomic_long_t check_context_retarget_intr;
39407 - atomic_long_t check_context_unload;
39408 - atomic_long_t tlb_dropin;
39409 - atomic_long_t tlb_preload_page;
39410 - atomic_long_t tlb_dropin_fail_no_asid;
39411 - atomic_long_t tlb_dropin_fail_upm;
39412 - atomic_long_t tlb_dropin_fail_invalid;
39413 - atomic_long_t tlb_dropin_fail_range_active;
39414 - atomic_long_t tlb_dropin_fail_idle;
39415 - atomic_long_t tlb_dropin_fail_fmm;
39416 - atomic_long_t tlb_dropin_fail_no_exception;
39417 - atomic_long_t tfh_stale_on_fault;
39418 - atomic_long_t mmu_invalidate_range;
39419 - atomic_long_t mmu_invalidate_page;
39420 - atomic_long_t flush_tlb;
39421 - atomic_long_t flush_tlb_gru;
39422 - atomic_long_t flush_tlb_gru_tgh;
39423 - atomic_long_t flush_tlb_gru_zero_asid;
39424 + atomic_long_unchecked_t vdata_alloc;
39425 + atomic_long_unchecked_t vdata_free;
39426 + atomic_long_unchecked_t gts_alloc;
39427 + atomic_long_unchecked_t gts_free;
39428 + atomic_long_unchecked_t gms_alloc;
39429 + atomic_long_unchecked_t gms_free;
39430 + atomic_long_unchecked_t gts_double_allocate;
39431 + atomic_long_unchecked_t assign_context;
39432 + atomic_long_unchecked_t assign_context_failed;
39433 + atomic_long_unchecked_t free_context;
39434 + atomic_long_unchecked_t load_user_context;
39435 + atomic_long_unchecked_t load_kernel_context;
39436 + atomic_long_unchecked_t lock_kernel_context;
39437 + atomic_long_unchecked_t unlock_kernel_context;
39438 + atomic_long_unchecked_t steal_user_context;
39439 + atomic_long_unchecked_t steal_kernel_context;
39440 + atomic_long_unchecked_t steal_context_failed;
39441 + atomic_long_unchecked_t nopfn;
39442 + atomic_long_unchecked_t asid_new;
39443 + atomic_long_unchecked_t asid_next;
39444 + atomic_long_unchecked_t asid_wrap;
39445 + atomic_long_unchecked_t asid_reuse;
39446 + atomic_long_unchecked_t intr;
39447 + atomic_long_unchecked_t intr_cbr;
39448 + atomic_long_unchecked_t intr_tfh;
39449 + atomic_long_unchecked_t intr_spurious;
39450 + atomic_long_unchecked_t intr_mm_lock_failed;
39451 + atomic_long_unchecked_t call_os;
39452 + atomic_long_unchecked_t call_os_wait_queue;
39453 + atomic_long_unchecked_t user_flush_tlb;
39454 + atomic_long_unchecked_t user_unload_context;
39455 + atomic_long_unchecked_t user_exception;
39456 + atomic_long_unchecked_t set_context_option;
39457 + atomic_long_unchecked_t check_context_retarget_intr;
39458 + atomic_long_unchecked_t check_context_unload;
39459 + atomic_long_unchecked_t tlb_dropin;
39460 + atomic_long_unchecked_t tlb_preload_page;
39461 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39462 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39463 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39464 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39465 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39466 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39467 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39468 + atomic_long_unchecked_t tfh_stale_on_fault;
39469 + atomic_long_unchecked_t mmu_invalidate_range;
39470 + atomic_long_unchecked_t mmu_invalidate_page;
39471 + atomic_long_unchecked_t flush_tlb;
39472 + atomic_long_unchecked_t flush_tlb_gru;
39473 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39474 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39475
39476 - atomic_long_t copy_gpa;
39477 - atomic_long_t read_gpa;
39478 + atomic_long_unchecked_t copy_gpa;
39479 + atomic_long_unchecked_t read_gpa;
39480
39481 - atomic_long_t mesq_receive;
39482 - atomic_long_t mesq_receive_none;
39483 - atomic_long_t mesq_send;
39484 - atomic_long_t mesq_send_failed;
39485 - atomic_long_t mesq_noop;
39486 - atomic_long_t mesq_send_unexpected_error;
39487 - atomic_long_t mesq_send_lb_overflow;
39488 - atomic_long_t mesq_send_qlimit_reached;
39489 - atomic_long_t mesq_send_amo_nacked;
39490 - atomic_long_t mesq_send_put_nacked;
39491 - atomic_long_t mesq_page_overflow;
39492 - atomic_long_t mesq_qf_locked;
39493 - atomic_long_t mesq_qf_noop_not_full;
39494 - atomic_long_t mesq_qf_switch_head_failed;
39495 - atomic_long_t mesq_qf_unexpected_error;
39496 - atomic_long_t mesq_noop_unexpected_error;
39497 - atomic_long_t mesq_noop_lb_overflow;
39498 - atomic_long_t mesq_noop_qlimit_reached;
39499 - atomic_long_t mesq_noop_amo_nacked;
39500 - atomic_long_t mesq_noop_put_nacked;
39501 - atomic_long_t mesq_noop_page_overflow;
39502 + atomic_long_unchecked_t mesq_receive;
39503 + atomic_long_unchecked_t mesq_receive_none;
39504 + atomic_long_unchecked_t mesq_send;
39505 + atomic_long_unchecked_t mesq_send_failed;
39506 + atomic_long_unchecked_t mesq_noop;
39507 + atomic_long_unchecked_t mesq_send_unexpected_error;
39508 + atomic_long_unchecked_t mesq_send_lb_overflow;
39509 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39510 + atomic_long_unchecked_t mesq_send_amo_nacked;
39511 + atomic_long_unchecked_t mesq_send_put_nacked;
39512 + atomic_long_unchecked_t mesq_page_overflow;
39513 + atomic_long_unchecked_t mesq_qf_locked;
39514 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39515 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39516 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39517 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39518 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39519 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39520 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39521 + atomic_long_unchecked_t mesq_noop_put_nacked;
39522 + atomic_long_unchecked_t mesq_noop_page_overflow;
39523
39524 };
39525
39526 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39527 tghop_invalidate, mcsop_last};
39528
39529 struct mcs_op_statistic {
39530 - atomic_long_t count;
39531 - atomic_long_t total;
39532 + atomic_long_unchecked_t count;
39533 + atomic_long_unchecked_t total;
39534 unsigned long max;
39535 };
39536
39537 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39538
39539 #define STAT(id) do { \
39540 if (gru_options & OPT_STATS) \
39541 - atomic_long_inc(&gru_stats.id); \
39542 + atomic_long_inc_unchecked(&gru_stats.id); \
39543 } while (0)
39544
39545 #ifdef CONFIG_SGI_GRU_DEBUG
39546 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39547 index c862cd4..0d176fe 100644
39548 --- a/drivers/misc/sgi-xp/xp.h
39549 +++ b/drivers/misc/sgi-xp/xp.h
39550 @@ -288,7 +288,7 @@ struct xpc_interface {
39551 xpc_notify_func, void *);
39552 void (*received) (short, int, void *);
39553 enum xp_retval (*partid_to_nasids) (short, void *);
39554 -};
39555 +} __no_const;
39556
39557 extern struct xpc_interface xpc_interface;
39558
39559 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39560 index b94d5f7..7f494c5 100644
39561 --- a/drivers/misc/sgi-xp/xpc.h
39562 +++ b/drivers/misc/sgi-xp/xpc.h
39563 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39564 void (*received_payload) (struct xpc_channel *, void *);
39565 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39566 };
39567 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39568
39569 /* struct xpc_partition act_state values (for XPC HB) */
39570
39571 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39572 /* found in xpc_main.c */
39573 extern struct device *xpc_part;
39574 extern struct device *xpc_chan;
39575 -extern struct xpc_arch_operations xpc_arch_ops;
39576 +extern xpc_arch_operations_no_const xpc_arch_ops;
39577 extern int xpc_disengage_timelimit;
39578 extern int xpc_disengage_timedout;
39579 extern int xpc_activate_IRQ_rcvd;
39580 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39581 index d971817..33bdca5 100644
39582 --- a/drivers/misc/sgi-xp/xpc_main.c
39583 +++ b/drivers/misc/sgi-xp/xpc_main.c
39584 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39585 .notifier_call = xpc_system_die,
39586 };
39587
39588 -struct xpc_arch_operations xpc_arch_ops;
39589 +xpc_arch_operations_no_const xpc_arch_ops;
39590
39591 /*
39592 * Timer function to enforce the timelimit on the partition disengage.
39593 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39594
39595 if (((die_args->trapnr == X86_TRAP_MF) ||
39596 (die_args->trapnr == X86_TRAP_XF)) &&
39597 - !user_mode_vm(die_args->regs))
39598 + !user_mode(die_args->regs))
39599 xpc_die_deactivate();
39600
39601 break;
39602 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39603 index 6d8f701..35b6369 100644
39604 --- a/drivers/mmc/core/mmc_ops.c
39605 +++ b/drivers/mmc/core/mmc_ops.c
39606 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39607 void *data_buf;
39608 int is_on_stack;
39609
39610 - is_on_stack = object_is_on_stack(buf);
39611 + is_on_stack = object_starts_on_stack(buf);
39612 if (is_on_stack) {
39613 /*
39614 * dma onto stack is unsafe/nonportable, but callers to this
39615 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39616 index 53b8fd9..615b462 100644
39617 --- a/drivers/mmc/host/dw_mmc.h
39618 +++ b/drivers/mmc/host/dw_mmc.h
39619 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39620 int (*parse_dt)(struct dw_mci *host);
39621 int (*setup_bus)(struct dw_mci *host,
39622 struct device_node *slot_np, u8 bus_width);
39623 -};
39624 +} __do_const;
39625 #endif /* _DW_MMC_H_ */
39626 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39627 index 82a8de1..3c56ccb 100644
39628 --- a/drivers/mmc/host/sdhci-s3c.c
39629 +++ b/drivers/mmc/host/sdhci-s3c.c
39630 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39631 * we can use overriding functions instead of default.
39632 */
39633 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39634 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39635 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39636 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39637 + pax_open_kernel();
39638 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39639 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39640 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39641 + pax_close_kernel();
39642 }
39643
39644 /* It supports additional host capabilities if needed */
39645 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39646 index a4eb8b5..8c0628f 100644
39647 --- a/drivers/mtd/devices/doc2000.c
39648 +++ b/drivers/mtd/devices/doc2000.c
39649 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39650
39651 /* The ECC will not be calculated correctly if less than 512 is written */
39652 /* DBB-
39653 - if (len != 0x200 && eccbuf)
39654 + if (len != 0x200)
39655 printk(KERN_WARNING
39656 "ECC needs a full sector write (adr: %lx size %lx)\n",
39657 (long) to, (long) len);
39658 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39659 index 0c8bb6b..6f35deb 100644
39660 --- a/drivers/mtd/nand/denali.c
39661 +++ b/drivers/mtd/nand/denali.c
39662 @@ -24,6 +24,7 @@
39663 #include <linux/slab.h>
39664 #include <linux/mtd/mtd.h>
39665 #include <linux/module.h>
39666 +#include <linux/slab.h>
39667
39668 #include "denali.h"
39669
39670 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39671 index 51b9d6a..52af9a7 100644
39672 --- a/drivers/mtd/nftlmount.c
39673 +++ b/drivers/mtd/nftlmount.c
39674 @@ -24,6 +24,7 @@
39675 #include <asm/errno.h>
39676 #include <linux/delay.h>
39677 #include <linux/slab.h>
39678 +#include <linux/sched.h>
39679 #include <linux/mtd/mtd.h>
39680 #include <linux/mtd/nand.h>
39681 #include <linux/mtd/nftl.h>
39682 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39683 index 8dd6ba5..419cc1d 100644
39684 --- a/drivers/mtd/sm_ftl.c
39685 +++ b/drivers/mtd/sm_ftl.c
39686 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39687 #define SM_CIS_VENDOR_OFFSET 0x59
39688 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39689 {
39690 - struct attribute_group *attr_group;
39691 + attribute_group_no_const *attr_group;
39692 struct attribute **attributes;
39693 struct sm_sysfs_attribute *vendor_attribute;
39694
39695 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39696 index 045dc53..b1e5473 100644
39697 --- a/drivers/net/bonding/bond_main.c
39698 +++ b/drivers/net/bonding/bond_main.c
39699 @@ -4865,7 +4865,7 @@ static unsigned int bond_get_num_tx_queues(void)
39700 return tx_queues;
39701 }
39702
39703 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39704 +static struct rtnl_link_ops bond_link_ops = {
39705 .kind = "bond",
39706 .priv_size = sizeof(struct bonding),
39707 .setup = bond_setup,
39708 @@ -4990,8 +4990,8 @@ static void __exit bonding_exit(void)
39709
39710 bond_destroy_debugfs();
39711
39712 - rtnl_link_unregister(&bond_link_ops);
39713 unregister_pernet_subsys(&bond_net_ops);
39714 + rtnl_link_unregister(&bond_link_ops);
39715
39716 #ifdef CONFIG_NET_POLL_CONTROLLER
39717 /*
39718 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39719 index 70dba5d..11a0919 100644
39720 --- a/drivers/net/ethernet/8390/ax88796.c
39721 +++ b/drivers/net/ethernet/8390/ax88796.c
39722 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39723 if (ax->plat->reg_offsets)
39724 ei_local->reg_offset = ax->plat->reg_offsets;
39725 else {
39726 + resource_size_t _mem_size = mem_size;
39727 + do_div(_mem_size, 0x18);
39728 ei_local->reg_offset = ax->reg_offsets;
39729 for (ret = 0; ret < 0x18; ret++)
39730 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39731 + ax->reg_offsets[ret] = _mem_size * ret;
39732 }
39733
39734 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39735 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39736 index 0991534..8098e92 100644
39737 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39738 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39739 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39740 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39741 {
39742 /* RX_MODE controlling object */
39743 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39744 + bnx2x_init_rx_mode_obj(bp);
39745
39746 /* multicast configuration controlling object */
39747 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39748 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39749 index 10bc093..a2fb42a 100644
39750 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39751 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39752 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39753 break;
39754 default:
39755 BNX2X_ERR("Non valid capability ID\n");
39756 - rval = -EINVAL;
39757 + rval = 1;
39758 break;
39759 }
39760 } else {
39761 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39762 - rval = -EINVAL;
39763 + rval = 1;
39764 }
39765
39766 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39767 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39768 break;
39769 default:
39770 BNX2X_ERR("Non valid TC-ID\n");
39771 - rval = -EINVAL;
39772 + rval = 1;
39773 break;
39774 }
39775 } else {
39776 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39777 - rval = -EINVAL;
39778 + rval = 1;
39779 }
39780
39781 return rval;
39782 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39783 return -EINVAL;
39784 }
39785
39786 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39787 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39788 {
39789 struct bnx2x *bp = netdev_priv(netdev);
39790 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39791 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39792 break;
39793 default:
39794 BNX2X_ERR("Non valid featrue-ID\n");
39795 - rval = -EINVAL;
39796 + rval = 1;
39797 break;
39798 }
39799 } else {
39800 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39801 - rval = -EINVAL;
39802 + rval = 1;
39803 }
39804
39805 return rval;
39806 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39807 break;
39808 default:
39809 BNX2X_ERR("Non valid featrue-ID\n");
39810 - rval = -EINVAL;
39811 + rval = 1;
39812 break;
39813 }
39814 } else {
39815 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39816 - rval = -EINVAL;
39817 + rval = 1;
39818 }
39819
39820 return rval;
39821 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39822 index 5523da3..4fcf274 100644
39823 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39824 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39825 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39826 q);
39827 }
39828
39829 - if (!NO_FCOE(bp)) {
39830 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39831 fp = &bp->fp[FCOE_IDX(bp)];
39832 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39833
39834 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39835 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39836 mutex_unlock(&bp->cnic_mutex);
39837 synchronize_rcu();
39838 + bp->cnic_enabled = false;
39839 kfree(bp->cnic_kwq);
39840 bp->cnic_kwq = NULL;
39841
39842 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39843 index 09b625e..15b16fe 100644
39844 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39845 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39846 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39847 return rc;
39848 }
39849
39850 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39851 - struct bnx2x_rx_mode_obj *o)
39852 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39853 {
39854 if (CHIP_IS_E1x(bp)) {
39855 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39856 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39857 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39858 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39859 } else {
39860 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39861 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39862 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39863 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39864 }
39865 }
39866
39867 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39868 index adbd91b..58ec94a 100644
39869 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39870 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39871 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39872
39873 /********************* RX MODE ****************/
39874
39875 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39876 - struct bnx2x_rx_mode_obj *o);
39877 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39878
39879 /**
39880 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39881 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39882 index 6f9b74c..7f219b8 100644
39883 --- a/drivers/net/ethernet/broadcom/tg3.h
39884 +++ b/drivers/net/ethernet/broadcom/tg3.h
39885 @@ -146,6 +146,7 @@
39886 #define CHIPREV_ID_5750_A0 0x4000
39887 #define CHIPREV_ID_5750_A1 0x4001
39888 #define CHIPREV_ID_5750_A3 0x4003
39889 +#define CHIPREV_ID_5750_C1 0x4201
39890 #define CHIPREV_ID_5750_C2 0x4202
39891 #define CHIPREV_ID_5752_A0_HW 0x5000
39892 #define CHIPREV_ID_5752_A0 0x6000
39893 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39894 index 8cffcdf..aadf043 100644
39895 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39896 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39897 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39898 */
39899 struct l2t_skb_cb {
39900 arp_failure_handler_func arp_failure_handler;
39901 -};
39902 +} __no_const;
39903
39904 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39905
39906 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39907 index 4c83003..2a2a5b9 100644
39908 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39909 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39910 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39911 for (i=0; i<ETH_ALEN; i++) {
39912 tmp.addr[i] = dev->dev_addr[i];
39913 }
39914 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39915 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39916 break;
39917
39918 case DE4X5_SET_HWADDR: /* Set the hardware address */
39919 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39920 spin_lock_irqsave(&lp->lock, flags);
39921 memcpy(&statbuf, &lp->pktStats, ioc->len);
39922 spin_unlock_irqrestore(&lp->lock, flags);
39923 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39924 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39925 return -EFAULT;
39926 break;
39927 }
39928 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39929 index 4d6f3c5..449bc5c 100644
39930 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39931 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39932 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39933
39934 if (wrapped)
39935 newacc += 65536;
39936 - ACCESS_ONCE(*acc) = newacc;
39937 + ACCESS_ONCE_RW(*acc) = newacc;
39938 }
39939
39940 void be_parse_stats(struct be_adapter *adapter)
39941 @@ -759,8 +759,9 @@ static struct sk_buff *be_insert_vlan_in_pkt(struct be_adapter *adapter,
39942
39943 if (vlan_tx_tag_present(skb)) {
39944 vlan_tag = be_get_tx_vlan_tag(adapter, skb);
39945 - __vlan_put_tag(skb, vlan_tag);
39946 - skb->vlan_tci = 0;
39947 + skb = __vlan_put_tag(skb, vlan_tag);
39948 + if (skb)
39949 + skb->vlan_tci = 0;
39950 }
39951
39952 return skb;
39953 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39954 index 74d749e..eefb1bd 100644
39955 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39956 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39957 @@ -31,6 +31,8 @@
39958 #include <linux/netdevice.h>
39959 #include <linux/phy.h>
39960 #include <linux/platform_device.h>
39961 +#include <linux/interrupt.h>
39962 +#include <linux/irqreturn.h>
39963 #include <net/ip.h>
39964
39965 #include "ftgmac100.h"
39966 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39967 index b901a01..1ff32ee 100644
39968 --- a/drivers/net/ethernet/faraday/ftmac100.c
39969 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39970 @@ -31,6 +31,8 @@
39971 #include <linux/module.h>
39972 #include <linux/netdevice.h>
39973 #include <linux/platform_device.h>
39974 +#include <linux/interrupt.h>
39975 +#include <linux/irqreturn.h>
39976
39977 #include "ftmac100.h"
39978
39979 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39980 index a59f077..7925d77 100644
39981 --- a/drivers/net/ethernet/intel/e100.c
39982 +++ b/drivers/net/ethernet/intel/e100.c
39983 @@ -870,7 +870,7 @@ err_unlock:
39984 }
39985
39986 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39987 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39988 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39989 {
39990 struct cb *cb;
39991 unsigned long flags;
39992 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39993 nic->cbs_avail--;
39994 cb->skb = skb;
39995
39996 + err = cb_prepare(nic, cb, skb);
39997 + if (err)
39998 + goto err_unlock;
39999 +
40000 if (unlikely(!nic->cbs_avail))
40001 err = -ENOSPC;
40002
40003 - cb_prepare(nic, cb, skb);
40004
40005 /* Order is important otherwise we'll be in a race with h/w:
40006 * set S-bit in current first, then clear S-bit in previous. */
40007 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
40008 nic->mii.mdio_write = mdio_write;
40009 }
40010
40011 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40012 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40013 {
40014 struct config *config = &cb->u.config;
40015 u8 *c = (u8 *)config;
40016 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40017 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
40018 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
40019 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
40020 + return 0;
40021 }
40022
40023 /*************************************************************************
40024 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
40025 return fw;
40026 }
40027
40028 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40029 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
40030 struct sk_buff *skb)
40031 {
40032 const struct firmware *fw = (void *)skb;
40033 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40034 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
40035
40036 cb->command = cpu_to_le16(cb_ucode | cb_el);
40037 + return 0;
40038 }
40039
40040 static inline int e100_load_ucode_wait(struct nic *nic)
40041 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40042 return err;
40043 }
40044
40045 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40046 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40047 struct sk_buff *skb)
40048 {
40049 cb->command = cpu_to_le16(cb_iaaddr);
40050 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40051 + return 0;
40052 }
40053
40054 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40055 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40056 {
40057 cb->command = cpu_to_le16(cb_dump);
40058 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40059 offsetof(struct mem, dump_buf));
40060 + return 0;
40061 }
40062
40063 static int e100_phy_check_without_mii(struct nic *nic)
40064 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40065 return 0;
40066 }
40067
40068 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40069 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40070 {
40071 struct net_device *netdev = nic->netdev;
40072 struct netdev_hw_addr *ha;
40073 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40074 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40075 ETH_ALEN);
40076 }
40077 + return 0;
40078 }
40079
40080 static void e100_set_multicast_list(struct net_device *netdev)
40081 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40082 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40083 }
40084
40085 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40086 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40087 struct sk_buff *skb)
40088 {
40089 + dma_addr_t dma_addr;
40090 cb->command = nic->tx_command;
40091
40092 + dma_addr = pci_map_single(nic->pdev,
40093 + skb->data, skb->len, PCI_DMA_TODEVICE);
40094 + /* If we can't map the skb, have the upper layer try later */
40095 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40096 + return -ENOMEM;
40097 +
40098 /*
40099 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40100 * testing, ie sending frames with bad CRC.
40101 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40102 cb->u.tcb.tcb_byte_count = 0;
40103 cb->u.tcb.threshold = nic->tx_threshold;
40104 cb->u.tcb.tbd_count = 1;
40105 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40106 - skb->data, skb->len, PCI_DMA_TODEVICE));
40107 - /* check for mapping failure? */
40108 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40109 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40110 skb_tx_timestamp(skb);
40111 + return 0;
40112 }
40113
40114 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40115 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40116 index bb9256a..56d8752 100644
40117 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40118 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40119 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40120 }
40121
40122 /* update the base incval used to calculate frequency adjustment */
40123 - ACCESS_ONCE(adapter->base_incval) = incval;
40124 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40125 smp_mb();
40126
40127 /* need lock to prevent incorrect read while modifying cyclecounter */
40128 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40129 index c124e67..db9b897 100644
40130 --- a/drivers/net/ethernet/lantiq_etop.c
40131 +++ b/drivers/net/ethernet/lantiq_etop.c
40132 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40133 return 0;
40134
40135 err_free:
40136 - kfree(dev);
40137 + free_netdev(dev);
40138 err_out:
40139 return err;
40140 }
40141 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40142 index fbe5363..266b4e3 100644
40143 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40144 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40145 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40146 struct __vxge_hw_fifo *fifo;
40147 struct vxge_hw_fifo_config *config;
40148 u32 txdl_size, txdl_per_memblock;
40149 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40150 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40151 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40152 + };
40153 +
40154 struct __vxge_hw_virtualpath *vpath;
40155
40156 if ((vp == NULL) || (attr == NULL)) {
40157 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40158 goto exit;
40159 }
40160
40161 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40162 -
40163 fifo->mempool =
40164 __vxge_hw_mempool_create(vpath->hldev,
40165 fifo->config->memblock_size,
40166 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40167 index 2d849da..23bba3b 100644
40168 --- a/drivers/net/ethernet/realtek/r8169.c
40169 +++ b/drivers/net/ethernet/realtek/r8169.c
40170 @@ -741,22 +741,22 @@ struct rtl8169_private {
40171 struct mdio_ops {
40172 void (*write)(struct rtl8169_private *, int, int);
40173 int (*read)(struct rtl8169_private *, int);
40174 - } mdio_ops;
40175 + } __no_const mdio_ops;
40176
40177 struct pll_power_ops {
40178 void (*down)(struct rtl8169_private *);
40179 void (*up)(struct rtl8169_private *);
40180 - } pll_power_ops;
40181 + } __no_const pll_power_ops;
40182
40183 struct jumbo_ops {
40184 void (*enable)(struct rtl8169_private *);
40185 void (*disable)(struct rtl8169_private *);
40186 - } jumbo_ops;
40187 + } __no_const jumbo_ops;
40188
40189 struct csi_ops {
40190 void (*write)(struct rtl8169_private *, int, int);
40191 u32 (*read)(struct rtl8169_private *, int);
40192 - } csi_ops;
40193 + } __no_const csi_ops;
40194
40195 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40196 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40197 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40198 index 3f93624..cf01144 100644
40199 --- a/drivers/net/ethernet/sfc/ptp.c
40200 +++ b/drivers/net/ethernet/sfc/ptp.c
40201 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40202 (u32)((u64)ptp->start.dma_addr >> 32));
40203
40204 /* Clear flag that signals MC ready */
40205 - ACCESS_ONCE(*start) = 0;
40206 + ACCESS_ONCE_RW(*start) = 0;
40207 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40208 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40209
40210 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40211 index 0c74a70..3bc6f68 100644
40212 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40213 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40214 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40215
40216 writel(value, ioaddr + MMC_CNTRL);
40217
40218 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40219 - MMC_CNTRL, value);
40220 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40221 +// MMC_CNTRL, value);
40222 }
40223
40224 /* To mask all all interrupts.*/
40225 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40226 index e6fe0d8..2b7d752 100644
40227 --- a/drivers/net/hyperv/hyperv_net.h
40228 +++ b/drivers/net/hyperv/hyperv_net.h
40229 @@ -101,7 +101,7 @@ struct rndis_device {
40230
40231 enum rndis_device_state state;
40232 bool link_state;
40233 - atomic_t new_req_id;
40234 + atomic_unchecked_t new_req_id;
40235
40236 spinlock_t request_lock;
40237 struct list_head req_list;
40238 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40239 index 2b657d4..9903bc0 100644
40240 --- a/drivers/net/hyperv/rndis_filter.c
40241 +++ b/drivers/net/hyperv/rndis_filter.c
40242 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40243 * template
40244 */
40245 set = &rndis_msg->msg.set_req;
40246 - set->req_id = atomic_inc_return(&dev->new_req_id);
40247 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40248
40249 /* Add to the request list */
40250 spin_lock_irqsave(&dev->request_lock, flags);
40251 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40252
40253 /* Setup the rndis set */
40254 halt = &request->request_msg.msg.halt_req;
40255 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40256 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40257
40258 /* Ignore return since this msg is optional. */
40259 rndis_filter_send_request(dev, request);
40260 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40261 index 1e9cb0b..7839125 100644
40262 --- a/drivers/net/ieee802154/fakehard.c
40263 +++ b/drivers/net/ieee802154/fakehard.c
40264 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40265 phy->transmit_power = 0xbf;
40266
40267 dev->netdev_ops = &fake_ops;
40268 - dev->ml_priv = &fake_mlme;
40269 + dev->ml_priv = (void *)&fake_mlme;
40270
40271 priv = netdev_priv(dev);
40272 priv->phy = phy;
40273 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40274 index e5cb723..1fc0461 100644
40275 --- a/drivers/net/macvlan.c
40276 +++ b/drivers/net/macvlan.c
40277 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40278 int macvlan_link_register(struct rtnl_link_ops *ops)
40279 {
40280 /* common fields */
40281 - ops->priv_size = sizeof(struct macvlan_dev);
40282 - ops->validate = macvlan_validate;
40283 - ops->maxtype = IFLA_MACVLAN_MAX;
40284 - ops->policy = macvlan_policy;
40285 - ops->changelink = macvlan_changelink;
40286 - ops->get_size = macvlan_get_size;
40287 - ops->fill_info = macvlan_fill_info;
40288 + pax_open_kernel();
40289 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40290 + *(void **)&ops->validate = macvlan_validate;
40291 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40292 + *(const void **)&ops->policy = macvlan_policy;
40293 + *(void **)&ops->changelink = macvlan_changelink;
40294 + *(void **)&ops->get_size = macvlan_get_size;
40295 + *(void **)&ops->fill_info = macvlan_fill_info;
40296 + pax_close_kernel();
40297
40298 return rtnl_link_register(ops);
40299 };
40300 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40301 return NOTIFY_DONE;
40302 }
40303
40304 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40305 +static struct notifier_block macvlan_notifier_block = {
40306 .notifier_call = macvlan_device_event,
40307 };
40308
40309 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40310 index 0f0f9ce..0ca5819 100644
40311 --- a/drivers/net/macvtap.c
40312 +++ b/drivers/net/macvtap.c
40313 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40314 return NOTIFY_DONE;
40315 }
40316
40317 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40318 +static struct notifier_block macvtap_notifier_block = {
40319 .notifier_call = macvtap_device_event,
40320 };
40321
40322 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40323 index daec9b0..6428fcb 100644
40324 --- a/drivers/net/phy/mdio-bitbang.c
40325 +++ b/drivers/net/phy/mdio-bitbang.c
40326 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40327 struct mdiobb_ctrl *ctrl = bus->priv;
40328
40329 module_put(ctrl->ops->owner);
40330 + mdiobus_unregister(bus);
40331 mdiobus_free(bus);
40332 }
40333 EXPORT_SYMBOL(free_mdio_bitbang);
40334 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40335 index 508570e..f706dc7 100644
40336 --- a/drivers/net/ppp/ppp_generic.c
40337 +++ b/drivers/net/ppp/ppp_generic.c
40338 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40339 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40340 struct ppp_stats stats;
40341 struct ppp_comp_stats cstats;
40342 - char *vers;
40343
40344 switch (cmd) {
40345 case SIOCGPPPSTATS:
40346 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40347 break;
40348
40349 case SIOCGPPPVER:
40350 - vers = PPP_VERSION;
40351 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40352 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40353 break;
40354 err = 0;
40355 break;
40356 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40357 index 8efe47a..a8075c5 100644
40358 --- a/drivers/net/team/team.c
40359 +++ b/drivers/net/team/team.c
40360 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40361 return NOTIFY_DONE;
40362 }
40363
40364 -static struct notifier_block team_notifier_block __read_mostly = {
40365 +static struct notifier_block team_notifier_block = {
40366 .notifier_call = team_device_event,
40367 };
40368
40369 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40370 index cb95fe5..16909e2 100644
40371 --- a/drivers/net/tun.c
40372 +++ b/drivers/net/tun.c
40373 @@ -1594,7 +1594,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
40374
40375 if (tun->flags & TUN_TAP_MQ &&
40376 (tun->numqueues + tun->numdisabled > 1))
40377 - return err;
40378 + return -EBUSY;
40379 }
40380 else {
40381 char *name;
40382 @@ -1838,7 +1838,7 @@ unlock:
40383 }
40384
40385 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40386 - unsigned long arg, int ifreq_len)
40387 + unsigned long arg, size_t ifreq_len)
40388 {
40389 struct tun_file *tfile = file->private_data;
40390 struct tun_struct *tun;
40391 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40392 int vnet_hdr_sz;
40393 int ret;
40394
40395 + if (ifreq_len > sizeof ifr)
40396 + return -EFAULT;
40397 +
40398 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40399 if (copy_from_user(&ifr, argp, ifreq_len))
40400 return -EFAULT;
40401 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40402 index cd8ccb2..cff5144 100644
40403 --- a/drivers/net/usb/hso.c
40404 +++ b/drivers/net/usb/hso.c
40405 @@ -71,7 +71,7 @@
40406 #include <asm/byteorder.h>
40407 #include <linux/serial_core.h>
40408 #include <linux/serial.h>
40409 -
40410 +#include <asm/local.h>
40411
40412 #define MOD_AUTHOR "Option Wireless"
40413 #define MOD_DESCRIPTION "USB High Speed Option driver"
40414 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40415 struct urb *urb;
40416
40417 urb = serial->rx_urb[0];
40418 - if (serial->port.count > 0) {
40419 + if (atomic_read(&serial->port.count) > 0) {
40420 count = put_rxbuf_data(urb, serial);
40421 if (count == -1)
40422 return;
40423 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40424 DUMP1(urb->transfer_buffer, urb->actual_length);
40425
40426 /* Anyone listening? */
40427 - if (serial->port.count == 0)
40428 + if (atomic_read(&serial->port.count) == 0)
40429 return;
40430
40431 if (status == 0) {
40432 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40433 tty_port_tty_set(&serial->port, tty);
40434
40435 /* check for port already opened, if not set the termios */
40436 - serial->port.count++;
40437 - if (serial->port.count == 1) {
40438 + if (atomic_inc_return(&serial->port.count) == 1) {
40439 serial->rx_state = RX_IDLE;
40440 /* Force default termio settings */
40441 _hso_serial_set_termios(tty, NULL);
40442 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40443 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40444 if (result) {
40445 hso_stop_serial_device(serial->parent);
40446 - serial->port.count--;
40447 + atomic_dec(&serial->port.count);
40448 kref_put(&serial->parent->ref, hso_serial_ref_free);
40449 }
40450 } else {
40451 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40452
40453 /* reset the rts and dtr */
40454 /* do the actual close */
40455 - serial->port.count--;
40456 + atomic_dec(&serial->port.count);
40457
40458 - if (serial->port.count <= 0) {
40459 - serial->port.count = 0;
40460 + if (atomic_read(&serial->port.count) <= 0) {
40461 + atomic_set(&serial->port.count, 0);
40462 tty_port_tty_set(&serial->port, NULL);
40463 if (!usb_gone)
40464 hso_stop_serial_device(serial->parent);
40465 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40466
40467 /* the actual setup */
40468 spin_lock_irqsave(&serial->serial_lock, flags);
40469 - if (serial->port.count)
40470 + if (atomic_read(&serial->port.count))
40471 _hso_serial_set_termios(tty, old);
40472 else
40473 tty->termios = *old;
40474 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40475 D1("Pending read interrupt on port %d\n", i);
40476 spin_lock(&serial->serial_lock);
40477 if (serial->rx_state == RX_IDLE &&
40478 - serial->port.count > 0) {
40479 + atomic_read(&serial->port.count) > 0) {
40480 /* Setup and send a ctrl req read on
40481 * port i */
40482 if (!serial->rx_urb_filled[0]) {
40483 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40484 /* Start all serial ports */
40485 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40486 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40487 - if (dev2ser(serial_table[i])->port.count) {
40488 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40489 result =
40490 hso_start_serial_device(serial_table[i], GFP_NOIO);
40491 hso_kick_transmit(dev2ser(serial_table[i]));
40492 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40493 index 6993bfa..9053a34 100644
40494 --- a/drivers/net/vxlan.c
40495 +++ b/drivers/net/vxlan.c
40496 @@ -1428,7 +1428,7 @@ nla_put_failure:
40497 return -EMSGSIZE;
40498 }
40499
40500 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40501 +static struct rtnl_link_ops vxlan_link_ops = {
40502 .kind = "vxlan",
40503 .maxtype = IFLA_VXLAN_MAX,
40504 .policy = vxlan_policy,
40505 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40506 index 77fa428..996b355 100644
40507 --- a/drivers/net/wireless/at76c50x-usb.c
40508 +++ b/drivers/net/wireless/at76c50x-usb.c
40509 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40510 }
40511
40512 /* Convert timeout from the DFU status to jiffies */
40513 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40514 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40515 {
40516 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40517 | (s->poll_timeout[1] << 8)
40518 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40519 index 8d78253..bebbb68 100644
40520 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40521 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40522 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40523 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40524 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40525
40526 - ACCESS_ONCE(ads->ds_link) = i->link;
40527 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40528 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40529 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40530
40531 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40532 ctl6 = SM(i->keytype, AR_EncrType);
40533 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40534
40535 if ((i->is_first || i->is_last) &&
40536 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40537 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40538 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40539 | set11nTries(i->rates, 1)
40540 | set11nTries(i->rates, 2)
40541 | set11nTries(i->rates, 3)
40542 | (i->dur_update ? AR_DurUpdateEna : 0)
40543 | SM(0, AR_BurstDur);
40544
40545 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40546 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40547 | set11nRate(i->rates, 1)
40548 | set11nRate(i->rates, 2)
40549 | set11nRate(i->rates, 3);
40550 } else {
40551 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40552 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40553 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40554 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40555 }
40556
40557 if (!i->is_first) {
40558 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40559 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40560 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40561 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40562 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40563 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40564 return;
40565 }
40566
40567 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40568 break;
40569 }
40570
40571 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40572 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40573 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40574 | SM(i->txpower, AR_XmitPower)
40575 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40576 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40577 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40578 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40579
40580 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40581 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40582 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40583 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40584
40585 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40586 return;
40587
40588 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40589 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40590 | set11nPktDurRTSCTS(i->rates, 1);
40591
40592 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40593 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40594 | set11nPktDurRTSCTS(i->rates, 3);
40595
40596 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40597 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40598 | set11nRateFlags(i->rates, 1)
40599 | set11nRateFlags(i->rates, 2)
40600 | set11nRateFlags(i->rates, 3)
40601 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40602 index 301bf72..3f5654f 100644
40603 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40604 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40605 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40606 (i->qcu << AR_TxQcuNum_S) | desc_len;
40607
40608 checksum += val;
40609 - ACCESS_ONCE(ads->info) = val;
40610 + ACCESS_ONCE_RW(ads->info) = val;
40611
40612 checksum += i->link;
40613 - ACCESS_ONCE(ads->link) = i->link;
40614 + ACCESS_ONCE_RW(ads->link) = i->link;
40615
40616 checksum += i->buf_addr[0];
40617 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40618 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40619 checksum += i->buf_addr[1];
40620 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40621 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40622 checksum += i->buf_addr[2];
40623 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40624 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40625 checksum += i->buf_addr[3];
40626 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40627 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40628
40629 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40630 - ACCESS_ONCE(ads->ctl3) = val;
40631 + ACCESS_ONCE_RW(ads->ctl3) = val;
40632 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40633 - ACCESS_ONCE(ads->ctl5) = val;
40634 + ACCESS_ONCE_RW(ads->ctl5) = val;
40635 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40636 - ACCESS_ONCE(ads->ctl7) = val;
40637 + ACCESS_ONCE_RW(ads->ctl7) = val;
40638 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40639 - ACCESS_ONCE(ads->ctl9) = val;
40640 + ACCESS_ONCE_RW(ads->ctl9) = val;
40641
40642 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40643 - ACCESS_ONCE(ads->ctl10) = checksum;
40644 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40645
40646 if (i->is_first || i->is_last) {
40647 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40648 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40649 | set11nTries(i->rates, 1)
40650 | set11nTries(i->rates, 2)
40651 | set11nTries(i->rates, 3)
40652 | (i->dur_update ? AR_DurUpdateEna : 0)
40653 | SM(0, AR_BurstDur);
40654
40655 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40656 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40657 | set11nRate(i->rates, 1)
40658 | set11nRate(i->rates, 2)
40659 | set11nRate(i->rates, 3);
40660 } else {
40661 - ACCESS_ONCE(ads->ctl13) = 0;
40662 - ACCESS_ONCE(ads->ctl14) = 0;
40663 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40664 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40665 }
40666
40667 ads->ctl20 = 0;
40668 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40669
40670 ctl17 = SM(i->keytype, AR_EncrType);
40671 if (!i->is_first) {
40672 - ACCESS_ONCE(ads->ctl11) = 0;
40673 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40674 - ACCESS_ONCE(ads->ctl15) = 0;
40675 - ACCESS_ONCE(ads->ctl16) = 0;
40676 - ACCESS_ONCE(ads->ctl17) = ctl17;
40677 - ACCESS_ONCE(ads->ctl18) = 0;
40678 - ACCESS_ONCE(ads->ctl19) = 0;
40679 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40680 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40681 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40682 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40683 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40684 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40685 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40686 return;
40687 }
40688
40689 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40690 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40691 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40692 | SM(i->txpower, AR_XmitPower)
40693 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40694 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40695 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40696 ctl12 |= SM(val, AR_PAPRDChainMask);
40697
40698 - ACCESS_ONCE(ads->ctl12) = ctl12;
40699 - ACCESS_ONCE(ads->ctl17) = ctl17;
40700 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40701 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40702
40703 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40704 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40705 | set11nPktDurRTSCTS(i->rates, 1);
40706
40707 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40708 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40709 | set11nPktDurRTSCTS(i->rates, 3);
40710
40711 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40712 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40713 | set11nRateFlags(i->rates, 1)
40714 | set11nRateFlags(i->rates, 2)
40715 | set11nRateFlags(i->rates, 3)
40716 | SM(i->rtscts_rate, AR_RTSCTSRate);
40717
40718 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40719 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40720 }
40721
40722 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40723 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40724 index 9d26fc5..60d9f14 100644
40725 --- a/drivers/net/wireless/ath/ath9k/hw.h
40726 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40727 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40728
40729 /* ANI */
40730 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40731 -};
40732 +} __no_const;
40733
40734 /**
40735 * struct ath_hw_ops - callbacks used by hardware code and driver code
40736 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40737 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40738 struct ath_hw_antcomb_conf *antconf);
40739 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40740 -};
40741 +} __no_const;
40742
40743 struct ath_nf_limits {
40744 s16 max;
40745 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40746 index 3726cd6..b655808 100644
40747 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40748 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40749 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40750 */
40751 if (il3945_mod_params.disable_hw_scan) {
40752 D_INFO("Disabling hw_scan\n");
40753 - il3945_mac_ops.hw_scan = NULL;
40754 + pax_open_kernel();
40755 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40756 + pax_close_kernel();
40757 }
40758
40759 D_INFO("*** LOAD DRIVER ***\n");
40760 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40761 index 2c056b1..698efa9 100644
40762 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40763 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40764 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40765 {
40766 struct iwl_priv *priv = file->private_data;
40767 char buf[64];
40768 - int buf_size;
40769 + size_t buf_size;
40770 u32 offset, len;
40771
40772 memset(buf, 0, sizeof(buf));
40773 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40774 struct iwl_priv *priv = file->private_data;
40775
40776 char buf[8];
40777 - int buf_size;
40778 + size_t buf_size;
40779 u32 reset_flag;
40780
40781 memset(buf, 0, sizeof(buf));
40782 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40783 {
40784 struct iwl_priv *priv = file->private_data;
40785 char buf[8];
40786 - int buf_size;
40787 + size_t buf_size;
40788 int ht40;
40789
40790 memset(buf, 0, sizeof(buf));
40791 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40792 {
40793 struct iwl_priv *priv = file->private_data;
40794 char buf[8];
40795 - int buf_size;
40796 + size_t buf_size;
40797 int value;
40798
40799 memset(buf, 0, sizeof(buf));
40800 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40801 {
40802 struct iwl_priv *priv = file->private_data;
40803 char buf[8];
40804 - int buf_size;
40805 + size_t buf_size;
40806 int clear;
40807
40808 memset(buf, 0, sizeof(buf));
40809 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40810 {
40811 struct iwl_priv *priv = file->private_data;
40812 char buf[8];
40813 - int buf_size;
40814 + size_t buf_size;
40815 int trace;
40816
40817 memset(buf, 0, sizeof(buf));
40818 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40819 {
40820 struct iwl_priv *priv = file->private_data;
40821 char buf[8];
40822 - int buf_size;
40823 + size_t buf_size;
40824 int missed;
40825
40826 memset(buf, 0, sizeof(buf));
40827 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40828
40829 struct iwl_priv *priv = file->private_data;
40830 char buf[8];
40831 - int buf_size;
40832 + size_t buf_size;
40833 int plcp;
40834
40835 memset(buf, 0, sizeof(buf));
40836 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40837
40838 struct iwl_priv *priv = file->private_data;
40839 char buf[8];
40840 - int buf_size;
40841 + size_t buf_size;
40842 int flush;
40843
40844 memset(buf, 0, sizeof(buf));
40845 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40846
40847 struct iwl_priv *priv = file->private_data;
40848 char buf[8];
40849 - int buf_size;
40850 + size_t buf_size;
40851 int rts;
40852
40853 if (!priv->cfg->ht_params)
40854 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40855 {
40856 struct iwl_priv *priv = file->private_data;
40857 char buf[8];
40858 - int buf_size;
40859 + size_t buf_size;
40860
40861 memset(buf, 0, sizeof(buf));
40862 buf_size = min(count, sizeof(buf) - 1);
40863 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40864 struct iwl_priv *priv = file->private_data;
40865 u32 event_log_flag;
40866 char buf[8];
40867 - int buf_size;
40868 + size_t buf_size;
40869
40870 /* check that the interface is up */
40871 if (!iwl_is_ready(priv))
40872 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40873 struct iwl_priv *priv = file->private_data;
40874 char buf[8];
40875 u32 calib_disabled;
40876 - int buf_size;
40877 + size_t buf_size;
40878
40879 memset(buf, 0, sizeof(buf));
40880 buf_size = min(count, sizeof(buf) - 1);
40881 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40882 index 35708b9..31f7754 100644
40883 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40884 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40885 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40886 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40887
40888 char buf[8];
40889 - int buf_size;
40890 + size_t buf_size;
40891 u32 reset_flag;
40892
40893 memset(buf, 0, sizeof(buf));
40894 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40895 {
40896 struct iwl_trans *trans = file->private_data;
40897 char buf[8];
40898 - int buf_size;
40899 + size_t buf_size;
40900 int csr;
40901
40902 memset(buf, 0, sizeof(buf));
40903 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40904 index ff90855..e46d223 100644
40905 --- a/drivers/net/wireless/mac80211_hwsim.c
40906 +++ b/drivers/net/wireless/mac80211_hwsim.c
40907 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40908
40909 if (channels > 1) {
40910 hwsim_if_comb.num_different_channels = channels;
40911 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40912 - mac80211_hwsim_ops.cancel_hw_scan =
40913 - mac80211_hwsim_cancel_hw_scan;
40914 - mac80211_hwsim_ops.sw_scan_start = NULL;
40915 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40916 - mac80211_hwsim_ops.remain_on_channel =
40917 - mac80211_hwsim_roc;
40918 - mac80211_hwsim_ops.cancel_remain_on_channel =
40919 - mac80211_hwsim_croc;
40920 - mac80211_hwsim_ops.add_chanctx =
40921 - mac80211_hwsim_add_chanctx;
40922 - mac80211_hwsim_ops.remove_chanctx =
40923 - mac80211_hwsim_remove_chanctx;
40924 - mac80211_hwsim_ops.change_chanctx =
40925 - mac80211_hwsim_change_chanctx;
40926 - mac80211_hwsim_ops.assign_vif_chanctx =
40927 - mac80211_hwsim_assign_vif_chanctx;
40928 - mac80211_hwsim_ops.unassign_vif_chanctx =
40929 - mac80211_hwsim_unassign_vif_chanctx;
40930 + pax_open_kernel();
40931 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40932 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40933 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40934 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40935 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40936 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40937 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40938 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40939 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40940 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40941 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40942 + pax_close_kernel();
40943 }
40944
40945 spin_lock_init(&hwsim_radio_lock);
40946 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40947 index abe1d03..fb02c22 100644
40948 --- a/drivers/net/wireless/rndis_wlan.c
40949 +++ b/drivers/net/wireless/rndis_wlan.c
40950 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40951
40952 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40953
40954 - if (rts_threshold < 0 || rts_threshold > 2347)
40955 + if (rts_threshold > 2347)
40956 rts_threshold = 2347;
40957
40958 tmp = cpu_to_le32(rts_threshold);
40959 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40960 index 0751b35..246ba3e 100644
40961 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40962 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40963 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40964 * for hardware which doesn't support hardware
40965 * sequence counting.
40966 */
40967 - atomic_t seqno;
40968 + atomic_unchecked_t seqno;
40969 };
40970
40971 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40972 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40973 index e488b94..14b6a0c 100644
40974 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40975 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40976 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40977 * sequence counter given by mac80211.
40978 */
40979 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40980 - seqno = atomic_add_return(0x10, &intf->seqno);
40981 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40982 else
40983 - seqno = atomic_read(&intf->seqno);
40984 + seqno = atomic_read_unchecked(&intf->seqno);
40985
40986 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40987 hdr->seq_ctrl |= cpu_to_le16(seqno);
40988 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40989 index e57ee48..541cf6c 100644
40990 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40991 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40992 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40993
40994 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40995
40996 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40997 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40998 + pax_open_kernel();
40999 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41000 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41001 + pax_close_kernel();
41002
41003 wl1251_info("using dedicated interrupt line");
41004 } else {
41005 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41006 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41007 + pax_open_kernel();
41008 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41009 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41010 + pax_close_kernel();
41011
41012 wl1251_info("using SDIO interrupt");
41013 }
41014 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41015 index e5f5f8f..fdf15b7 100644
41016 --- a/drivers/net/wireless/ti/wl12xx/main.c
41017 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41018 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41019 sizeof(wl->conf.mem));
41020
41021 /* read data preparation is only needed by wl127x */
41022 - wl->ops->prepare_read = wl127x_prepare_read;
41023 + pax_open_kernel();
41024 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41025 + pax_close_kernel();
41026
41027 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41028 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41029 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41030 sizeof(wl->conf.mem));
41031
41032 /* read data preparation is only needed by wl127x */
41033 - wl->ops->prepare_read = wl127x_prepare_read;
41034 + pax_open_kernel();
41035 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41036 + pax_close_kernel();
41037
41038 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41039 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41040 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41041 index 8d8c1f8..e754844 100644
41042 --- a/drivers/net/wireless/ti/wl18xx/main.c
41043 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41044 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41045 }
41046
41047 if (!checksum_param) {
41048 - wl18xx_ops.set_rx_csum = NULL;
41049 - wl18xx_ops.init_vif = NULL;
41050 + pax_open_kernel();
41051 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41052 + *(void **)&wl18xx_ops.init_vif = NULL;
41053 + pax_close_kernel();
41054 }
41055
41056 /* Enable 11a Band only if we have 5G antennas */
41057 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41058 index ef2b171..bb513a6 100644
41059 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41060 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41061 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41062 {
41063 struct zd_usb *usb = urb->context;
41064 struct zd_usb_interrupt *intr = &usb->intr;
41065 - int len;
41066 + unsigned int len;
41067 u16 int_num;
41068
41069 ZD_ASSERT(in_interrupt());
41070 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41071 index d93b2b6..ae50401 100644
41072 --- a/drivers/oprofile/buffer_sync.c
41073 +++ b/drivers/oprofile/buffer_sync.c
41074 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41075 if (cookie == NO_COOKIE)
41076 offset = pc;
41077 if (cookie == INVALID_COOKIE) {
41078 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41079 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41080 offset = pc;
41081 }
41082 if (cookie != last_cookie) {
41083 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41084 /* add userspace sample */
41085
41086 if (!mm) {
41087 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41088 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41089 return 0;
41090 }
41091
41092 cookie = lookup_dcookie(mm, s->eip, &offset);
41093
41094 if (cookie == INVALID_COOKIE) {
41095 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41096 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41097 return 0;
41098 }
41099
41100 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41101 /* ignore backtraces if failed to add a sample */
41102 if (state == sb_bt_start) {
41103 state = sb_bt_ignore;
41104 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41105 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41106 }
41107 }
41108 release_mm(mm);
41109 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41110 index c0cc4e7..44d4e54 100644
41111 --- a/drivers/oprofile/event_buffer.c
41112 +++ b/drivers/oprofile/event_buffer.c
41113 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41114 }
41115
41116 if (buffer_pos == buffer_size) {
41117 - atomic_inc(&oprofile_stats.event_lost_overflow);
41118 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41119 return;
41120 }
41121
41122 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41123 index ed2c3ec..deda85a 100644
41124 --- a/drivers/oprofile/oprof.c
41125 +++ b/drivers/oprofile/oprof.c
41126 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41127 if (oprofile_ops.switch_events())
41128 return;
41129
41130 - atomic_inc(&oprofile_stats.multiplex_counter);
41131 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41132 start_switch_worker();
41133 }
41134
41135 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41136 index 84a208d..d61b0a1 100644
41137 --- a/drivers/oprofile/oprofile_files.c
41138 +++ b/drivers/oprofile/oprofile_files.c
41139 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41140
41141 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41142
41143 -static ssize_t timeout_read(struct file *file, char __user *buf,
41144 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41145 size_t count, loff_t *offset)
41146 {
41147 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41148 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41149 index 917d28e..d62d981 100644
41150 --- a/drivers/oprofile/oprofile_stats.c
41151 +++ b/drivers/oprofile/oprofile_stats.c
41152 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41153 cpu_buf->sample_invalid_eip = 0;
41154 }
41155
41156 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41157 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41158 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41159 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41160 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41161 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41162 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41163 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41164 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41165 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41166 }
41167
41168
41169 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41170 index 38b6fc0..b5cbfce 100644
41171 --- a/drivers/oprofile/oprofile_stats.h
41172 +++ b/drivers/oprofile/oprofile_stats.h
41173 @@ -13,11 +13,11 @@
41174 #include <linux/atomic.h>
41175
41176 struct oprofile_stat_struct {
41177 - atomic_t sample_lost_no_mm;
41178 - atomic_t sample_lost_no_mapping;
41179 - atomic_t bt_lost_no_mapping;
41180 - atomic_t event_lost_overflow;
41181 - atomic_t multiplex_counter;
41182 + atomic_unchecked_t sample_lost_no_mm;
41183 + atomic_unchecked_t sample_lost_no_mapping;
41184 + atomic_unchecked_t bt_lost_no_mapping;
41185 + atomic_unchecked_t event_lost_overflow;
41186 + atomic_unchecked_t multiplex_counter;
41187 };
41188
41189 extern struct oprofile_stat_struct oprofile_stats;
41190 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41191 index 849357c..b83c1e0 100644
41192 --- a/drivers/oprofile/oprofilefs.c
41193 +++ b/drivers/oprofile/oprofilefs.c
41194 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41195
41196
41197 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41198 - char const *name, atomic_t *val)
41199 + char const *name, atomic_unchecked_t *val)
41200 {
41201 return __oprofilefs_create_file(sb, root, name,
41202 &atomic_ro_fops, 0444, val);
41203 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41204 index 93404f7..4a313d8 100644
41205 --- a/drivers/oprofile/timer_int.c
41206 +++ b/drivers/oprofile/timer_int.c
41207 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41208 return NOTIFY_OK;
41209 }
41210
41211 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41212 +static struct notifier_block oprofile_cpu_notifier = {
41213 .notifier_call = oprofile_cpu_notify,
41214 };
41215
41216 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41217 index 3f56bc0..707d642 100644
41218 --- a/drivers/parport/procfs.c
41219 +++ b/drivers/parport/procfs.c
41220 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41221
41222 *ppos += len;
41223
41224 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41225 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41226 }
41227
41228 #ifdef CONFIG_PARPORT_1284
41229 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41230
41231 *ppos += len;
41232
41233 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41234 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41235 }
41236 #endif /* IEEE1284.3 support. */
41237
41238 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41239 index c35e8ad..fc33beb 100644
41240 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41241 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41242 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41243 goto init_cleanup;
41244 }
41245
41246 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41247 + pax_open_kernel();
41248 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41249 + pax_close_kernel();
41250 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41251
41252 return retval;
41253 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41254 index a6a71c4..c91097b 100644
41255 --- a/drivers/pci/hotplug/cpcihp_generic.c
41256 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41257 @@ -73,7 +73,6 @@ static u16 port;
41258 static unsigned int enum_bit;
41259 static u8 enum_mask;
41260
41261 -static struct cpci_hp_controller_ops generic_hpc_ops;
41262 static struct cpci_hp_controller generic_hpc;
41263
41264 static int __init validate_parameters(void)
41265 @@ -139,6 +138,10 @@ static int query_enum(void)
41266 return ((value & enum_mask) == enum_mask);
41267 }
41268
41269 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41270 + .query_enum = query_enum,
41271 +};
41272 +
41273 static int __init cpcihp_generic_init(void)
41274 {
41275 int status;
41276 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41277 pci_dev_put(dev);
41278
41279 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41280 - generic_hpc_ops.query_enum = query_enum;
41281 generic_hpc.ops = &generic_hpc_ops;
41282
41283 status = cpci_hp_register_controller(&generic_hpc);
41284 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41285 index 449b4bb..257e2e8 100644
41286 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41287 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41288 @@ -59,7 +59,6 @@
41289 /* local variables */
41290 static bool debug;
41291 static bool poll;
41292 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41293 static struct cpci_hp_controller zt5550_hpc;
41294
41295 /* Primary cPCI bus bridge device */
41296 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41297 return 0;
41298 }
41299
41300 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41301 + .query_enum = zt5550_hc_query_enum,
41302 +};
41303 +
41304 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41305 {
41306 int status;
41307 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41308 dbg("returned from zt5550_hc_config");
41309
41310 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41311 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41312 zt5550_hpc.ops = &zt5550_hpc_ops;
41313 if(!poll) {
41314 zt5550_hpc.irq = hc_dev->irq;
41315 zt5550_hpc.irq_flags = IRQF_SHARED;
41316 zt5550_hpc.dev_id = hc_dev;
41317
41318 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41319 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41320 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41321 + pax_open_kernel();
41322 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41323 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41324 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41325 + pax_open_kernel();
41326 } else {
41327 info("using ENUM# polling mode");
41328 }
41329 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41330 index 76ba8a1..20ca857 100644
41331 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41332 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41333 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41334
41335 void compaq_nvram_init (void __iomem *rom_start)
41336 {
41337 +
41338 +#ifndef CONFIG_PAX_KERNEXEC
41339 if (rom_start) {
41340 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41341 }
41342 +#endif
41343 +
41344 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41345
41346 /* initialize our int15 lock */
41347 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41348 index 202f4a9..8ee47d0 100644
41349 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41350 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41351 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41352 return -EINVAL;
41353 }
41354
41355 - slot->ops->owner = owner;
41356 - slot->ops->mod_name = mod_name;
41357 + pax_open_kernel();
41358 + *(struct module **)&slot->ops->owner = owner;
41359 + *(const char **)&slot->ops->mod_name = mod_name;
41360 + pax_close_kernel();
41361
41362 mutex_lock(&pci_hp_mutex);
41363 /*
41364 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41365 index 939bd1d..a1459c9 100644
41366 --- a/drivers/pci/hotplug/pciehp_core.c
41367 +++ b/drivers/pci/hotplug/pciehp_core.c
41368 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41369 struct slot *slot = ctrl->slot;
41370 struct hotplug_slot *hotplug = NULL;
41371 struct hotplug_slot_info *info = NULL;
41372 - struct hotplug_slot_ops *ops = NULL;
41373 + hotplug_slot_ops_no_const *ops = NULL;
41374 char name[SLOT_NAME_SIZE];
41375 int retval = -ENOMEM;
41376
41377 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41378 index 9c6e9bb..2916736 100644
41379 --- a/drivers/pci/pci-sysfs.c
41380 +++ b/drivers/pci/pci-sysfs.c
41381 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41382 {
41383 /* allocate attribute structure, piggyback attribute name */
41384 int name_len = write_combine ? 13 : 10;
41385 - struct bin_attribute *res_attr;
41386 + bin_attribute_no_const *res_attr;
41387 int retval;
41388
41389 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41390 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41391 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41392 {
41393 int retval;
41394 - struct bin_attribute *attr;
41395 + bin_attribute_no_const *attr;
41396
41397 /* If the device has VPD, try to expose it in sysfs. */
41398 if (dev->vpd) {
41399 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41400 {
41401 int retval;
41402 int rom_size = 0;
41403 - struct bin_attribute *attr;
41404 + bin_attribute_no_const *attr;
41405
41406 if (!sysfs_initialized)
41407 return -EACCES;
41408 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41409 index e851829..a1a7196 100644
41410 --- a/drivers/pci/pci.h
41411 +++ b/drivers/pci/pci.h
41412 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41413 struct pci_vpd {
41414 unsigned int len;
41415 const struct pci_vpd_ops *ops;
41416 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41417 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41418 };
41419
41420 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41421 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41422 index 8474b6a..ee81993 100644
41423 --- a/drivers/pci/pcie/aspm.c
41424 +++ b/drivers/pci/pcie/aspm.c
41425 @@ -27,9 +27,9 @@
41426 #define MODULE_PARAM_PREFIX "pcie_aspm."
41427
41428 /* Note: those are not register definitions */
41429 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41430 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41431 -#define ASPM_STATE_L1 (4) /* L1 state */
41432 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41433 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41434 +#define ASPM_STATE_L1 (4U) /* L1 state */
41435 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41436 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41437
41438 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41439 index 6186f03..1a78714 100644
41440 --- a/drivers/pci/probe.c
41441 +++ b/drivers/pci/probe.c
41442 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41443 struct pci_bus_region region;
41444 bool bar_too_big = false, bar_disabled = false;
41445
41446 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41447 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41448
41449 /* No printks while decoding is disabled! */
41450 if (!dev->mmio_always_on) {
41451 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41452 index 9b8505c..f00870a 100644
41453 --- a/drivers/pci/proc.c
41454 +++ b/drivers/pci/proc.c
41455 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41456 static int __init pci_proc_init(void)
41457 {
41458 struct pci_dev *dev = NULL;
41459 +
41460 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41461 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41462 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41463 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41464 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41465 +#endif
41466 +#else
41467 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41468 +#endif
41469 proc_create("devices", 0, proc_bus_pci_dir,
41470 &proc_bus_pci_dev_operations);
41471 proc_initialized = 1;
41472 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41473 index 2111dbb..79e434b 100644
41474 --- a/drivers/platform/x86/msi-laptop.c
41475 +++ b/drivers/platform/x86/msi-laptop.c
41476 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41477 int result;
41478
41479 /* allow userland write sysfs file */
41480 - dev_attr_bluetooth.store = store_bluetooth;
41481 - dev_attr_wlan.store = store_wlan;
41482 - dev_attr_threeg.store = store_threeg;
41483 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41484 - dev_attr_wlan.attr.mode |= S_IWUSR;
41485 - dev_attr_threeg.attr.mode |= S_IWUSR;
41486 + pax_open_kernel();
41487 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41488 + *(void **)&dev_attr_wlan.store = store_wlan;
41489 + *(void **)&dev_attr_threeg.store = store_threeg;
41490 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41491 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41492 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41493 + pax_close_kernel();
41494
41495 /* disable hardware control by fn key */
41496 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41497 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41498 index 0fe987f..6f3d5c3 100644
41499 --- a/drivers/platform/x86/sony-laptop.c
41500 +++ b/drivers/platform/x86/sony-laptop.c
41501 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41502 }
41503
41504 /* High speed charging function */
41505 -static struct device_attribute *hsc_handle;
41506 +static device_attribute_no_const *hsc_handle;
41507
41508 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41509 struct device_attribute *attr,
41510 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41511 index f946ca7..f25c833 100644
41512 --- a/drivers/platform/x86/thinkpad_acpi.c
41513 +++ b/drivers/platform/x86/thinkpad_acpi.c
41514 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41515 return 0;
41516 }
41517
41518 -void static hotkey_mask_warn_incomplete_mask(void)
41519 +static void hotkey_mask_warn_incomplete_mask(void)
41520 {
41521 /* log only what the user can fix... */
41522 const u32 wantedmask = hotkey_driver_mask &
41523 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41524 }
41525 }
41526
41527 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41528 - struct tp_nvram_state *newn,
41529 - const u32 event_mask)
41530 -{
41531 -
41532 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41533 do { \
41534 if ((event_mask & (1 << __scancode)) && \
41535 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41536 tpacpi_hotkey_send_key(__scancode); \
41537 } while (0)
41538
41539 - void issue_volchange(const unsigned int oldvol,
41540 - const unsigned int newvol)
41541 - {
41542 - unsigned int i = oldvol;
41543 +static void issue_volchange(const unsigned int oldvol,
41544 + const unsigned int newvol,
41545 + const u32 event_mask)
41546 +{
41547 + unsigned int i = oldvol;
41548
41549 - while (i > newvol) {
41550 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41551 - i--;
41552 - }
41553 - while (i < newvol) {
41554 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41555 - i++;
41556 - }
41557 + while (i > newvol) {
41558 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41559 + i--;
41560 }
41561 + while (i < newvol) {
41562 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41563 + i++;
41564 + }
41565 +}
41566
41567 - void issue_brightnesschange(const unsigned int oldbrt,
41568 - const unsigned int newbrt)
41569 - {
41570 - unsigned int i = oldbrt;
41571 +static void issue_brightnesschange(const unsigned int oldbrt,
41572 + const unsigned int newbrt,
41573 + const u32 event_mask)
41574 +{
41575 + unsigned int i = oldbrt;
41576
41577 - while (i > newbrt) {
41578 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41579 - i--;
41580 - }
41581 - while (i < newbrt) {
41582 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41583 - i++;
41584 - }
41585 + while (i > newbrt) {
41586 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41587 + i--;
41588 + }
41589 + while (i < newbrt) {
41590 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41591 + i++;
41592 }
41593 +}
41594
41595 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41596 + struct tp_nvram_state *newn,
41597 + const u32 event_mask)
41598 +{
41599 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41600 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41601 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41602 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41603 oldn->volume_level != newn->volume_level) {
41604 /* recently muted, or repeated mute keypress, or
41605 * multiple presses ending in mute */
41606 - issue_volchange(oldn->volume_level, newn->volume_level);
41607 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41608 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41609 }
41610 } else {
41611 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41612 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41613 }
41614 if (oldn->volume_level != newn->volume_level) {
41615 - issue_volchange(oldn->volume_level, newn->volume_level);
41616 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41617 } else if (oldn->volume_toggle != newn->volume_toggle) {
41618 /* repeated vol up/down keypress at end of scale ? */
41619 if (newn->volume_level == 0)
41620 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41621 /* handle brightness */
41622 if (oldn->brightness_level != newn->brightness_level) {
41623 issue_brightnesschange(oldn->brightness_level,
41624 - newn->brightness_level);
41625 + newn->brightness_level,
41626 + event_mask);
41627 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41628 /* repeated key presses that didn't change state */
41629 if (newn->brightness_level == 0)
41630 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41631 && !tp_features.bright_unkfw)
41632 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41633 }
41634 +}
41635
41636 #undef TPACPI_COMPARE_KEY
41637 #undef TPACPI_MAY_SEND_KEY
41638 -}
41639
41640 /*
41641 * Polling driver
41642 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41643 index 769d265..a3a05ca 100644
41644 --- a/drivers/pnp/pnpbios/bioscalls.c
41645 +++ b/drivers/pnp/pnpbios/bioscalls.c
41646 @@ -58,7 +58,7 @@ do { \
41647 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41648 } while(0)
41649
41650 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41651 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41652 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41653
41654 /*
41655 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41656
41657 cpu = get_cpu();
41658 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41659 +
41660 + pax_open_kernel();
41661 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41662 + pax_close_kernel();
41663
41664 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41665 spin_lock_irqsave(&pnp_bios_lock, flags);
41666 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41667 :"memory");
41668 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41669
41670 + pax_open_kernel();
41671 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41672 + pax_close_kernel();
41673 +
41674 put_cpu();
41675
41676 /* If we get here and this is set then the PnP BIOS faulted on us. */
41677 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41678 return status;
41679 }
41680
41681 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41682 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41683 {
41684 int i;
41685
41686 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41687 pnp_bios_callpoint.offset = header->fields.pm16offset;
41688 pnp_bios_callpoint.segment = PNP_CS16;
41689
41690 + pax_open_kernel();
41691 +
41692 for_each_possible_cpu(i) {
41693 struct desc_struct *gdt = get_cpu_gdt_table(i);
41694 if (!gdt)
41695 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41696 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41697 (unsigned long)__va(header->fields.pm16dseg));
41698 }
41699 +
41700 + pax_close_kernel();
41701 }
41702 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41703 index 3e6db1c..1fbbdae 100644
41704 --- a/drivers/pnp/resource.c
41705 +++ b/drivers/pnp/resource.c
41706 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41707 return 1;
41708
41709 /* check if the resource is valid */
41710 - if (*irq < 0 || *irq > 15)
41711 + if (*irq > 15)
41712 return 0;
41713
41714 /* check if the resource is reserved */
41715 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41716 return 1;
41717
41718 /* check if the resource is valid */
41719 - if (*dma < 0 || *dma == 4 || *dma > 7)
41720 + if (*dma == 4 || *dma > 7)
41721 return 0;
41722
41723 /* check if the resource is reserved */
41724 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41725 index 7df7c5f..bd48c47 100644
41726 --- a/drivers/power/pda_power.c
41727 +++ b/drivers/power/pda_power.c
41728 @@ -37,7 +37,11 @@ static int polling;
41729
41730 #ifdef CONFIG_USB_OTG_UTILS
41731 static struct usb_phy *transceiver;
41732 -static struct notifier_block otg_nb;
41733 +static int otg_handle_notification(struct notifier_block *nb,
41734 + unsigned long event, void *unused);
41735 +static struct notifier_block otg_nb = {
41736 + .notifier_call = otg_handle_notification
41737 +};
41738 #endif
41739
41740 static struct regulator *ac_draw;
41741 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41742
41743 #ifdef CONFIG_USB_OTG_UTILS
41744 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41745 - otg_nb.notifier_call = otg_handle_notification;
41746 ret = usb_register_notifier(transceiver, &otg_nb);
41747 if (ret) {
41748 dev_err(dev, "failure to register otg notifier\n");
41749 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41750 index cc439fd..8fa30df 100644
41751 --- a/drivers/power/power_supply.h
41752 +++ b/drivers/power/power_supply.h
41753 @@ -16,12 +16,12 @@ struct power_supply;
41754
41755 #ifdef CONFIG_SYSFS
41756
41757 -extern void power_supply_init_attrs(struct device_type *dev_type);
41758 +extern void power_supply_init_attrs(void);
41759 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41760
41761 #else
41762
41763 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41764 +static inline void power_supply_init_attrs(void) {}
41765 #define power_supply_uevent NULL
41766
41767 #endif /* CONFIG_SYSFS */
41768 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41769 index 8a7cfb3..72e6e9b 100644
41770 --- a/drivers/power/power_supply_core.c
41771 +++ b/drivers/power/power_supply_core.c
41772 @@ -24,7 +24,10 @@
41773 struct class *power_supply_class;
41774 EXPORT_SYMBOL_GPL(power_supply_class);
41775
41776 -static struct device_type power_supply_dev_type;
41777 +extern const struct attribute_group *power_supply_attr_groups[];
41778 +static struct device_type power_supply_dev_type = {
41779 + .groups = power_supply_attr_groups,
41780 +};
41781
41782 static int __power_supply_changed_work(struct device *dev, void *data)
41783 {
41784 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41785 return PTR_ERR(power_supply_class);
41786
41787 power_supply_class->dev_uevent = power_supply_uevent;
41788 - power_supply_init_attrs(&power_supply_dev_type);
41789 + power_supply_init_attrs();
41790
41791 return 0;
41792 }
41793 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41794 index 40fa3b7..d9c2e0e 100644
41795 --- a/drivers/power/power_supply_sysfs.c
41796 +++ b/drivers/power/power_supply_sysfs.c
41797 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41798 .is_visible = power_supply_attr_is_visible,
41799 };
41800
41801 -static const struct attribute_group *power_supply_attr_groups[] = {
41802 +const struct attribute_group *power_supply_attr_groups[] = {
41803 &power_supply_attr_group,
41804 NULL,
41805 };
41806
41807 -void power_supply_init_attrs(struct device_type *dev_type)
41808 +void power_supply_init_attrs(void)
41809 {
41810 int i;
41811
41812 - dev_type->groups = power_supply_attr_groups;
41813 -
41814 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41815 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41816 }
41817 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41818 index 4d7c635..9860196 100644
41819 --- a/drivers/regulator/max8660.c
41820 +++ b/drivers/regulator/max8660.c
41821 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41822 max8660->shadow_regs[MAX8660_OVER1] = 5;
41823 } else {
41824 /* Otherwise devices can be toggled via software */
41825 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41826 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41827 + pax_open_kernel();
41828 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41829 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41830 + pax_close_kernel();
41831 }
41832
41833 /*
41834 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41835 index 9a8ea91..c483dd9 100644
41836 --- a/drivers/regulator/max8973-regulator.c
41837 +++ b/drivers/regulator/max8973-regulator.c
41838 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41839 if (!pdata->enable_ext_control) {
41840 max->desc.enable_reg = MAX8973_VOUT;
41841 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41842 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41843 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41844 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41845 + pax_open_kernel();
41846 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41847 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41848 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41849 + pax_close_kernel();
41850 }
41851
41852 max->enable_external_control = pdata->enable_ext_control;
41853 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41854 index 0d84b1f..c2da6ac 100644
41855 --- a/drivers/regulator/mc13892-regulator.c
41856 +++ b/drivers/regulator/mc13892-regulator.c
41857 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41858 }
41859 mc13xxx_unlock(mc13892);
41860
41861 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41862 + pax_open_kernel();
41863 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41864 = mc13892_vcam_set_mode;
41865 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41866 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41867 = mc13892_vcam_get_mode;
41868 + pax_close_kernel();
41869
41870 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41871 ARRAY_SIZE(mc13892_regulators));
41872 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41873 index 1c77423..2971d18 100644
41874 --- a/drivers/rtc/rtc-cmos.c
41875 +++ b/drivers/rtc/rtc-cmos.c
41876 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41877 hpet_rtc_timer_init();
41878
41879 /* export at least the first block of NVRAM */
41880 - nvram.size = address_space - NVRAM_OFFSET;
41881 + pax_open_kernel();
41882 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41883 + pax_close_kernel();
41884 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41885 if (retval < 0) {
41886 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41887 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41888 index 9a86b4b..3a383dc 100644
41889 --- a/drivers/rtc/rtc-dev.c
41890 +++ b/drivers/rtc/rtc-dev.c
41891 @@ -14,6 +14,7 @@
41892 #include <linux/module.h>
41893 #include <linux/rtc.h>
41894 #include <linux/sched.h>
41895 +#include <linux/grsecurity.h>
41896 #include "rtc-core.h"
41897
41898 static dev_t rtc_devt;
41899 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41900 if (copy_from_user(&tm, uarg, sizeof(tm)))
41901 return -EFAULT;
41902
41903 + gr_log_timechange();
41904 +
41905 return rtc_set_time(rtc, &tm);
41906
41907 case RTC_PIE_ON:
41908 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41909 index e0d0ba4..3c65868 100644
41910 --- a/drivers/rtc/rtc-ds1307.c
41911 +++ b/drivers/rtc/rtc-ds1307.c
41912 @@ -106,7 +106,7 @@ struct ds1307 {
41913 u8 offset; /* register's offset */
41914 u8 regs[11];
41915 u16 nvram_offset;
41916 - struct bin_attribute *nvram;
41917 + bin_attribute_no_const *nvram;
41918 enum ds_type type;
41919 unsigned long flags;
41920 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41921 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41922 index 130f29a..6179d03 100644
41923 --- a/drivers/rtc/rtc-m48t59.c
41924 +++ b/drivers/rtc/rtc-m48t59.c
41925 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41926 goto out;
41927 }
41928
41929 - m48t59_nvram_attr.size = pdata->offset;
41930 + pax_open_kernel();
41931 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41932 + pax_close_kernel();
41933
41934 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41935 if (ret) {
41936 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41937 index e693af6..2e525b6 100644
41938 --- a/drivers/scsi/bfa/bfa_fcpim.h
41939 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41940 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41941
41942 struct bfa_itn_s {
41943 bfa_isr_func_t isr;
41944 -};
41945 +} __no_const;
41946
41947 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41948 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41949 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41950 index 23a90e7..9cf04ee 100644
41951 --- a/drivers/scsi/bfa/bfa_ioc.h
41952 +++ b/drivers/scsi/bfa/bfa_ioc.h
41953 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41954 bfa_ioc_disable_cbfn_t disable_cbfn;
41955 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41956 bfa_ioc_reset_cbfn_t reset_cbfn;
41957 -};
41958 +} __no_const;
41959
41960 /*
41961 * IOC event notification mechanism.
41962 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41963 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41964 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41965 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41966 -};
41967 +} __no_const;
41968
41969 /*
41970 * Queue element to wait for room in request queue. FIFO order is
41971 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41972 index 593085a..47aa999 100644
41973 --- a/drivers/scsi/hosts.c
41974 +++ b/drivers/scsi/hosts.c
41975 @@ -42,7 +42,7 @@
41976 #include "scsi_logging.h"
41977
41978
41979 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41980 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41981
41982
41983 static void scsi_host_cls_release(struct device *dev)
41984 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41985 * subtract one because we increment first then return, but we need to
41986 * know what the next host number was before increment
41987 */
41988 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41989 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41990 shost->dma_channel = 0xff;
41991
41992 /* These three are default values which can be overridden */
41993 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41994 index 4f33806..afd6f60 100644
41995 --- a/drivers/scsi/hpsa.c
41996 +++ b/drivers/scsi/hpsa.c
41997 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41998 unsigned long flags;
41999
42000 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42001 - return h->access.command_completed(h, q);
42002 + return h->access->command_completed(h, q);
42003
42004 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42005 a = rq->head[rq->current_entry];
42006 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
42007 while (!list_empty(&h->reqQ)) {
42008 c = list_entry(h->reqQ.next, struct CommandList, list);
42009 /* can't do anything if fifo is full */
42010 - if ((h->access.fifo_full(h))) {
42011 + if ((h->access->fifo_full(h))) {
42012 dev_warn(&h->pdev->dev, "fifo full\n");
42013 break;
42014 }
42015 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
42016
42017 /* Tell the controller execute command */
42018 spin_unlock_irqrestore(&h->lock, flags);
42019 - h->access.submit_command(h, c);
42020 + h->access->submit_command(h, c);
42021 spin_lock_irqsave(&h->lock, flags);
42022 }
42023 spin_unlock_irqrestore(&h->lock, flags);
42024 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
42025
42026 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42027 {
42028 - return h->access.command_completed(h, q);
42029 + return h->access->command_completed(h, q);
42030 }
42031
42032 static inline bool interrupt_pending(struct ctlr_info *h)
42033 {
42034 - return h->access.intr_pending(h);
42035 + return h->access->intr_pending(h);
42036 }
42037
42038 static inline long interrupt_not_for_us(struct ctlr_info *h)
42039 {
42040 - return (h->access.intr_pending(h) == 0) ||
42041 + return (h->access->intr_pending(h) == 0) ||
42042 (h->interrupts_enabled == 0);
42043 }
42044
42045 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42046 if (prod_index < 0)
42047 return -ENODEV;
42048 h->product_name = products[prod_index].product_name;
42049 - h->access = *(products[prod_index].access);
42050 + h->access = products[prod_index].access;
42051
42052 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42053 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42054 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42055
42056 assert_spin_locked(&lockup_detector_lock);
42057 remove_ctlr_from_lockup_detector_list(h);
42058 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42059 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42060 spin_lock_irqsave(&h->lock, flags);
42061 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42062 spin_unlock_irqrestore(&h->lock, flags);
42063 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42064 }
42065
42066 /* make sure the board interrupts are off */
42067 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42068 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42069
42070 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42071 goto clean2;
42072 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42073 * fake ones to scoop up any residual completions.
42074 */
42075 spin_lock_irqsave(&h->lock, flags);
42076 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42077 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42078 spin_unlock_irqrestore(&h->lock, flags);
42079 free_irqs(h);
42080 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42081 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42082 dev_info(&h->pdev->dev, "Board READY.\n");
42083 dev_info(&h->pdev->dev,
42084 "Waiting for stale completions to drain.\n");
42085 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42086 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42087 msleep(10000);
42088 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42089 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42090
42091 rc = controller_reset_failed(h->cfgtable);
42092 if (rc)
42093 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42094 }
42095
42096 /* Turn the interrupts on so we can service requests */
42097 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42098 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42099
42100 hpsa_hba_inquiry(h);
42101 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42102 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42103 * To write all data in the battery backed cache to disks
42104 */
42105 hpsa_flush_cache(h);
42106 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42107 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42108 hpsa_free_irqs_and_disable_msix(h);
42109 }
42110
42111 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42112 return;
42113 }
42114 /* Change the access methods to the performant access methods */
42115 - h->access = SA5_performant_access;
42116 + h->access = &SA5_performant_access;
42117 h->transMethod = CFGTBL_Trans_Performant;
42118 }
42119
42120 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42121 index 9816479..c5d4e97 100644
42122 --- a/drivers/scsi/hpsa.h
42123 +++ b/drivers/scsi/hpsa.h
42124 @@ -79,7 +79,7 @@ struct ctlr_info {
42125 unsigned int msix_vector;
42126 unsigned int msi_vector;
42127 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42128 - struct access_method access;
42129 + struct access_method *access;
42130
42131 /* queue and queue Info */
42132 struct list_head reqQ;
42133 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42134 index c772d8d..35c362c 100644
42135 --- a/drivers/scsi/libfc/fc_exch.c
42136 +++ b/drivers/scsi/libfc/fc_exch.c
42137 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42138 u16 pool_max_index;
42139
42140 struct {
42141 - atomic_t no_free_exch;
42142 - atomic_t no_free_exch_xid;
42143 - atomic_t xid_not_found;
42144 - atomic_t xid_busy;
42145 - atomic_t seq_not_found;
42146 - atomic_t non_bls_resp;
42147 + atomic_unchecked_t no_free_exch;
42148 + atomic_unchecked_t no_free_exch_xid;
42149 + atomic_unchecked_t xid_not_found;
42150 + atomic_unchecked_t xid_busy;
42151 + atomic_unchecked_t seq_not_found;
42152 + atomic_unchecked_t non_bls_resp;
42153 } stats;
42154 };
42155
42156 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42157 /* allocate memory for exchange */
42158 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42159 if (!ep) {
42160 - atomic_inc(&mp->stats.no_free_exch);
42161 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42162 goto out;
42163 }
42164 memset(ep, 0, sizeof(*ep));
42165 @@ -786,7 +786,7 @@ out:
42166 return ep;
42167 err:
42168 spin_unlock_bh(&pool->lock);
42169 - atomic_inc(&mp->stats.no_free_exch_xid);
42170 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42171 mempool_free(ep, mp->ep_pool);
42172 return NULL;
42173 }
42174 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42175 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42176 ep = fc_exch_find(mp, xid);
42177 if (!ep) {
42178 - atomic_inc(&mp->stats.xid_not_found);
42179 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42180 reject = FC_RJT_OX_ID;
42181 goto out;
42182 }
42183 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42184 ep = fc_exch_find(mp, xid);
42185 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42186 if (ep) {
42187 - atomic_inc(&mp->stats.xid_busy);
42188 + atomic_inc_unchecked(&mp->stats.xid_busy);
42189 reject = FC_RJT_RX_ID;
42190 goto rel;
42191 }
42192 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42193 }
42194 xid = ep->xid; /* get our XID */
42195 } else if (!ep) {
42196 - atomic_inc(&mp->stats.xid_not_found);
42197 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42198 reject = FC_RJT_RX_ID; /* XID not found */
42199 goto out;
42200 }
42201 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42202 } else {
42203 sp = &ep->seq;
42204 if (sp->id != fh->fh_seq_id) {
42205 - atomic_inc(&mp->stats.seq_not_found);
42206 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42207 if (f_ctl & FC_FC_END_SEQ) {
42208 /*
42209 * Update sequence_id based on incoming last
42210 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42211
42212 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42213 if (!ep) {
42214 - atomic_inc(&mp->stats.xid_not_found);
42215 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42216 goto out;
42217 }
42218 if (ep->esb_stat & ESB_ST_COMPLETE) {
42219 - atomic_inc(&mp->stats.xid_not_found);
42220 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42221 goto rel;
42222 }
42223 if (ep->rxid == FC_XID_UNKNOWN)
42224 ep->rxid = ntohs(fh->fh_rx_id);
42225 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42226 - atomic_inc(&mp->stats.xid_not_found);
42227 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42228 goto rel;
42229 }
42230 if (ep->did != ntoh24(fh->fh_s_id) &&
42231 ep->did != FC_FID_FLOGI) {
42232 - atomic_inc(&mp->stats.xid_not_found);
42233 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42234 goto rel;
42235 }
42236 sof = fr_sof(fp);
42237 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42238 sp->ssb_stat |= SSB_ST_RESP;
42239 sp->id = fh->fh_seq_id;
42240 } else if (sp->id != fh->fh_seq_id) {
42241 - atomic_inc(&mp->stats.seq_not_found);
42242 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42243 goto rel;
42244 }
42245
42246 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42247 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42248
42249 if (!sp)
42250 - atomic_inc(&mp->stats.xid_not_found);
42251 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42252 else
42253 - atomic_inc(&mp->stats.non_bls_resp);
42254 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42255
42256 fc_frame_free(fp);
42257 }
42258 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42259
42260 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42261 mp = ema->mp;
42262 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42263 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42264 st->fc_no_free_exch_xid +=
42265 - atomic_read(&mp->stats.no_free_exch_xid);
42266 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42267 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42268 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42269 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42270 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42271 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42272 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42273 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42274 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42275 }
42276 }
42277 EXPORT_SYMBOL(fc_exch_update_stats);
42278 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42279 index bdb81cd..d3c7c2c 100644
42280 --- a/drivers/scsi/libsas/sas_ata.c
42281 +++ b/drivers/scsi/libsas/sas_ata.c
42282 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42283 .postreset = ata_std_postreset,
42284 .error_handler = ata_std_error_handler,
42285 .post_internal_cmd = sas_ata_post_internal,
42286 - .qc_defer = ata_std_qc_defer,
42287 + .qc_defer = ata_std_qc_defer,
42288 .qc_prep = ata_noop_qc_prep,
42289 .qc_issue = sas_ata_qc_issue,
42290 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42291 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42292 index df4c13a..a51e90c 100644
42293 --- a/drivers/scsi/lpfc/lpfc.h
42294 +++ b/drivers/scsi/lpfc/lpfc.h
42295 @@ -424,7 +424,7 @@ struct lpfc_vport {
42296 struct dentry *debug_nodelist;
42297 struct dentry *vport_debugfs_root;
42298 struct lpfc_debugfs_trc *disc_trc;
42299 - atomic_t disc_trc_cnt;
42300 + atomic_unchecked_t disc_trc_cnt;
42301 #endif
42302 uint8_t stat_data_enabled;
42303 uint8_t stat_data_blocked;
42304 @@ -842,8 +842,8 @@ struct lpfc_hba {
42305 struct timer_list fabric_block_timer;
42306 unsigned long bit_flags;
42307 #define FABRIC_COMANDS_BLOCKED 0
42308 - atomic_t num_rsrc_err;
42309 - atomic_t num_cmd_success;
42310 + atomic_unchecked_t num_rsrc_err;
42311 + atomic_unchecked_t num_cmd_success;
42312 unsigned long last_rsrc_error_time;
42313 unsigned long last_ramp_down_time;
42314 unsigned long last_ramp_up_time;
42315 @@ -879,7 +879,7 @@ struct lpfc_hba {
42316
42317 struct dentry *debug_slow_ring_trc;
42318 struct lpfc_debugfs_trc *slow_ring_trc;
42319 - atomic_t slow_ring_trc_cnt;
42320 + atomic_unchecked_t slow_ring_trc_cnt;
42321 /* iDiag debugfs sub-directory */
42322 struct dentry *idiag_root;
42323 struct dentry *idiag_pci_cfg;
42324 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42325 index f63f5ff..de29189 100644
42326 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42327 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42328 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42329
42330 #include <linux/debugfs.h>
42331
42332 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42333 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42334 static unsigned long lpfc_debugfs_start_time = 0L;
42335
42336 /* iDiag */
42337 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42338 lpfc_debugfs_enable = 0;
42339
42340 len = 0;
42341 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42342 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42343 (lpfc_debugfs_max_disc_trc - 1);
42344 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42345 dtp = vport->disc_trc + i;
42346 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42347 lpfc_debugfs_enable = 0;
42348
42349 len = 0;
42350 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42351 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42352 (lpfc_debugfs_max_slow_ring_trc - 1);
42353 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42354 dtp = phba->slow_ring_trc + i;
42355 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42356 !vport || !vport->disc_trc)
42357 return;
42358
42359 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42360 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42361 (lpfc_debugfs_max_disc_trc - 1);
42362 dtp = vport->disc_trc + index;
42363 dtp->fmt = fmt;
42364 dtp->data1 = data1;
42365 dtp->data2 = data2;
42366 dtp->data3 = data3;
42367 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42368 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42369 dtp->jif = jiffies;
42370 #endif
42371 return;
42372 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42373 !phba || !phba->slow_ring_trc)
42374 return;
42375
42376 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42377 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42378 (lpfc_debugfs_max_slow_ring_trc - 1);
42379 dtp = phba->slow_ring_trc + index;
42380 dtp->fmt = fmt;
42381 dtp->data1 = data1;
42382 dtp->data2 = data2;
42383 dtp->data3 = data3;
42384 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42385 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42386 dtp->jif = jiffies;
42387 #endif
42388 return;
42389 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42390 "slow_ring buffer\n");
42391 goto debug_failed;
42392 }
42393 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42394 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42395 memset(phba->slow_ring_trc, 0,
42396 (sizeof(struct lpfc_debugfs_trc) *
42397 lpfc_debugfs_max_slow_ring_trc));
42398 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42399 "buffer\n");
42400 goto debug_failed;
42401 }
42402 - atomic_set(&vport->disc_trc_cnt, 0);
42403 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42404
42405 snprintf(name, sizeof(name), "discovery_trace");
42406 vport->debug_disc_trc =
42407 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42408 index 89ad558..76956c4 100644
42409 --- a/drivers/scsi/lpfc/lpfc_init.c
42410 +++ b/drivers/scsi/lpfc/lpfc_init.c
42411 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42412 "misc_register returned with status %d", error);
42413
42414 if (lpfc_enable_npiv) {
42415 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42416 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42417 + pax_open_kernel();
42418 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42419 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42420 + pax_close_kernel();
42421 }
42422 lpfc_transport_template =
42423 fc_attach_transport(&lpfc_transport_functions);
42424 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42425 index 60e5a17..ff7a793 100644
42426 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42427 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42428 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42429 uint32_t evt_posted;
42430
42431 spin_lock_irqsave(&phba->hbalock, flags);
42432 - atomic_inc(&phba->num_rsrc_err);
42433 + atomic_inc_unchecked(&phba->num_rsrc_err);
42434 phba->last_rsrc_error_time = jiffies;
42435
42436 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42437 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42438 unsigned long flags;
42439 struct lpfc_hba *phba = vport->phba;
42440 uint32_t evt_posted;
42441 - atomic_inc(&phba->num_cmd_success);
42442 + atomic_inc_unchecked(&phba->num_cmd_success);
42443
42444 if (vport->cfg_lun_queue_depth <= queue_depth)
42445 return;
42446 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42447 unsigned long num_rsrc_err, num_cmd_success;
42448 int i;
42449
42450 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42451 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42452 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42453 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42454
42455 /*
42456 * The error and success command counters are global per
42457 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42458 }
42459 }
42460 lpfc_destroy_vport_work_array(phba, vports);
42461 - atomic_set(&phba->num_rsrc_err, 0);
42462 - atomic_set(&phba->num_cmd_success, 0);
42463 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42464 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42465 }
42466
42467 /**
42468 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42469 }
42470 }
42471 lpfc_destroy_vport_work_array(phba, vports);
42472 - atomic_set(&phba->num_rsrc_err, 0);
42473 - atomic_set(&phba->num_cmd_success, 0);
42474 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42475 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42476 }
42477
42478 /**
42479 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42480 index b46f5e9..c4c4ccb 100644
42481 --- a/drivers/scsi/pmcraid.c
42482 +++ b/drivers/scsi/pmcraid.c
42483 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42484 res->scsi_dev = scsi_dev;
42485 scsi_dev->hostdata = res;
42486 res->change_detected = 0;
42487 - atomic_set(&res->read_failures, 0);
42488 - atomic_set(&res->write_failures, 0);
42489 + atomic_set_unchecked(&res->read_failures, 0);
42490 + atomic_set_unchecked(&res->write_failures, 0);
42491 rc = 0;
42492 }
42493 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42494 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42495
42496 /* If this was a SCSI read/write command keep count of errors */
42497 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42498 - atomic_inc(&res->read_failures);
42499 + atomic_inc_unchecked(&res->read_failures);
42500 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42501 - atomic_inc(&res->write_failures);
42502 + atomic_inc_unchecked(&res->write_failures);
42503
42504 if (!RES_IS_GSCSI(res->cfg_entry) &&
42505 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42506 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42507 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42508 * hrrq_id assigned here in queuecommand
42509 */
42510 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42511 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42512 pinstance->num_hrrq;
42513 cmd->cmd_done = pmcraid_io_done;
42514
42515 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42516 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42517 * hrrq_id assigned here in queuecommand
42518 */
42519 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42520 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42521 pinstance->num_hrrq;
42522
42523 if (request_size) {
42524 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42525
42526 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42527 /* add resources only after host is added into system */
42528 - if (!atomic_read(&pinstance->expose_resources))
42529 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42530 return;
42531
42532 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42533 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42534 init_waitqueue_head(&pinstance->reset_wait_q);
42535
42536 atomic_set(&pinstance->outstanding_cmds, 0);
42537 - atomic_set(&pinstance->last_message_id, 0);
42538 - atomic_set(&pinstance->expose_resources, 0);
42539 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42540 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42541
42542 INIT_LIST_HEAD(&pinstance->free_res_q);
42543 INIT_LIST_HEAD(&pinstance->used_res_q);
42544 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42545 /* Schedule worker thread to handle CCN and take care of adding and
42546 * removing devices to OS
42547 */
42548 - atomic_set(&pinstance->expose_resources, 1);
42549 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42550 schedule_work(&pinstance->worker_q);
42551 return rc;
42552
42553 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42554 index e1d150f..6c6df44 100644
42555 --- a/drivers/scsi/pmcraid.h
42556 +++ b/drivers/scsi/pmcraid.h
42557 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42558 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42559
42560 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42561 - atomic_t last_message_id;
42562 + atomic_unchecked_t last_message_id;
42563
42564 /* configuration table */
42565 struct pmcraid_config_table *cfg_table;
42566 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42567 atomic_t outstanding_cmds;
42568
42569 /* should add/delete resources to mid-layer now ?*/
42570 - atomic_t expose_resources;
42571 + atomic_unchecked_t expose_resources;
42572
42573
42574
42575 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42576 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42577 };
42578 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42579 - atomic_t read_failures; /* count of failed READ commands */
42580 - atomic_t write_failures; /* count of failed WRITE commands */
42581 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42582 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42583
42584 /* To indicate add/delete/modify during CCN */
42585 u8 change_detected;
42586 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42587 index 83d7984..a27d947 100644
42588 --- a/drivers/scsi/qla2xxx/qla_attr.c
42589 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42590 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42591 return 0;
42592 }
42593
42594 -struct fc_function_template qla2xxx_transport_functions = {
42595 +fc_function_template_no_const qla2xxx_transport_functions = {
42596
42597 .show_host_node_name = 1,
42598 .show_host_port_name = 1,
42599 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42600 .bsg_timeout = qla24xx_bsg_timeout,
42601 };
42602
42603 -struct fc_function_template qla2xxx_transport_vport_functions = {
42604 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42605
42606 .show_host_node_name = 1,
42607 .show_host_port_name = 1,
42608 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42609 index 2411d1a..4673766 100644
42610 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42611 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42612 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42613 struct device_attribute;
42614 extern struct device_attribute *qla2x00_host_attrs[];
42615 struct fc_function_template;
42616 -extern struct fc_function_template qla2xxx_transport_functions;
42617 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42618 +extern fc_function_template_no_const qla2xxx_transport_functions;
42619 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42620 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42621 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42622 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42623 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42624 index 10d23f8..a7d5d4c 100644
42625 --- a/drivers/scsi/qla2xxx/qla_os.c
42626 +++ b/drivers/scsi/qla2xxx/qla_os.c
42627 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42628 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42629 /* Ok, a 64bit DMA mask is applicable. */
42630 ha->flags.enable_64bit_addressing = 1;
42631 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42632 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42633 + pax_open_kernel();
42634 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42635 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42636 + pax_close_kernel();
42637 return;
42638 }
42639 }
42640 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42641 index 329d553..f20d31d 100644
42642 --- a/drivers/scsi/qla4xxx/ql4_def.h
42643 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42644 @@ -273,7 +273,7 @@ struct ddb_entry {
42645 * (4000 only) */
42646 atomic_t relogin_timer; /* Max Time to wait for
42647 * relogin to complete */
42648 - atomic_t relogin_retry_count; /* Num of times relogin has been
42649 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42650 * retried */
42651 uint32_t default_time2wait; /* Default Min time between
42652 * relogins (+aens) */
42653 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42654 index 4cec123..7c1329f 100644
42655 --- a/drivers/scsi/qla4xxx/ql4_os.c
42656 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42657 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42658 */
42659 if (!iscsi_is_session_online(cls_sess)) {
42660 /* Reset retry relogin timer */
42661 - atomic_inc(&ddb_entry->relogin_retry_count);
42662 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42663 DEBUG2(ql4_printk(KERN_INFO, ha,
42664 "%s: index[%d] relogin timed out-retrying"
42665 " relogin (%d), retry (%d)\n", __func__,
42666 ddb_entry->fw_ddb_index,
42667 - atomic_read(&ddb_entry->relogin_retry_count),
42668 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42669 ddb_entry->default_time2wait + 4));
42670 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42671 atomic_set(&ddb_entry->retry_relogin_timer,
42672 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42673
42674 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42675 atomic_set(&ddb_entry->relogin_timer, 0);
42676 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42677 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42678 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42679 ddb_entry->default_relogin_timeout =
42680 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42681 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42682 index 2c0d0ec..4e8681a 100644
42683 --- a/drivers/scsi/scsi.c
42684 +++ b/drivers/scsi/scsi.c
42685 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42686 unsigned long timeout;
42687 int rtn = 0;
42688
42689 - atomic_inc(&cmd->device->iorequest_cnt);
42690 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42691
42692 /* check if the device is still usable */
42693 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42694 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42695 index f1bf5af..f67e943 100644
42696 --- a/drivers/scsi/scsi_lib.c
42697 +++ b/drivers/scsi/scsi_lib.c
42698 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42699 shost = sdev->host;
42700 scsi_init_cmd_errh(cmd);
42701 cmd->result = DID_NO_CONNECT << 16;
42702 - atomic_inc(&cmd->device->iorequest_cnt);
42703 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42704
42705 /*
42706 * SCSI request completion path will do scsi_device_unbusy(),
42707 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42708
42709 INIT_LIST_HEAD(&cmd->eh_entry);
42710
42711 - atomic_inc(&cmd->device->iodone_cnt);
42712 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42713 if (cmd->result)
42714 - atomic_inc(&cmd->device->ioerr_cnt);
42715 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42716
42717 disposition = scsi_decide_disposition(cmd);
42718 if (disposition != SUCCESS &&
42719 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42720 index 931a7d9..0c2a754 100644
42721 --- a/drivers/scsi/scsi_sysfs.c
42722 +++ b/drivers/scsi/scsi_sysfs.c
42723 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42724 char *buf) \
42725 { \
42726 struct scsi_device *sdev = to_scsi_device(dev); \
42727 - unsigned long long count = atomic_read(&sdev->field); \
42728 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42729 return snprintf(buf, 20, "0x%llx\n", count); \
42730 } \
42731 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42732 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42733 index 84a1fdf..693b0d6 100644
42734 --- a/drivers/scsi/scsi_tgt_lib.c
42735 +++ b/drivers/scsi/scsi_tgt_lib.c
42736 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42737 int err;
42738
42739 dprintk("%lx %u\n", uaddr, len);
42740 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42741 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42742 if (err) {
42743 /*
42744 * TODO: need to fixup sg_tablesize, max_segment_size,
42745 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42746 index e894ca7..de9d7660 100644
42747 --- a/drivers/scsi/scsi_transport_fc.c
42748 +++ b/drivers/scsi/scsi_transport_fc.c
42749 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42750 * Netlink Infrastructure
42751 */
42752
42753 -static atomic_t fc_event_seq;
42754 +static atomic_unchecked_t fc_event_seq;
42755
42756 /**
42757 * fc_get_event_number - Obtain the next sequential FC event number
42758 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42759 u32
42760 fc_get_event_number(void)
42761 {
42762 - return atomic_add_return(1, &fc_event_seq);
42763 + return atomic_add_return_unchecked(1, &fc_event_seq);
42764 }
42765 EXPORT_SYMBOL(fc_get_event_number);
42766
42767 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42768 {
42769 int error;
42770
42771 - atomic_set(&fc_event_seq, 0);
42772 + atomic_set_unchecked(&fc_event_seq, 0);
42773
42774 error = transport_class_register(&fc_host_class);
42775 if (error)
42776 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42777 char *cp;
42778
42779 *val = simple_strtoul(buf, &cp, 0);
42780 - if ((*cp && (*cp != '\n')) || (*val < 0))
42781 + if (*cp && (*cp != '\n'))
42782 return -EINVAL;
42783 /*
42784 * Check for overflow; dev_loss_tmo is u32
42785 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42786 index 31969f2..2b348f0 100644
42787 --- a/drivers/scsi/scsi_transport_iscsi.c
42788 +++ b/drivers/scsi/scsi_transport_iscsi.c
42789 @@ -79,7 +79,7 @@ struct iscsi_internal {
42790 struct transport_container session_cont;
42791 };
42792
42793 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42794 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42795 static struct workqueue_struct *iscsi_eh_timer_workq;
42796
42797 static DEFINE_IDA(iscsi_sess_ida);
42798 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42799 int err;
42800
42801 ihost = shost->shost_data;
42802 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42803 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42804
42805 if (target_id == ISCSI_MAX_TARGET) {
42806 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42807 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42808 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42809 ISCSI_TRANSPORT_VERSION);
42810
42811 - atomic_set(&iscsi_session_nr, 0);
42812 + atomic_set_unchecked(&iscsi_session_nr, 0);
42813
42814 err = class_register(&iscsi_transport_class);
42815 if (err)
42816 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42817 index f379c7f..e8fc69c 100644
42818 --- a/drivers/scsi/scsi_transport_srp.c
42819 +++ b/drivers/scsi/scsi_transport_srp.c
42820 @@ -33,7 +33,7 @@
42821 #include "scsi_transport_srp_internal.h"
42822
42823 struct srp_host_attrs {
42824 - atomic_t next_port_id;
42825 + atomic_unchecked_t next_port_id;
42826 };
42827 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42828
42829 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42830 struct Scsi_Host *shost = dev_to_shost(dev);
42831 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42832
42833 - atomic_set(&srp_host->next_port_id, 0);
42834 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42835 return 0;
42836 }
42837
42838 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42839 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42840 rport->roles = ids->roles;
42841
42842 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42843 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42844 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42845
42846 transport_setup_device(&rport->dev);
42847 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42848 index 7992635..609faf8 100644
42849 --- a/drivers/scsi/sd.c
42850 +++ b/drivers/scsi/sd.c
42851 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42852 sdkp->disk = gd;
42853 sdkp->index = index;
42854 atomic_set(&sdkp->openers, 0);
42855 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42856 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42857
42858 if (!sdp->request_queue->rq_timeout) {
42859 if (sdp->type != TYPE_MOD)
42860 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42861 index be2c9a6..275525c 100644
42862 --- a/drivers/scsi/sg.c
42863 +++ b/drivers/scsi/sg.c
42864 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42865 sdp->disk->disk_name,
42866 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42867 NULL,
42868 - (char *)arg);
42869 + (char __user *)arg);
42870 case BLKTRACESTART:
42871 return blk_trace_startstop(sdp->device->request_queue, 1);
42872 case BLKTRACESTOP:
42873 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42874 index 19ee901..6e8c2ef 100644
42875 --- a/drivers/spi/spi.c
42876 +++ b/drivers/spi/spi.c
42877 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42878 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42879
42880 /* portable code must never pass more than 32 bytes */
42881 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42882 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42883
42884 static u8 *buf;
42885
42886 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42887 index c7a5f97..71ecd35 100644
42888 --- a/drivers/staging/iio/iio_hwmon.c
42889 +++ b/drivers/staging/iio/iio_hwmon.c
42890 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42891 static int iio_hwmon_probe(struct platform_device *pdev)
42892 {
42893 struct iio_hwmon_state *st;
42894 - struct sensor_device_attribute *a;
42895 + sensor_device_attribute_no_const *a;
42896 int ret, i;
42897 int in_i = 1, temp_i = 1, curr_i = 1;
42898 enum iio_chan_type type;
42899 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42900 index 34afc16..ffe44dd 100644
42901 --- a/drivers/staging/octeon/ethernet-rx.c
42902 +++ b/drivers/staging/octeon/ethernet-rx.c
42903 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42904 /* Increment RX stats for virtual ports */
42905 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42906 #ifdef CONFIG_64BIT
42907 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42908 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42909 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42910 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42911 #else
42912 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42913 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42914 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42915 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42916 #endif
42917 }
42918 netif_receive_skb(skb);
42919 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42920 dev->name);
42921 */
42922 #ifdef CONFIG_64BIT
42923 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42924 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42925 #else
42926 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42927 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42928 #endif
42929 dev_kfree_skb_irq(skb);
42930 }
42931 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42932 index ef32dc1..a159d68 100644
42933 --- a/drivers/staging/octeon/ethernet.c
42934 +++ b/drivers/staging/octeon/ethernet.c
42935 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42936 * since the RX tasklet also increments it.
42937 */
42938 #ifdef CONFIG_64BIT
42939 - atomic64_add(rx_status.dropped_packets,
42940 - (atomic64_t *)&priv->stats.rx_dropped);
42941 + atomic64_add_unchecked(rx_status.dropped_packets,
42942 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42943 #else
42944 - atomic_add(rx_status.dropped_packets,
42945 - (atomic_t *)&priv->stats.rx_dropped);
42946 + atomic_add_unchecked(rx_status.dropped_packets,
42947 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42948 #endif
42949 }
42950
42951 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42952 index a2b7e03..aaf3630 100644
42953 --- a/drivers/staging/ramster/tmem.c
42954 +++ b/drivers/staging/ramster/tmem.c
42955 @@ -50,25 +50,25 @@
42956 * A tmem host implementation must use this function to register callbacks
42957 * for memory allocation.
42958 */
42959 -static struct tmem_hostops tmem_hostops;
42960 +static struct tmem_hostops *tmem_hostops;
42961
42962 static void tmem_objnode_tree_init(void);
42963
42964 void tmem_register_hostops(struct tmem_hostops *m)
42965 {
42966 tmem_objnode_tree_init();
42967 - tmem_hostops = *m;
42968 + tmem_hostops = m;
42969 }
42970
42971 /*
42972 * A tmem host implementation must use this function to register
42973 * callbacks for a page-accessible memory (PAM) implementation.
42974 */
42975 -static struct tmem_pamops tmem_pamops;
42976 +static struct tmem_pamops *tmem_pamops;
42977
42978 void tmem_register_pamops(struct tmem_pamops *m)
42979 {
42980 - tmem_pamops = *m;
42981 + tmem_pamops = m;
42982 }
42983
42984 /*
42985 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42986 obj->pampd_count = 0;
42987 #ifdef CONFIG_RAMSTER
42988 if (tmem_pamops.new_obj != NULL)
42989 - (*tmem_pamops.new_obj)(obj);
42990 + (tmem_pamops->new_obj)(obj);
42991 #endif
42992 SET_SENTINEL(obj, OBJ);
42993
42994 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42995 rbnode = rb_next(rbnode);
42996 tmem_pampd_destroy_all_in_obj(obj, true);
42997 tmem_obj_free(obj, hb);
42998 - (*tmem_hostops.obj_free)(obj, pool);
42999 + (tmem_hostops->obj_free)(obj, pool);
43000 }
43001 spin_unlock(&hb->lock);
43002 }
43003 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
43004 ASSERT_SENTINEL(obj, OBJ);
43005 BUG_ON(obj->pool == NULL);
43006 ASSERT_SENTINEL(obj->pool, POOL);
43007 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
43008 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
43009 if (unlikely(objnode == NULL))
43010 goto out;
43011 objnode->obj = obj;
43012 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
43013 ASSERT_SENTINEL(pool, POOL);
43014 objnode->obj->objnode_count--;
43015 objnode->obj = NULL;
43016 - (*tmem_hostops.objnode_free)(objnode, pool);
43017 + (tmem_hostops->objnode_free)(objnode, pool);
43018 }
43019
43020 /*
43021 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
43022 void *old_pampd = *(void **)slot;
43023 *(void **)slot = new_pampd;
43024 if (!no_free)
43025 - (*tmem_pamops.free)(old_pampd, obj->pool,
43026 + (tmem_pamops->free)(old_pampd, obj->pool,
43027 NULL, 0, false);
43028 ret = new_pampd;
43029 }
43030 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
43031 if (objnode->slots[i]) {
43032 if (ht == 1) {
43033 obj->pampd_count--;
43034 - (*tmem_pamops.free)(objnode->slots[i],
43035 + (tmem_pamops->free)(objnode->slots[i],
43036 obj->pool, NULL, 0, true);
43037 objnode->slots[i] = NULL;
43038 continue;
43039 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43040 return;
43041 if (obj->objnode_tree_height == 0) {
43042 obj->pampd_count--;
43043 - (*tmem_pamops.free)(obj->objnode_tree_root,
43044 + (tmem_pamops->free)(obj->objnode_tree_root,
43045 obj->pool, NULL, 0, true);
43046 } else {
43047 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43048 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43049 obj->objnode_tree_root = NULL;
43050 #ifdef CONFIG_RAMSTER
43051 if (tmem_pamops.free_obj != NULL)
43052 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43053 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43054 #endif
43055 }
43056
43057 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43058 /* if found, is a dup put, flush the old one */
43059 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43060 BUG_ON(pampd_del != pampd);
43061 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43062 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43063 if (obj->pampd_count == 0) {
43064 objnew = obj;
43065 objfound = NULL;
43066 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43067 pampd = NULL;
43068 }
43069 } else {
43070 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43071 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43072 if (unlikely(obj == NULL)) {
43073 ret = -ENOMEM;
43074 goto out;
43075 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43076 if (unlikely(ret == -ENOMEM))
43077 /* may have partially built objnode tree ("stump") */
43078 goto delete_and_free;
43079 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43080 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43081 goto out;
43082
43083 delete_and_free:
43084 (void)tmem_pampd_delete_from_obj(obj, index);
43085 if (pampd)
43086 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43087 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43088 if (objnew) {
43089 tmem_obj_free(objnew, hb);
43090 - (*tmem_hostops.obj_free)(objnew, pool);
43091 + (tmem_hostops->obj_free)(objnew, pool);
43092 }
43093 out:
43094 spin_unlock(&hb->lock);
43095 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43096 if (pampd != NULL) {
43097 BUG_ON(obj == NULL);
43098 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43099 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43100 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43101 } else if (delete) {
43102 BUG_ON(obj == NULL);
43103 (void)tmem_pampd_delete_from_obj(obj, index);
43104 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43105 int ret = 0;
43106
43107 if (!is_ephemeral(pool))
43108 - new_pampd = (*tmem_pamops.repatriate_preload)(
43109 + new_pampd = (tmem_pamops->repatriate_preload)(
43110 old_pampd, pool, oidp, index, &intransit);
43111 if (intransit)
43112 ret = -EAGAIN;
43113 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43114 /* must release the hb->lock else repatriate can't sleep */
43115 spin_unlock(&hb->lock);
43116 if (!intransit)
43117 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43118 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43119 oidp, index, free, data);
43120 if (ret == -EAGAIN) {
43121 /* rare I think, but should cond_resched()??? */
43122 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43123 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43124 /* if we bug here, pamops wasn't properly set up for ramster */
43125 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43126 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43127 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43128 out:
43129 spin_unlock(&hb->lock);
43130 return ret;
43131 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43132 if (free) {
43133 if (obj->pampd_count == 0) {
43134 tmem_obj_free(obj, hb);
43135 - (*tmem_hostops.obj_free)(obj, pool);
43136 + (tmem_hostops->obj_free)(obj, pool);
43137 obj = NULL;
43138 }
43139 }
43140 if (free)
43141 - ret = (*tmem_pamops.get_data_and_free)(
43142 + ret = (tmem_pamops->get_data_and_free)(
43143 data, sizep, raw, pampd, pool, oidp, index);
43144 else
43145 - ret = (*tmem_pamops.get_data)(
43146 + ret = (tmem_pamops->get_data)(
43147 data, sizep, raw, pampd, pool, oidp, index);
43148 if (ret < 0)
43149 goto out;
43150 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43151 pampd = tmem_pampd_delete_from_obj(obj, index);
43152 if (pampd == NULL)
43153 goto out;
43154 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43155 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43156 if (obj->pampd_count == 0) {
43157 tmem_obj_free(obj, hb);
43158 - (*tmem_hostops.obj_free)(obj, pool);
43159 + (tmem_hostops->obj_free)(obj, pool);
43160 }
43161 ret = 0;
43162
43163 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43164 goto out;
43165 tmem_pampd_destroy_all_in_obj(obj, false);
43166 tmem_obj_free(obj, hb);
43167 - (*tmem_hostops.obj_free)(obj, pool);
43168 + (tmem_hostops->obj_free)(obj, pool);
43169 ret = 0;
43170
43171 out:
43172 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43173 index dc23395..cf7e9b1 100644
43174 --- a/drivers/staging/rtl8712/rtl871x_io.h
43175 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43176 @@ -108,7 +108,7 @@ struct _io_ops {
43177 u8 *pmem);
43178 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43179 u8 *pmem);
43180 -};
43181 +} __no_const;
43182
43183 struct io_req {
43184 struct list_head list;
43185 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43186 index 1f5088b..0e59820 100644
43187 --- a/drivers/staging/sbe-2t3e3/netdev.c
43188 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43189 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43190 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43191
43192 if (rlen)
43193 - if (copy_to_user(data, &resp, rlen))
43194 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43195 return -EFAULT;
43196
43197 return 0;
43198 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43199 index 5dddc4d..34fcb2f 100644
43200 --- a/drivers/staging/usbip/vhci.h
43201 +++ b/drivers/staging/usbip/vhci.h
43202 @@ -83,7 +83,7 @@ struct vhci_hcd {
43203 unsigned resuming:1;
43204 unsigned long re_timeout;
43205
43206 - atomic_t seqnum;
43207 + atomic_unchecked_t seqnum;
43208
43209 /*
43210 * NOTE:
43211 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43212 index c3aa219..bf8b3de 100644
43213 --- a/drivers/staging/usbip/vhci_hcd.c
43214 +++ b/drivers/staging/usbip/vhci_hcd.c
43215 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43216 return;
43217 }
43218
43219 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43220 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43221 if (priv->seqnum == 0xffff)
43222 dev_info(&urb->dev->dev, "seqnum max\n");
43223
43224 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43225 return -ENOMEM;
43226 }
43227
43228 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43229 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43230 if (unlink->seqnum == 0xffff)
43231 pr_info("seqnum max\n");
43232
43233 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43234 vdev->rhport = rhport;
43235 }
43236
43237 - atomic_set(&vhci->seqnum, 0);
43238 + atomic_set_unchecked(&vhci->seqnum, 0);
43239 spin_lock_init(&vhci->lock);
43240
43241 hcd->power_budget = 0; /* no limit */
43242 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43243 index ba5f1c0..11d8122 100644
43244 --- a/drivers/staging/usbip/vhci_rx.c
43245 +++ b/drivers/staging/usbip/vhci_rx.c
43246 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43247 if (!urb) {
43248 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43249 pr_info("max seqnum %d\n",
43250 - atomic_read(&the_controller->seqnum));
43251 + atomic_read_unchecked(&the_controller->seqnum));
43252 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43253 return;
43254 }
43255 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43256 index 5f13890..36a044b 100644
43257 --- a/drivers/staging/vt6655/hostap.c
43258 +++ b/drivers/staging/vt6655/hostap.c
43259 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43260 *
43261 */
43262
43263 +static net_device_ops_no_const apdev_netdev_ops;
43264 +
43265 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43266 {
43267 PSDevice apdev_priv;
43268 struct net_device *dev = pDevice->dev;
43269 int ret;
43270 - const struct net_device_ops apdev_netdev_ops = {
43271 - .ndo_start_xmit = pDevice->tx_80211,
43272 - };
43273
43274 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43275
43276 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43277 *apdev_priv = *pDevice;
43278 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43279
43280 + /* only half broken now */
43281 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43282 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43283
43284 pDevice->apdev->type = ARPHRD_IEEE80211;
43285 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43286 index 26a7d0e..897b083 100644
43287 --- a/drivers/staging/vt6656/hostap.c
43288 +++ b/drivers/staging/vt6656/hostap.c
43289 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43290 *
43291 */
43292
43293 +static net_device_ops_no_const apdev_netdev_ops;
43294 +
43295 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43296 {
43297 PSDevice apdev_priv;
43298 struct net_device *dev = pDevice->dev;
43299 int ret;
43300 - const struct net_device_ops apdev_netdev_ops = {
43301 - .ndo_start_xmit = pDevice->tx_80211,
43302 - };
43303
43304 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43305
43306 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43307 *apdev_priv = *pDevice;
43308 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43309
43310 + /* only half broken now */
43311 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43312 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43313
43314 pDevice->apdev->type = ARPHRD_IEEE80211;
43315 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43316 index 56c8e60..1920c63 100644
43317 --- a/drivers/staging/zcache/tmem.c
43318 +++ b/drivers/staging/zcache/tmem.c
43319 @@ -39,7 +39,7 @@
43320 * A tmem host implementation must use this function to register callbacks
43321 * for memory allocation.
43322 */
43323 -static struct tmem_hostops tmem_hostops;
43324 +static tmem_hostops_no_const tmem_hostops;
43325
43326 static void tmem_objnode_tree_init(void);
43327
43328 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43329 * A tmem host implementation must use this function to register
43330 * callbacks for a page-accessible memory (PAM) implementation
43331 */
43332 -static struct tmem_pamops tmem_pamops;
43333 +static tmem_pamops_no_const tmem_pamops;
43334
43335 void tmem_register_pamops(struct tmem_pamops *m)
43336 {
43337 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43338 index 0d4aa82..f7832d4 100644
43339 --- a/drivers/staging/zcache/tmem.h
43340 +++ b/drivers/staging/zcache/tmem.h
43341 @@ -180,6 +180,7 @@ struct tmem_pamops {
43342 void (*new_obj)(struct tmem_obj *);
43343 int (*replace_in_obj)(void *, struct tmem_obj *);
43344 };
43345 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43346 extern void tmem_register_pamops(struct tmem_pamops *m);
43347
43348 /* memory allocation methods provided by the host implementation */
43349 @@ -189,6 +190,7 @@ struct tmem_hostops {
43350 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43351 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43352 };
43353 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43354 extern void tmem_register_hostops(struct tmem_hostops *m);
43355
43356 /* core tmem accessor functions */
43357 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43358 index 96f4981..4daaa7e 100644
43359 --- a/drivers/target/target_core_device.c
43360 +++ b/drivers/target/target_core_device.c
43361 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43362 spin_lock_init(&dev->se_port_lock);
43363 spin_lock_init(&dev->se_tmr_lock);
43364 spin_lock_init(&dev->qf_cmd_lock);
43365 - atomic_set(&dev->dev_ordered_id, 0);
43366 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43367 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43368 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43369 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43370 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43371 index fcf880f..a4d1e8f 100644
43372 --- a/drivers/target/target_core_transport.c
43373 +++ b/drivers/target/target_core_transport.c
43374 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43375 * Used to determine when ORDERED commands should go from
43376 * Dormant to Active status.
43377 */
43378 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43379 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43380 smp_mb__after_atomic_inc();
43381 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43382 cmd->se_ordered_id, cmd->sam_task_attr,
43383 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43384 index b09c8d1f..c4225c0 100644
43385 --- a/drivers/tty/cyclades.c
43386 +++ b/drivers/tty/cyclades.c
43387 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43388 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43389 info->port.count);
43390 #endif
43391 - info->port.count++;
43392 + atomic_inc(&info->port.count);
43393 #ifdef CY_DEBUG_COUNT
43394 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43395 - current->pid, info->port.count);
43396 + current->pid, atomic_read(&info->port.count));
43397 #endif
43398
43399 /*
43400 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43401 for (j = 0; j < cy_card[i].nports; j++) {
43402 info = &cy_card[i].ports[j];
43403
43404 - if (info->port.count) {
43405 + if (atomic_read(&info->port.count)) {
43406 /* XXX is the ldisc num worth this? */
43407 struct tty_struct *tty;
43408 struct tty_ldisc *ld;
43409 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43410 index 13ee53b..418d164 100644
43411 --- a/drivers/tty/hvc/hvc_console.c
43412 +++ b/drivers/tty/hvc/hvc_console.c
43413 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43414
43415 spin_lock_irqsave(&hp->port.lock, flags);
43416 /* Check and then increment for fast path open. */
43417 - if (hp->port.count++ > 0) {
43418 + if (atomic_inc_return(&hp->port.count) > 1) {
43419 spin_unlock_irqrestore(&hp->port.lock, flags);
43420 hvc_kick();
43421 return 0;
43422 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43423
43424 spin_lock_irqsave(&hp->port.lock, flags);
43425
43426 - if (--hp->port.count == 0) {
43427 + if (atomic_dec_return(&hp->port.count) == 0) {
43428 spin_unlock_irqrestore(&hp->port.lock, flags);
43429 /* We are done with the tty pointer now. */
43430 tty_port_tty_set(&hp->port, NULL);
43431 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43432 */
43433 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43434 } else {
43435 - if (hp->port.count < 0)
43436 + if (atomic_read(&hp->port.count) < 0)
43437 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43438 - hp->vtermno, hp->port.count);
43439 + hp->vtermno, atomic_read(&hp->port.count));
43440 spin_unlock_irqrestore(&hp->port.lock, flags);
43441 }
43442 }
43443 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43444 * open->hangup case this can be called after the final close so prevent
43445 * that from happening for now.
43446 */
43447 - if (hp->port.count <= 0) {
43448 + if (atomic_read(&hp->port.count) <= 0) {
43449 spin_unlock_irqrestore(&hp->port.lock, flags);
43450 return;
43451 }
43452
43453 - hp->port.count = 0;
43454 + atomic_set(&hp->port.count, 0);
43455 spin_unlock_irqrestore(&hp->port.lock, flags);
43456 tty_port_tty_set(&hp->port, NULL);
43457
43458 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43459 return -EPIPE;
43460
43461 /* FIXME what's this (unprotected) check for? */
43462 - if (hp->port.count <= 0)
43463 + if (atomic_read(&hp->port.count) <= 0)
43464 return -EIO;
43465
43466 spin_lock_irqsave(&hp->lock, flags);
43467 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43468 index 8776357..b2d4afd 100644
43469 --- a/drivers/tty/hvc/hvcs.c
43470 +++ b/drivers/tty/hvc/hvcs.c
43471 @@ -83,6 +83,7 @@
43472 #include <asm/hvcserver.h>
43473 #include <asm/uaccess.h>
43474 #include <asm/vio.h>
43475 +#include <asm/local.h>
43476
43477 /*
43478 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43479 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43480
43481 spin_lock_irqsave(&hvcsd->lock, flags);
43482
43483 - if (hvcsd->port.count > 0) {
43484 + if (atomic_read(&hvcsd->port.count) > 0) {
43485 spin_unlock_irqrestore(&hvcsd->lock, flags);
43486 printk(KERN_INFO "HVCS: vterm state unchanged. "
43487 "The hvcs device node is still in use.\n");
43488 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43489 }
43490 }
43491
43492 - hvcsd->port.count = 0;
43493 + atomic_set(&hvcsd->port.count, 0);
43494 hvcsd->port.tty = tty;
43495 tty->driver_data = hvcsd;
43496
43497 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43498 unsigned long flags;
43499
43500 spin_lock_irqsave(&hvcsd->lock, flags);
43501 - hvcsd->port.count++;
43502 + atomic_inc(&hvcsd->port.count);
43503 hvcsd->todo_mask |= HVCS_SCHED_READ;
43504 spin_unlock_irqrestore(&hvcsd->lock, flags);
43505
43506 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43507 hvcsd = tty->driver_data;
43508
43509 spin_lock_irqsave(&hvcsd->lock, flags);
43510 - if (--hvcsd->port.count == 0) {
43511 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43512
43513 vio_disable_interrupts(hvcsd->vdev);
43514
43515 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43516
43517 free_irq(irq, hvcsd);
43518 return;
43519 - } else if (hvcsd->port.count < 0) {
43520 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43521 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43522 " is missmanaged.\n",
43523 - hvcsd->vdev->unit_address, hvcsd->port.count);
43524 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43525 }
43526
43527 spin_unlock_irqrestore(&hvcsd->lock, flags);
43528 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43529
43530 spin_lock_irqsave(&hvcsd->lock, flags);
43531 /* Preserve this so that we know how many kref refs to put */
43532 - temp_open_count = hvcsd->port.count;
43533 + temp_open_count = atomic_read(&hvcsd->port.count);
43534
43535 /*
43536 * Don't kref put inside the spinlock because the destruction
43537 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43538 tty->driver_data = NULL;
43539 hvcsd->port.tty = NULL;
43540
43541 - hvcsd->port.count = 0;
43542 + atomic_set(&hvcsd->port.count, 0);
43543
43544 /* This will drop any buffered data on the floor which is OK in a hangup
43545 * scenario. */
43546 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43547 * the middle of a write operation? This is a crummy place to do this
43548 * but we want to keep it all in the spinlock.
43549 */
43550 - if (hvcsd->port.count <= 0) {
43551 + if (atomic_read(&hvcsd->port.count) <= 0) {
43552 spin_unlock_irqrestore(&hvcsd->lock, flags);
43553 return -ENODEV;
43554 }
43555 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43556 {
43557 struct hvcs_struct *hvcsd = tty->driver_data;
43558
43559 - if (!hvcsd || hvcsd->port.count <= 0)
43560 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43561 return 0;
43562
43563 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43564 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43565 index 2cde13d..645d78f 100644
43566 --- a/drivers/tty/ipwireless/tty.c
43567 +++ b/drivers/tty/ipwireless/tty.c
43568 @@ -29,6 +29,7 @@
43569 #include <linux/tty_driver.h>
43570 #include <linux/tty_flip.h>
43571 #include <linux/uaccess.h>
43572 +#include <asm/local.h>
43573
43574 #include "tty.h"
43575 #include "network.h"
43576 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43577 mutex_unlock(&tty->ipw_tty_mutex);
43578 return -ENODEV;
43579 }
43580 - if (tty->port.count == 0)
43581 + if (atomic_read(&tty->port.count) == 0)
43582 tty->tx_bytes_queued = 0;
43583
43584 - tty->port.count++;
43585 + atomic_inc(&tty->port.count);
43586
43587 tty->port.tty = linux_tty;
43588 linux_tty->driver_data = tty;
43589 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43590
43591 static void do_ipw_close(struct ipw_tty *tty)
43592 {
43593 - tty->port.count--;
43594 -
43595 - if (tty->port.count == 0) {
43596 + if (atomic_dec_return(&tty->port.count) == 0) {
43597 struct tty_struct *linux_tty = tty->port.tty;
43598
43599 if (linux_tty != NULL) {
43600 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43601 return;
43602
43603 mutex_lock(&tty->ipw_tty_mutex);
43604 - if (tty->port.count == 0) {
43605 + if (atomic_read(&tty->port.count) == 0) {
43606 mutex_unlock(&tty->ipw_tty_mutex);
43607 return;
43608 }
43609 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43610 return;
43611 }
43612
43613 - if (!tty->port.count) {
43614 + if (!atomic_read(&tty->port.count)) {
43615 mutex_unlock(&tty->ipw_tty_mutex);
43616 return;
43617 }
43618 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43619 return -ENODEV;
43620
43621 mutex_lock(&tty->ipw_tty_mutex);
43622 - if (!tty->port.count) {
43623 + if (!atomic_read(&tty->port.count)) {
43624 mutex_unlock(&tty->ipw_tty_mutex);
43625 return -EINVAL;
43626 }
43627 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43628 if (!tty)
43629 return -ENODEV;
43630
43631 - if (!tty->port.count)
43632 + if (!atomic_read(&tty->port.count))
43633 return -EINVAL;
43634
43635 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43636 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43637 if (!tty)
43638 return 0;
43639
43640 - if (!tty->port.count)
43641 + if (!atomic_read(&tty->port.count))
43642 return 0;
43643
43644 return tty->tx_bytes_queued;
43645 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43646 if (!tty)
43647 return -ENODEV;
43648
43649 - if (!tty->port.count)
43650 + if (!atomic_read(&tty->port.count))
43651 return -EINVAL;
43652
43653 return get_control_lines(tty);
43654 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43655 if (!tty)
43656 return -ENODEV;
43657
43658 - if (!tty->port.count)
43659 + if (!atomic_read(&tty->port.count))
43660 return -EINVAL;
43661
43662 return set_control_lines(tty, set, clear);
43663 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43664 if (!tty)
43665 return -ENODEV;
43666
43667 - if (!tty->port.count)
43668 + if (!atomic_read(&tty->port.count))
43669 return -EINVAL;
43670
43671 /* FIXME: Exactly how is the tty object locked here .. */
43672 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43673 * are gone */
43674 mutex_lock(&ttyj->ipw_tty_mutex);
43675 }
43676 - while (ttyj->port.count)
43677 + while (atomic_read(&ttyj->port.count))
43678 do_ipw_close(ttyj);
43679 ipwireless_disassociate_network_ttys(network,
43680 ttyj->channel_idx);
43681 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43682 index f9d2850..b006f04 100644
43683 --- a/drivers/tty/moxa.c
43684 +++ b/drivers/tty/moxa.c
43685 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43686 }
43687
43688 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43689 - ch->port.count++;
43690 + atomic_inc(&ch->port.count);
43691 tty->driver_data = ch;
43692 tty_port_tty_set(&ch->port, tty);
43693 mutex_lock(&ch->port.mutex);
43694 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43695 index bfd6771..e0d93c4 100644
43696 --- a/drivers/tty/n_gsm.c
43697 +++ b/drivers/tty/n_gsm.c
43698 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43699 spin_lock_init(&dlci->lock);
43700 mutex_init(&dlci->mutex);
43701 dlci->fifo = &dlci->_fifo;
43702 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43703 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43704 kfree(dlci);
43705 return NULL;
43706 }
43707 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43708 struct gsm_dlci *dlci = tty->driver_data;
43709 struct tty_port *port = &dlci->port;
43710
43711 - port->count++;
43712 + atomic_inc(&port->count);
43713 dlci_get(dlci);
43714 dlci_get(dlci->gsm->dlci[0]);
43715 mux_get(dlci->gsm);
43716 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43717 index 19083ef..6e34e97 100644
43718 --- a/drivers/tty/n_tty.c
43719 +++ b/drivers/tty/n_tty.c
43720 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43721 {
43722 *ops = tty_ldisc_N_TTY;
43723 ops->owner = NULL;
43724 - ops->refcount = ops->flags = 0;
43725 + atomic_set(&ops->refcount, 0);
43726 + ops->flags = 0;
43727 }
43728 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43729 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43730 index c830b60..b239698 100644
43731 --- a/drivers/tty/pty.c
43732 +++ b/drivers/tty/pty.c
43733 @@ -793,8 +793,10 @@ static void __init unix98_pty_init(void)
43734 panic("Couldn't register Unix98 pts driver");
43735
43736 /* Now create the /dev/ptmx special device */
43737 + pax_open_kernel();
43738 tty_default_fops(&ptmx_fops);
43739 - ptmx_fops.open = ptmx_open;
43740 + *(void **)&ptmx_fops.open = ptmx_open;
43741 + pax_close_kernel();
43742
43743 cdev_init(&ptmx_cdev, &ptmx_fops);
43744 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43745 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43746 index e42009a..566a036 100644
43747 --- a/drivers/tty/rocket.c
43748 +++ b/drivers/tty/rocket.c
43749 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43750 tty->driver_data = info;
43751 tty_port_tty_set(port, tty);
43752
43753 - if (port->count++ == 0) {
43754 + if (atomic_inc_return(&port->count) == 1) {
43755 atomic_inc(&rp_num_ports_open);
43756
43757 #ifdef ROCKET_DEBUG_OPEN
43758 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43759 #endif
43760 }
43761 #ifdef ROCKET_DEBUG_OPEN
43762 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43763 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43764 #endif
43765
43766 /*
43767 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43768 spin_unlock_irqrestore(&info->port.lock, flags);
43769 return;
43770 }
43771 - if (info->port.count)
43772 + if (atomic_read(&info->port.count))
43773 atomic_dec(&rp_num_ports_open);
43774 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43775 spin_unlock_irqrestore(&info->port.lock, flags);
43776 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43777 index 1002054..dd644a8 100644
43778 --- a/drivers/tty/serial/kgdboc.c
43779 +++ b/drivers/tty/serial/kgdboc.c
43780 @@ -24,8 +24,9 @@
43781 #define MAX_CONFIG_LEN 40
43782
43783 static struct kgdb_io kgdboc_io_ops;
43784 +static struct kgdb_io kgdboc_io_ops_console;
43785
43786 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43787 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43788 static int configured = -1;
43789
43790 static char config[MAX_CONFIG_LEN];
43791 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43792 kgdboc_unregister_kbd();
43793 if (configured == 1)
43794 kgdb_unregister_io_module(&kgdboc_io_ops);
43795 + else if (configured == 2)
43796 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43797 }
43798
43799 static int configure_kgdboc(void)
43800 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43801 int err;
43802 char *cptr = config;
43803 struct console *cons;
43804 + int is_console = 0;
43805
43806 err = kgdboc_option_setup(config);
43807 if (err || !strlen(config) || isspace(config[0]))
43808 goto noconfig;
43809
43810 err = -ENODEV;
43811 - kgdboc_io_ops.is_console = 0;
43812 kgdb_tty_driver = NULL;
43813
43814 kgdboc_use_kms = 0;
43815 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43816 int idx;
43817 if (cons->device && cons->device(cons, &idx) == p &&
43818 idx == tty_line) {
43819 - kgdboc_io_ops.is_console = 1;
43820 + is_console = 1;
43821 break;
43822 }
43823 cons = cons->next;
43824 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43825 kgdb_tty_line = tty_line;
43826
43827 do_register:
43828 - err = kgdb_register_io_module(&kgdboc_io_ops);
43829 + if (is_console) {
43830 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43831 + configured = 2;
43832 + } else {
43833 + err = kgdb_register_io_module(&kgdboc_io_ops);
43834 + configured = 1;
43835 + }
43836 if (err)
43837 goto noconfig;
43838
43839 @@ -205,8 +214,6 @@ do_register:
43840 if (err)
43841 goto nmi_con_failed;
43842
43843 - configured = 1;
43844 -
43845 return 0;
43846
43847 nmi_con_failed:
43848 @@ -223,7 +230,7 @@ noconfig:
43849 static int __init init_kgdboc(void)
43850 {
43851 /* Already configured? */
43852 - if (configured == 1)
43853 + if (configured >= 1)
43854 return 0;
43855
43856 return configure_kgdboc();
43857 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43858 if (config[len - 1] == '\n')
43859 config[len - 1] = '\0';
43860
43861 - if (configured == 1)
43862 + if (configured >= 1)
43863 cleanup_kgdboc();
43864
43865 /* Go and configure with the new params. */
43866 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43867 .post_exception = kgdboc_post_exp_handler,
43868 };
43869
43870 +static struct kgdb_io kgdboc_io_ops_console = {
43871 + .name = "kgdboc",
43872 + .read_char = kgdboc_get_char,
43873 + .write_char = kgdboc_put_char,
43874 + .pre_exception = kgdboc_pre_exp_handler,
43875 + .post_exception = kgdboc_post_exp_handler,
43876 + .is_console = 1
43877 +};
43878 +
43879 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43880 /* This is only available if kgdboc is a built in for early debugging */
43881 static int __init kgdboc_early_init(char *opt)
43882 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43883 index e514b3a..c73d614 100644
43884 --- a/drivers/tty/serial/samsung.c
43885 +++ b/drivers/tty/serial/samsung.c
43886 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43887 }
43888 }
43889
43890 +static int s3c64xx_serial_startup(struct uart_port *port);
43891 static int s3c24xx_serial_startup(struct uart_port *port)
43892 {
43893 struct s3c24xx_uart_port *ourport = to_ourport(port);
43894 int ret;
43895
43896 + /* Startup sequence is different for s3c64xx and higher SoC's */
43897 + if (s3c24xx_serial_has_interrupt_mask(port))
43898 + return s3c64xx_serial_startup(port);
43899 +
43900 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43901 port->mapbase, port->membase);
43902
43903 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43904 /* setup info for port */
43905 port->dev = &platdev->dev;
43906
43907 - /* Startup sequence is different for s3c64xx and higher SoC's */
43908 - if (s3c24xx_serial_has_interrupt_mask(port))
43909 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43910 -
43911 port->uartclk = 1;
43912
43913 if (cfg->uart_flags & UPF_CONS_FLOW) {
43914 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43915 index 4293a3e..7227e42 100644
43916 --- a/drivers/tty/serial/serial_core.c
43917 +++ b/drivers/tty/serial/serial_core.c
43918 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43919 uart_flush_buffer(tty);
43920 uart_shutdown(tty, state);
43921 spin_lock_irqsave(&port->lock, flags);
43922 - port->count = 0;
43923 + atomic_set(&port->count, 0);
43924 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43925 spin_unlock_irqrestore(&port->lock, flags);
43926 tty_port_tty_set(port, NULL);
43927 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43928 goto end;
43929 }
43930
43931 - port->count++;
43932 + atomic_inc(&port->count);
43933 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43934 retval = -ENXIO;
43935 goto err_dec_count;
43936 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43937 /*
43938 * Make sure the device is in D0 state.
43939 */
43940 - if (port->count == 1)
43941 + if (atomic_read(&port->count) == 1)
43942 uart_change_pm(state, 0);
43943
43944 /*
43945 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43946 end:
43947 return retval;
43948 err_dec_count:
43949 - port->count--;
43950 + atomic_inc(&port->count);
43951 mutex_unlock(&port->mutex);
43952 goto end;
43953 }
43954 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43955 index 9e071f6..f30ae69 100644
43956 --- a/drivers/tty/synclink.c
43957 +++ b/drivers/tty/synclink.c
43958 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43959
43960 if (debug_level >= DEBUG_LEVEL_INFO)
43961 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43962 - __FILE__,__LINE__, info->device_name, info->port.count);
43963 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43964
43965 if (tty_port_close_start(&info->port, tty, filp) == 0)
43966 goto cleanup;
43967 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43968 cleanup:
43969 if (debug_level >= DEBUG_LEVEL_INFO)
43970 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43971 - tty->driver->name, info->port.count);
43972 + tty->driver->name, atomic_read(&info->port.count));
43973
43974 } /* end of mgsl_close() */
43975
43976 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43977
43978 mgsl_flush_buffer(tty);
43979 shutdown(info);
43980 -
43981 - info->port.count = 0;
43982 +
43983 + atomic_set(&info->port.count, 0);
43984 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43985 info->port.tty = NULL;
43986
43987 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43988
43989 if (debug_level >= DEBUG_LEVEL_INFO)
43990 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43991 - __FILE__,__LINE__, tty->driver->name, port->count );
43992 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43993
43994 spin_lock_irqsave(&info->irq_spinlock, flags);
43995 if (!tty_hung_up_p(filp)) {
43996 extra_count = true;
43997 - port->count--;
43998 + atomic_dec(&port->count);
43999 }
44000 spin_unlock_irqrestore(&info->irq_spinlock, flags);
44001 port->blocked_open++;
44002 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44003
44004 if (debug_level >= DEBUG_LEVEL_INFO)
44005 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
44006 - __FILE__,__LINE__, tty->driver->name, port->count );
44007 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44008
44009 tty_unlock(tty);
44010 schedule();
44011 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
44012
44013 /* FIXME: Racy on hangup during close wait */
44014 if (extra_count)
44015 - port->count++;
44016 + atomic_inc(&port->count);
44017 port->blocked_open--;
44018
44019 if (debug_level >= DEBUG_LEVEL_INFO)
44020 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
44021 - __FILE__,__LINE__, tty->driver->name, port->count );
44022 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44023
44024 if (!retval)
44025 port->flags |= ASYNC_NORMAL_ACTIVE;
44026 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44027
44028 if (debug_level >= DEBUG_LEVEL_INFO)
44029 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44030 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44031 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44032
44033 /* If port is closing, signal caller to try again */
44034 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44035 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44036 spin_unlock_irqrestore(&info->netlock, flags);
44037 goto cleanup;
44038 }
44039 - info->port.count++;
44040 + atomic_inc(&info->port.count);
44041 spin_unlock_irqrestore(&info->netlock, flags);
44042
44043 - if (info->port.count == 1) {
44044 + if (atomic_read(&info->port.count) == 1) {
44045 /* 1st open on this device, init hardware */
44046 retval = startup(info);
44047 if (retval < 0)
44048 @@ -3451,8 +3451,8 @@ cleanup:
44049 if (retval) {
44050 if (tty->count == 1)
44051 info->port.tty = NULL; /* tty layer will release tty struct */
44052 - if(info->port.count)
44053 - info->port.count--;
44054 + if (atomic_read(&info->port.count))
44055 + atomic_dec(&info->port.count);
44056 }
44057
44058 return retval;
44059 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44060 unsigned short new_crctype;
44061
44062 /* return error if TTY interface open */
44063 - if (info->port.count)
44064 + if (atomic_read(&info->port.count))
44065 return -EBUSY;
44066
44067 switch (encoding)
44068 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44069
44070 /* arbitrate between network and tty opens */
44071 spin_lock_irqsave(&info->netlock, flags);
44072 - if (info->port.count != 0 || info->netcount != 0) {
44073 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44074 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44075 spin_unlock_irqrestore(&info->netlock, flags);
44076 return -EBUSY;
44077 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44078 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44079
44080 /* return error if TTY interface open */
44081 - if (info->port.count)
44082 + if (atomic_read(&info->port.count))
44083 return -EBUSY;
44084
44085 if (cmd != SIOCWANDEV)
44086 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44087 index aba1e59..877ac33 100644
44088 --- a/drivers/tty/synclink_gt.c
44089 +++ b/drivers/tty/synclink_gt.c
44090 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44091 tty->driver_data = info;
44092 info->port.tty = tty;
44093
44094 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44095 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44096
44097 /* If port is closing, signal caller to try again */
44098 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44099 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44100 mutex_unlock(&info->port.mutex);
44101 goto cleanup;
44102 }
44103 - info->port.count++;
44104 + atomic_inc(&info->port.count);
44105 spin_unlock_irqrestore(&info->netlock, flags);
44106
44107 - if (info->port.count == 1) {
44108 + if (atomic_read(&info->port.count) == 1) {
44109 /* 1st open on this device, init hardware */
44110 retval = startup(info);
44111 if (retval < 0) {
44112 @@ -716,8 +716,8 @@ cleanup:
44113 if (retval) {
44114 if (tty->count == 1)
44115 info->port.tty = NULL; /* tty layer will release tty struct */
44116 - if(info->port.count)
44117 - info->port.count--;
44118 + if(atomic_read(&info->port.count))
44119 + atomic_dec(&info->port.count);
44120 }
44121
44122 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44123 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44124
44125 if (sanity_check(info, tty->name, "close"))
44126 return;
44127 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44128 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44129
44130 if (tty_port_close_start(&info->port, tty, filp) == 0)
44131 goto cleanup;
44132 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44133 tty_port_close_end(&info->port, tty);
44134 info->port.tty = NULL;
44135 cleanup:
44136 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44137 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44138 }
44139
44140 static void hangup(struct tty_struct *tty)
44141 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44142 shutdown(info);
44143
44144 spin_lock_irqsave(&info->port.lock, flags);
44145 - info->port.count = 0;
44146 + atomic_set(&info->port.count, 0);
44147 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44148 info->port.tty = NULL;
44149 spin_unlock_irqrestore(&info->port.lock, flags);
44150 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44151 unsigned short new_crctype;
44152
44153 /* return error if TTY interface open */
44154 - if (info->port.count)
44155 + if (atomic_read(&info->port.count))
44156 return -EBUSY;
44157
44158 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44159 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44160
44161 /* arbitrate between network and tty opens */
44162 spin_lock_irqsave(&info->netlock, flags);
44163 - if (info->port.count != 0 || info->netcount != 0) {
44164 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44165 DBGINFO(("%s hdlc_open busy\n", dev->name));
44166 spin_unlock_irqrestore(&info->netlock, flags);
44167 return -EBUSY;
44168 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44169 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44170
44171 /* return error if TTY interface open */
44172 - if (info->port.count)
44173 + if (atomic_read(&info->port.count))
44174 return -EBUSY;
44175
44176 if (cmd != SIOCWANDEV)
44177 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44178 if (port == NULL)
44179 continue;
44180 spin_lock(&port->lock);
44181 - if ((port->port.count || port->netcount) &&
44182 + if ((atomic_read(&port->port.count) || port->netcount) &&
44183 port->pending_bh && !port->bh_running &&
44184 !port->bh_requested) {
44185 DBGISR(("%s bh queued\n", port->device_name));
44186 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44187 spin_lock_irqsave(&info->lock, flags);
44188 if (!tty_hung_up_p(filp)) {
44189 extra_count = true;
44190 - port->count--;
44191 + atomic_dec(&port->count);
44192 }
44193 spin_unlock_irqrestore(&info->lock, flags);
44194 port->blocked_open++;
44195 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44196 remove_wait_queue(&port->open_wait, &wait);
44197
44198 if (extra_count)
44199 - port->count++;
44200 + atomic_inc(&port->count);
44201 port->blocked_open--;
44202
44203 if (!retval)
44204 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44205 index fd43fb6..34704ad 100644
44206 --- a/drivers/tty/synclinkmp.c
44207 +++ b/drivers/tty/synclinkmp.c
44208 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44209
44210 if (debug_level >= DEBUG_LEVEL_INFO)
44211 printk("%s(%d):%s open(), old ref count = %d\n",
44212 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44213 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44214
44215 /* If port is closing, signal caller to try again */
44216 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44217 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44218 spin_unlock_irqrestore(&info->netlock, flags);
44219 goto cleanup;
44220 }
44221 - info->port.count++;
44222 + atomic_inc(&info->port.count);
44223 spin_unlock_irqrestore(&info->netlock, flags);
44224
44225 - if (info->port.count == 1) {
44226 + if (atomic_read(&info->port.count) == 1) {
44227 /* 1st open on this device, init hardware */
44228 retval = startup(info);
44229 if (retval < 0)
44230 @@ -797,8 +797,8 @@ cleanup:
44231 if (retval) {
44232 if (tty->count == 1)
44233 info->port.tty = NULL; /* tty layer will release tty struct */
44234 - if(info->port.count)
44235 - info->port.count--;
44236 + if(atomic_read(&info->port.count))
44237 + atomic_dec(&info->port.count);
44238 }
44239
44240 return retval;
44241 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44242
44243 if (debug_level >= DEBUG_LEVEL_INFO)
44244 printk("%s(%d):%s close() entry, count=%d\n",
44245 - __FILE__,__LINE__, info->device_name, info->port.count);
44246 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44247
44248 if (tty_port_close_start(&info->port, tty, filp) == 0)
44249 goto cleanup;
44250 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44251 cleanup:
44252 if (debug_level >= DEBUG_LEVEL_INFO)
44253 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44254 - tty->driver->name, info->port.count);
44255 + tty->driver->name, atomic_read(&info->port.count));
44256 }
44257
44258 /* Called by tty_hangup() when a hangup is signaled.
44259 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44260 shutdown(info);
44261
44262 spin_lock_irqsave(&info->port.lock, flags);
44263 - info->port.count = 0;
44264 + atomic_set(&info->port.count, 0);
44265 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44266 info->port.tty = NULL;
44267 spin_unlock_irqrestore(&info->port.lock, flags);
44268 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44269 unsigned short new_crctype;
44270
44271 /* return error if TTY interface open */
44272 - if (info->port.count)
44273 + if (atomic_read(&info->port.count))
44274 return -EBUSY;
44275
44276 switch (encoding)
44277 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44278
44279 /* arbitrate between network and tty opens */
44280 spin_lock_irqsave(&info->netlock, flags);
44281 - if (info->port.count != 0 || info->netcount != 0) {
44282 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44283 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44284 spin_unlock_irqrestore(&info->netlock, flags);
44285 return -EBUSY;
44286 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44287 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44288
44289 /* return error if TTY interface open */
44290 - if (info->port.count)
44291 + if (atomic_read(&info->port.count))
44292 return -EBUSY;
44293
44294 if (cmd != SIOCWANDEV)
44295 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44296 * do not request bottom half processing if the
44297 * device is not open in a normal mode.
44298 */
44299 - if ( port && (port->port.count || port->netcount) &&
44300 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44301 port->pending_bh && !port->bh_running &&
44302 !port->bh_requested ) {
44303 if ( debug_level >= DEBUG_LEVEL_ISR )
44304 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44305
44306 if (debug_level >= DEBUG_LEVEL_INFO)
44307 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44308 - __FILE__,__LINE__, tty->driver->name, port->count );
44309 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44310
44311 spin_lock_irqsave(&info->lock, flags);
44312 if (!tty_hung_up_p(filp)) {
44313 extra_count = true;
44314 - port->count--;
44315 + atomic_dec(&port->count);
44316 }
44317 spin_unlock_irqrestore(&info->lock, flags);
44318 port->blocked_open++;
44319 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44320
44321 if (debug_level >= DEBUG_LEVEL_INFO)
44322 printk("%s(%d):%s block_til_ready() count=%d\n",
44323 - __FILE__,__LINE__, tty->driver->name, port->count );
44324 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44325
44326 tty_unlock(tty);
44327 schedule();
44328 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44329 remove_wait_queue(&port->open_wait, &wait);
44330
44331 if (extra_count)
44332 - port->count++;
44333 + atomic_inc(&port->count);
44334 port->blocked_open--;
44335
44336 if (debug_level >= DEBUG_LEVEL_INFO)
44337 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44338 - __FILE__,__LINE__, tty->driver->name, port->count );
44339 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44340
44341 if (!retval)
44342 port->flags |= ASYNC_NORMAL_ACTIVE;
44343 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44344 index b3c4a25..723916f 100644
44345 --- a/drivers/tty/sysrq.c
44346 +++ b/drivers/tty/sysrq.c
44347 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44348 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44349 size_t count, loff_t *ppos)
44350 {
44351 - if (count) {
44352 + if (count && capable(CAP_SYS_ADMIN)) {
44353 char c;
44354
44355 if (get_user(c, buf))
44356 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44357 index f34f98d..73c6c42 100644
44358 --- a/drivers/tty/tty_io.c
44359 +++ b/drivers/tty/tty_io.c
44360 @@ -3401,7 +3401,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44361
44362 void tty_default_fops(struct file_operations *fops)
44363 {
44364 - *fops = tty_fops;
44365 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44366 }
44367
44368 /*
44369 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44370 index 78f1be2..3e98910 100644
44371 --- a/drivers/tty/tty_ldisc.c
44372 +++ b/drivers/tty/tty_ldisc.c
44373 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44374 if (atomic_dec_and_test(&ld->users)) {
44375 struct tty_ldisc_ops *ldo = ld->ops;
44376
44377 - ldo->refcount--;
44378 + atomic_dec(&ldo->refcount);
44379 module_put(ldo->owner);
44380 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44381
44382 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44383 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44384 tty_ldiscs[disc] = new_ldisc;
44385 new_ldisc->num = disc;
44386 - new_ldisc->refcount = 0;
44387 + atomic_set(&new_ldisc->refcount, 0);
44388 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44389
44390 return ret;
44391 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44392 return -EINVAL;
44393
44394 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44395 - if (tty_ldiscs[disc]->refcount)
44396 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44397 ret = -EBUSY;
44398 else
44399 tty_ldiscs[disc] = NULL;
44400 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44401 if (ldops) {
44402 ret = ERR_PTR(-EAGAIN);
44403 if (try_module_get(ldops->owner)) {
44404 - ldops->refcount++;
44405 + atomic_inc(&ldops->refcount);
44406 ret = ldops;
44407 }
44408 }
44409 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44410 unsigned long flags;
44411
44412 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44413 - ldops->refcount--;
44414 + atomic_dec(&ldops->refcount);
44415 module_put(ldops->owner);
44416 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44417 }
44418 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44419 index b7ff59d..7c6105e 100644
44420 --- a/drivers/tty/tty_port.c
44421 +++ b/drivers/tty/tty_port.c
44422 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44423 unsigned long flags;
44424
44425 spin_lock_irqsave(&port->lock, flags);
44426 - port->count = 0;
44427 + atomic_set(&port->count, 0);
44428 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44429 if (port->tty) {
44430 set_bit(TTY_IO_ERROR, &port->tty->flags);
44431 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44432 /* The port lock protects the port counts */
44433 spin_lock_irqsave(&port->lock, flags);
44434 if (!tty_hung_up_p(filp))
44435 - port->count--;
44436 + atomic_dec(&port->count);
44437 port->blocked_open++;
44438 spin_unlock_irqrestore(&port->lock, flags);
44439
44440 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44441 we must not mess that up further */
44442 spin_lock_irqsave(&port->lock, flags);
44443 if (!tty_hung_up_p(filp))
44444 - port->count++;
44445 + atomic_inc(&port->count);
44446 port->blocked_open--;
44447 if (retval == 0)
44448 port->flags |= ASYNC_NORMAL_ACTIVE;
44449 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44450 return 0;
44451 }
44452
44453 - if (tty->count == 1 && port->count != 1) {
44454 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44455 printk(KERN_WARNING
44456 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44457 - port->count);
44458 - port->count = 1;
44459 + atomic_read(&port->count));
44460 + atomic_set(&port->count, 1);
44461 }
44462 - if (--port->count < 0) {
44463 + if (atomic_dec_return(&port->count) < 0) {
44464 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44465 - port->count);
44466 - port->count = 0;
44467 + atomic_read(&port->count));
44468 + atomic_set(&port->count, 0);
44469 }
44470
44471 - if (port->count) {
44472 + if (atomic_read(&port->count)) {
44473 spin_unlock_irqrestore(&port->lock, flags);
44474 if (port->ops->drop)
44475 port->ops->drop(port);
44476 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44477 {
44478 spin_lock_irq(&port->lock);
44479 if (!tty_hung_up_p(filp))
44480 - ++port->count;
44481 + atomic_inc(&port->count);
44482 spin_unlock_irq(&port->lock);
44483 tty_port_tty_set(port, tty);
44484
44485 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44486 index 681765b..d3ccdf2 100644
44487 --- a/drivers/tty/vt/keyboard.c
44488 +++ b/drivers/tty/vt/keyboard.c
44489 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44490 kbd->kbdmode == VC_OFF) &&
44491 value != KVAL(K_SAK))
44492 return; /* SAK is allowed even in raw mode */
44493 +
44494 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44495 + {
44496 + void *func = fn_handler[value];
44497 + if (func == fn_show_state || func == fn_show_ptregs ||
44498 + func == fn_show_mem)
44499 + return;
44500 + }
44501 +#endif
44502 +
44503 fn_handler[value](vc);
44504 }
44505
44506 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44507 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44508 return -EFAULT;
44509
44510 - if (!capable(CAP_SYS_TTY_CONFIG))
44511 - perm = 0;
44512 -
44513 switch (cmd) {
44514 case KDGKBENT:
44515 /* Ensure another thread doesn't free it under us */
44516 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44517 spin_unlock_irqrestore(&kbd_event_lock, flags);
44518 return put_user(val, &user_kbe->kb_value);
44519 case KDSKBENT:
44520 + if (!capable(CAP_SYS_TTY_CONFIG))
44521 + perm = 0;
44522 +
44523 if (!perm)
44524 return -EPERM;
44525 if (!i && v == K_NOSUCHMAP) {
44526 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44527 int i, j, k;
44528 int ret;
44529
44530 - if (!capable(CAP_SYS_TTY_CONFIG))
44531 - perm = 0;
44532 -
44533 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44534 if (!kbs) {
44535 ret = -ENOMEM;
44536 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44537 kfree(kbs);
44538 return ((p && *p) ? -EOVERFLOW : 0);
44539 case KDSKBSENT:
44540 + if (!capable(CAP_SYS_TTY_CONFIG))
44541 + perm = 0;
44542 +
44543 if (!perm) {
44544 ret = -EPERM;
44545 goto reterr;
44546 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44547 index 5110f36..8dc0a74 100644
44548 --- a/drivers/uio/uio.c
44549 +++ b/drivers/uio/uio.c
44550 @@ -25,6 +25,7 @@
44551 #include <linux/kobject.h>
44552 #include <linux/cdev.h>
44553 #include <linux/uio_driver.h>
44554 +#include <asm/local.h>
44555
44556 #define UIO_MAX_DEVICES (1U << MINORBITS)
44557
44558 @@ -32,10 +33,10 @@ struct uio_device {
44559 struct module *owner;
44560 struct device *dev;
44561 int minor;
44562 - atomic_t event;
44563 + atomic_unchecked_t event;
44564 struct fasync_struct *async_queue;
44565 wait_queue_head_t wait;
44566 - int vma_count;
44567 + local_t vma_count;
44568 struct uio_info *info;
44569 struct kobject *map_dir;
44570 struct kobject *portio_dir;
44571 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44572 struct device_attribute *attr, char *buf)
44573 {
44574 struct uio_device *idev = dev_get_drvdata(dev);
44575 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44576 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44577 }
44578
44579 static struct device_attribute uio_class_attributes[] = {
44580 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44581 {
44582 struct uio_device *idev = info->uio_dev;
44583
44584 - atomic_inc(&idev->event);
44585 + atomic_inc_unchecked(&idev->event);
44586 wake_up_interruptible(&idev->wait);
44587 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44588 }
44589 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44590 }
44591
44592 listener->dev = idev;
44593 - listener->event_count = atomic_read(&idev->event);
44594 + listener->event_count = atomic_read_unchecked(&idev->event);
44595 filep->private_data = listener;
44596
44597 if (idev->info->open) {
44598 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44599 return -EIO;
44600
44601 poll_wait(filep, &idev->wait, wait);
44602 - if (listener->event_count != atomic_read(&idev->event))
44603 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44604 return POLLIN | POLLRDNORM;
44605 return 0;
44606 }
44607 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44608 do {
44609 set_current_state(TASK_INTERRUPTIBLE);
44610
44611 - event_count = atomic_read(&idev->event);
44612 + event_count = atomic_read_unchecked(&idev->event);
44613 if (event_count != listener->event_count) {
44614 if (copy_to_user(buf, &event_count, count))
44615 retval = -EFAULT;
44616 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44617 static void uio_vma_open(struct vm_area_struct *vma)
44618 {
44619 struct uio_device *idev = vma->vm_private_data;
44620 - idev->vma_count++;
44621 + local_inc(&idev->vma_count);
44622 }
44623
44624 static void uio_vma_close(struct vm_area_struct *vma)
44625 {
44626 struct uio_device *idev = vma->vm_private_data;
44627 - idev->vma_count--;
44628 + local_dec(&idev->vma_count);
44629 }
44630
44631 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44632 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44633 idev->owner = owner;
44634 idev->info = info;
44635 init_waitqueue_head(&idev->wait);
44636 - atomic_set(&idev->event, 0);
44637 + atomic_set_unchecked(&idev->event, 0);
44638
44639 ret = uio_get_minor(idev);
44640 if (ret)
44641 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44642 index b7eb86a..36d28af 100644
44643 --- a/drivers/usb/atm/cxacru.c
44644 +++ b/drivers/usb/atm/cxacru.c
44645 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44646 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44647 if (ret < 2)
44648 return -EINVAL;
44649 - if (index < 0 || index > 0x7f)
44650 + if (index > 0x7f)
44651 return -EINVAL;
44652 pos += tmp;
44653
44654 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44655 index 35f10bf..6a38a0b 100644
44656 --- a/drivers/usb/atm/usbatm.c
44657 +++ b/drivers/usb/atm/usbatm.c
44658 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44659 if (printk_ratelimit())
44660 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44661 __func__, vpi, vci);
44662 - atomic_inc(&vcc->stats->rx_err);
44663 + atomic_inc_unchecked(&vcc->stats->rx_err);
44664 return;
44665 }
44666
44667 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44668 if (length > ATM_MAX_AAL5_PDU) {
44669 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44670 __func__, length, vcc);
44671 - atomic_inc(&vcc->stats->rx_err);
44672 + atomic_inc_unchecked(&vcc->stats->rx_err);
44673 goto out;
44674 }
44675
44676 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44677 if (sarb->len < pdu_length) {
44678 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44679 __func__, pdu_length, sarb->len, vcc);
44680 - atomic_inc(&vcc->stats->rx_err);
44681 + atomic_inc_unchecked(&vcc->stats->rx_err);
44682 goto out;
44683 }
44684
44685 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44686 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44687 __func__, vcc);
44688 - atomic_inc(&vcc->stats->rx_err);
44689 + atomic_inc_unchecked(&vcc->stats->rx_err);
44690 goto out;
44691 }
44692
44693 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44694 if (printk_ratelimit())
44695 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44696 __func__, length);
44697 - atomic_inc(&vcc->stats->rx_drop);
44698 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44699 goto out;
44700 }
44701
44702 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44703
44704 vcc->push(vcc, skb);
44705
44706 - atomic_inc(&vcc->stats->rx);
44707 + atomic_inc_unchecked(&vcc->stats->rx);
44708 out:
44709 skb_trim(sarb, 0);
44710 }
44711 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44712 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44713
44714 usbatm_pop(vcc, skb);
44715 - atomic_inc(&vcc->stats->tx);
44716 + atomic_inc_unchecked(&vcc->stats->tx);
44717
44718 skb = skb_dequeue(&instance->sndqueue);
44719 }
44720 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44721 if (!left--)
44722 return sprintf(page,
44723 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44724 - atomic_read(&atm_dev->stats.aal5.tx),
44725 - atomic_read(&atm_dev->stats.aal5.tx_err),
44726 - atomic_read(&atm_dev->stats.aal5.rx),
44727 - atomic_read(&atm_dev->stats.aal5.rx_err),
44728 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44729 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44730 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44731 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44732 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44733 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44734
44735 if (!left--) {
44736 if (instance->disconnected)
44737 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44738 index cbacea9..246cccd 100644
44739 --- a/drivers/usb/core/devices.c
44740 +++ b/drivers/usb/core/devices.c
44741 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44742 * time it gets called.
44743 */
44744 static struct device_connect_event {
44745 - atomic_t count;
44746 + atomic_unchecked_t count;
44747 wait_queue_head_t wait;
44748 } device_event = {
44749 .count = ATOMIC_INIT(1),
44750 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44751
44752 void usbfs_conn_disc_event(void)
44753 {
44754 - atomic_add(2, &device_event.count);
44755 + atomic_add_unchecked(2, &device_event.count);
44756 wake_up(&device_event.wait);
44757 }
44758
44759 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44760
44761 poll_wait(file, &device_event.wait, wait);
44762
44763 - event_count = atomic_read(&device_event.count);
44764 + event_count = atomic_read_unchecked(&device_event.count);
44765 if (file->f_version != event_count) {
44766 file->f_version = event_count;
44767 return POLLIN | POLLRDNORM;
44768 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44769 index 8e64adf..9a33a3c 100644
44770 --- a/drivers/usb/core/hcd.c
44771 +++ b/drivers/usb/core/hcd.c
44772 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44773 */
44774 usb_get_urb(urb);
44775 atomic_inc(&urb->use_count);
44776 - atomic_inc(&urb->dev->urbnum);
44777 + atomic_inc_unchecked(&urb->dev->urbnum);
44778 usbmon_urb_submit(&hcd->self, urb);
44779
44780 /* NOTE requirements on root-hub callers (usbfs and the hub
44781 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44782 urb->hcpriv = NULL;
44783 INIT_LIST_HEAD(&urb->urb_list);
44784 atomic_dec(&urb->use_count);
44785 - atomic_dec(&urb->dev->urbnum);
44786 + atomic_dec_unchecked(&urb->dev->urbnum);
44787 if (atomic_read(&urb->reject))
44788 wake_up(&usb_kill_urb_queue);
44789 usb_put_urb(urb);
44790 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44791 index 131f736..99004c3 100644
44792 --- a/drivers/usb/core/message.c
44793 +++ b/drivers/usb/core/message.c
44794 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44795 * method can wait for it to complete. Since you don't have a handle on the
44796 * URB used, you can't cancel the request.
44797 */
44798 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44799 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44800 __u8 requesttype, __u16 value, __u16 index, void *data,
44801 __u16 size, int timeout)
44802 {
44803 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44804 index 818e4a0..0fc9589 100644
44805 --- a/drivers/usb/core/sysfs.c
44806 +++ b/drivers/usb/core/sysfs.c
44807 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44808 struct usb_device *udev;
44809
44810 udev = to_usb_device(dev);
44811 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44812 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44813 }
44814 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44815
44816 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44817 index f81b925..78d22ec 100644
44818 --- a/drivers/usb/core/usb.c
44819 +++ b/drivers/usb/core/usb.c
44820 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44821 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44822 dev->state = USB_STATE_ATTACHED;
44823 dev->lpm_disable_count = 1;
44824 - atomic_set(&dev->urbnum, 0);
44825 + atomic_set_unchecked(&dev->urbnum, 0);
44826
44827 INIT_LIST_HEAD(&dev->ep0.urb_list);
44828 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44829 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44830 index 5e29dde..eca992f 100644
44831 --- a/drivers/usb/early/ehci-dbgp.c
44832 +++ b/drivers/usb/early/ehci-dbgp.c
44833 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44834
44835 #ifdef CONFIG_KGDB
44836 static struct kgdb_io kgdbdbgp_io_ops;
44837 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44838 +static struct kgdb_io kgdbdbgp_io_ops_console;
44839 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44840 #else
44841 #define dbgp_kgdb_mode (0)
44842 #endif
44843 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44844 .write_char = kgdbdbgp_write_char,
44845 };
44846
44847 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44848 + .name = "kgdbdbgp",
44849 + .read_char = kgdbdbgp_read_char,
44850 + .write_char = kgdbdbgp_write_char,
44851 + .is_console = 1
44852 +};
44853 +
44854 static int kgdbdbgp_wait_time;
44855
44856 static int __init kgdbdbgp_parse_config(char *str)
44857 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44858 ptr++;
44859 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44860 }
44861 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44862 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44863 + if (early_dbgp_console.index != -1)
44864 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44865 + else
44866 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44867
44868 return 0;
44869 }
44870 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44871 index 598dcc1..032dd4f 100644
44872 --- a/drivers/usb/gadget/u_serial.c
44873 +++ b/drivers/usb/gadget/u_serial.c
44874 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44875 spin_lock_irq(&port->port_lock);
44876
44877 /* already open? Great. */
44878 - if (port->port.count) {
44879 + if (atomic_read(&port->port.count)) {
44880 status = 0;
44881 - port->port.count++;
44882 + atomic_inc(&port->port.count);
44883
44884 /* currently opening/closing? wait ... */
44885 } else if (port->openclose) {
44886 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44887 tty->driver_data = port;
44888 port->port.tty = tty;
44889
44890 - port->port.count = 1;
44891 + atomic_set(&port->port.count, 1);
44892 port->openclose = false;
44893
44894 /* if connected, start the I/O stream */
44895 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44896
44897 spin_lock_irq(&port->port_lock);
44898
44899 - if (port->port.count != 1) {
44900 - if (port->port.count == 0)
44901 + if (atomic_read(&port->port.count) != 1) {
44902 + if (atomic_read(&port->port.count) == 0)
44903 WARN_ON(1);
44904 else
44905 - --port->port.count;
44906 + atomic_dec(&port->port.count);
44907 goto exit;
44908 }
44909
44910 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44911 * and sleep if necessary
44912 */
44913 port->openclose = true;
44914 - port->port.count = 0;
44915 + atomic_set(&port->port.count, 0);
44916
44917 gser = port->port_usb;
44918 if (gser && gser->disconnect)
44919 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44920 int cond;
44921
44922 spin_lock_irq(&port->port_lock);
44923 - cond = (port->port.count == 0) && !port->openclose;
44924 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44925 spin_unlock_irq(&port->port_lock);
44926 return cond;
44927 }
44928 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44929 /* if it's already open, start I/O ... and notify the serial
44930 * protocol about open/close status (connect/disconnect).
44931 */
44932 - if (port->port.count) {
44933 + if (atomic_read(&port->port.count)) {
44934 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44935 gs_start_io(port);
44936 if (gser->connect)
44937 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44938
44939 port->port_usb = NULL;
44940 gser->ioport = NULL;
44941 - if (port->port.count > 0 || port->openclose) {
44942 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44943 wake_up_interruptible(&port->drain_wait);
44944 if (port->port.tty)
44945 tty_hangup(port->port.tty);
44946 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44947
44948 /* finally, free any unused/unusable I/O buffers */
44949 spin_lock_irqsave(&port->port_lock, flags);
44950 - if (port->port.count == 0 && !port->openclose)
44951 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44952 gs_buf_free(&port->port_write_buf);
44953 gs_free_requests(gser->out, &port->read_pool, NULL);
44954 gs_free_requests(gser->out, &port->read_queue, NULL);
44955 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44956 index 5f3bcd3..bfca43f 100644
44957 --- a/drivers/usb/serial/console.c
44958 +++ b/drivers/usb/serial/console.c
44959 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44960
44961 info->port = port;
44962
44963 - ++port->port.count;
44964 + atomic_inc(&port->port.count);
44965 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44966 if (serial->type->set_termios) {
44967 /*
44968 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44969 }
44970 /* Now that any required fake tty operations are completed restore
44971 * the tty port count */
44972 - --port->port.count;
44973 + atomic_dec(&port->port.count);
44974 /* The console is special in terms of closing the device so
44975 * indicate this port is now acting as a system console. */
44976 port->port.console = 1;
44977 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44978 free_tty:
44979 kfree(tty);
44980 reset_open_count:
44981 - port->port.count = 0;
44982 + atomic_set(&port->port.count, 0);
44983 usb_autopm_put_interface(serial->interface);
44984 error_get_interface:
44985 usb_serial_put(serial);
44986 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44987 index 6c3586a..a94e621 100644
44988 --- a/drivers/usb/storage/realtek_cr.c
44989 +++ b/drivers/usb/storage/realtek_cr.c
44990 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44991
44992 buf = kmalloc(len, GFP_NOIO);
44993 if (buf == NULL)
44994 - return USB_STOR_TRANSPORT_ERROR;
44995 + return -ENOMEM;
44996
44997 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44998
44999 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
45000 index 75f70f0..d467e1a 100644
45001 --- a/drivers/usb/storage/usb.h
45002 +++ b/drivers/usb/storage/usb.h
45003 @@ -63,7 +63,7 @@ struct us_unusual_dev {
45004 __u8 useProtocol;
45005 __u8 useTransport;
45006 int (*initFunction)(struct us_data *);
45007 -};
45008 +} __do_const;
45009
45010
45011 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
45012 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
45013 index d6bea3e..60b250e 100644
45014 --- a/drivers/usb/wusbcore/wa-hc.h
45015 +++ b/drivers/usb/wusbcore/wa-hc.h
45016 @@ -192,7 +192,7 @@ struct wahc {
45017 struct list_head xfer_delayed_list;
45018 spinlock_t xfer_list_lock;
45019 struct work_struct xfer_work;
45020 - atomic_t xfer_id_count;
45021 + atomic_unchecked_t xfer_id_count;
45022 };
45023
45024
45025 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
45026 INIT_LIST_HEAD(&wa->xfer_delayed_list);
45027 spin_lock_init(&wa->xfer_list_lock);
45028 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45029 - atomic_set(&wa->xfer_id_count, 1);
45030 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45031 }
45032
45033 /**
45034 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45035 index 57c01ab..8a05959 100644
45036 --- a/drivers/usb/wusbcore/wa-xfer.c
45037 +++ b/drivers/usb/wusbcore/wa-xfer.c
45038 @@ -296,7 +296,7 @@ out:
45039 */
45040 static void wa_xfer_id_init(struct wa_xfer *xfer)
45041 {
45042 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45043 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45044 }
45045
45046 /*
45047 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45048 index 8c55011..eed4ae1a 100644
45049 --- a/drivers/video/aty/aty128fb.c
45050 +++ b/drivers/video/aty/aty128fb.c
45051 @@ -149,7 +149,7 @@ enum {
45052 };
45053
45054 /* Must match above enum */
45055 -static char * const r128_family[] = {
45056 +static const char * const r128_family[] = {
45057 "AGP",
45058 "PCI",
45059 "PRO AGP",
45060 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45061 index 4f27fdc..d3537e6 100644
45062 --- a/drivers/video/aty/atyfb_base.c
45063 +++ b/drivers/video/aty/atyfb_base.c
45064 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45065 par->accel_flags = var->accel_flags; /* hack */
45066
45067 if (var->accel_flags) {
45068 - info->fbops->fb_sync = atyfb_sync;
45069 + pax_open_kernel();
45070 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45071 + pax_close_kernel();
45072 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45073 } else {
45074 - info->fbops->fb_sync = NULL;
45075 + pax_open_kernel();
45076 + *(void **)&info->fbops->fb_sync = NULL;
45077 + pax_close_kernel();
45078 info->flags |= FBINFO_HWACCEL_DISABLED;
45079 }
45080
45081 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45082 index 95ec042..e6affdd 100644
45083 --- a/drivers/video/aty/mach64_cursor.c
45084 +++ b/drivers/video/aty/mach64_cursor.c
45085 @@ -7,6 +7,7 @@
45086 #include <linux/string.h>
45087
45088 #include <asm/io.h>
45089 +#include <asm/pgtable.h>
45090
45091 #ifdef __sparc__
45092 #include <asm/fbio.h>
45093 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45094 info->sprite.buf_align = 16; /* and 64 lines tall. */
45095 info->sprite.flags = FB_PIXMAP_IO;
45096
45097 - info->fbops->fb_cursor = atyfb_cursor;
45098 + pax_open_kernel();
45099 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45100 + pax_close_kernel();
45101
45102 return 0;
45103 }
45104 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45105 index 6c5ed6b..b727c88 100644
45106 --- a/drivers/video/backlight/kb3886_bl.c
45107 +++ b/drivers/video/backlight/kb3886_bl.c
45108 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45109 static unsigned long kb3886bl_flags;
45110 #define KB3886BL_SUSPENDED 0x01
45111
45112 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45113 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45114 {
45115 .ident = "Sahara Touch-iT",
45116 .matches = {
45117 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45118 index 88cad6b..dd746c7 100644
45119 --- a/drivers/video/fb_defio.c
45120 +++ b/drivers/video/fb_defio.c
45121 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45122
45123 BUG_ON(!fbdefio);
45124 mutex_init(&fbdefio->lock);
45125 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45126 + pax_open_kernel();
45127 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45128 + pax_close_kernel();
45129 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45130 INIT_LIST_HEAD(&fbdefio->pagelist);
45131 if (fbdefio->delay == 0) /* set a default of 1 s */
45132 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45133 page->mapping = NULL;
45134 }
45135
45136 - info->fbops->fb_mmap = NULL;
45137 + *(void **)&info->fbops->fb_mmap = NULL;
45138 mutex_destroy(&fbdefio->lock);
45139 }
45140 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45141 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45142 index 5c3960d..15cf8fc 100644
45143 --- a/drivers/video/fbcmap.c
45144 +++ b/drivers/video/fbcmap.c
45145 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45146 rc = -ENODEV;
45147 goto out;
45148 }
45149 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45150 - !info->fbops->fb_setcmap)) {
45151 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45152 rc = -EINVAL;
45153 goto out1;
45154 }
45155 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45156 index 0a49456..fd5be1b 100644
45157 --- a/drivers/video/fbmem.c
45158 +++ b/drivers/video/fbmem.c
45159 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45160 image->dx += image->width + 8;
45161 }
45162 } else if (rotate == FB_ROTATE_UD) {
45163 - for (x = 0; x < num && image->dx >= 0; x++) {
45164 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45165 info->fbops->fb_imageblit(info, image);
45166 image->dx -= image->width + 8;
45167 }
45168 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45169 image->dy += image->height + 8;
45170 }
45171 } else if (rotate == FB_ROTATE_CCW) {
45172 - for (x = 0; x < num && image->dy >= 0; x++) {
45173 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45174 info->fbops->fb_imageblit(info, image);
45175 image->dy -= image->height + 8;
45176 }
45177 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45178 return -EFAULT;
45179 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45180 return -EINVAL;
45181 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45182 + if (con2fb.framebuffer >= FB_MAX)
45183 return -EINVAL;
45184 if (!registered_fb[con2fb.framebuffer])
45185 request_module("fb%d", con2fb.framebuffer);
45186 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45187 index 7672d2e..b56437f 100644
45188 --- a/drivers/video/i810/i810_accel.c
45189 +++ b/drivers/video/i810/i810_accel.c
45190 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45191 }
45192 }
45193 printk("ringbuffer lockup!!!\n");
45194 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45195 i810_report_error(mmio);
45196 par->dev_flags |= LOCKUP;
45197 info->pixmap.scan_align = 1;
45198 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45199 index 3c14e43..eafa544 100644
45200 --- a/drivers/video/logo/logo_linux_clut224.ppm
45201 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45202 @@ -1,1604 +1,1123 @@
45203 P3
45204 -# Standard 224-color Linux logo
45205 80 80
45206 255
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 6 6 6 6 6 6 10 10 10 10 10 10
45217 - 10 10 10 6 6 6 6 6 6 6 6 6
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 0 0 0 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 6 6 6 10 10 10 14 14 14
45236 - 22 22 22 26 26 26 30 30 30 34 34 34
45237 - 30 30 30 30 30 30 26 26 26 18 18 18
45238 - 14 14 14 10 10 10 6 6 6 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 0 0 0 0 0 0 0 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 0 0 0 0 0 1 0 0 1 0 0 0
45249 - 0 0 0 0 0 0 0 0 0 0 0 0
45250 - 0 0 0 0 0 0 0 0 0 0 0 0
45251 - 0 0 0 0 0 0 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 6 6 6 14 14 14 26 26 26 42 42 42
45256 - 54 54 54 66 66 66 78 78 78 78 78 78
45257 - 78 78 78 74 74 74 66 66 66 54 54 54
45258 - 42 42 42 26 26 26 18 18 18 10 10 10
45259 - 6 6 6 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 0 0 0 0 0 0 0 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 0 0 1 0 0 0 0 0 0 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 10 10 10
45275 - 22 22 22 42 42 42 66 66 66 86 86 86
45276 - 66 66 66 38 38 38 38 38 38 22 22 22
45277 - 26 26 26 34 34 34 54 54 54 66 66 66
45278 - 86 86 86 70 70 70 46 46 46 26 26 26
45279 - 14 14 14 6 6 6 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 0 0 0 0 0 0 0 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 0 0 1 0 0 1 0 0 1 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 10 10 10 26 26 26
45295 - 50 50 50 82 82 82 58 58 58 6 6 6
45296 - 2 2 6 2 2 6 2 2 6 2 2 6
45297 - 2 2 6 2 2 6 2 2 6 2 2 6
45298 - 6 6 6 54 54 54 86 86 86 66 66 66
45299 - 38 38 38 18 18 18 6 6 6 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 0 0 0
45308 - 0 0 0 0 0 0 0 0 0 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 6 6 6 22 22 22 50 50 50
45315 - 78 78 78 34 34 34 2 2 6 2 2 6
45316 - 2 2 6 2 2 6 2 2 6 2 2 6
45317 - 2 2 6 2 2 6 2 2 6 2 2 6
45318 - 2 2 6 2 2 6 6 6 6 70 70 70
45319 - 78 78 78 46 46 46 22 22 22 6 6 6
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 0 0 0 0 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 0 0 0
45328 - 0 0 1 0 0 1 0 0 1 0 0 0
45329 - 0 0 0 0 0 0 0 0 0 0 0 0
45330 - 0 0 0 0 0 0 0 0 0 0 0 0
45331 - 0 0 0 0 0 0 0 0 0 0 0 0
45332 - 0 0 0 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 6 6 6 18 18 18 42 42 42 82 82 82
45335 - 26 26 26 2 2 6 2 2 6 2 2 6
45336 - 2 2 6 2 2 6 2 2 6 2 2 6
45337 - 2 2 6 2 2 6 2 2 6 14 14 14
45338 - 46 46 46 34 34 34 6 6 6 2 2 6
45339 - 42 42 42 78 78 78 42 42 42 18 18 18
45340 - 6 6 6 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 0 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 0 0 0
45348 - 0 0 1 0 0 0 0 0 1 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 10 10 10 30 30 30 66 66 66 58 58 58
45355 - 2 2 6 2 2 6 2 2 6 2 2 6
45356 - 2 2 6 2 2 6 2 2 6 2 2 6
45357 - 2 2 6 2 2 6 2 2 6 26 26 26
45358 - 86 86 86 101 101 101 46 46 46 10 10 10
45359 - 2 2 6 58 58 58 70 70 70 34 34 34
45360 - 10 10 10 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 0 0 0 0 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 0 0 0
45368 - 0 0 1 0 0 1 0 0 1 0 0 0
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 14 14 14 42 42 42 86 86 86 10 10 10
45375 - 2 2 6 2 2 6 2 2 6 2 2 6
45376 - 2 2 6 2 2 6 2 2 6 2 2 6
45377 - 2 2 6 2 2 6 2 2 6 30 30 30
45378 - 94 94 94 94 94 94 58 58 58 26 26 26
45379 - 2 2 6 6 6 6 78 78 78 54 54 54
45380 - 22 22 22 6 6 6 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 0 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 0 0 0
45388 - 0 0 0 0 0 0 0 0 0 0 0 0
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 6 6 6
45394 - 22 22 22 62 62 62 62 62 62 2 2 6
45395 - 2 2 6 2 2 6 2 2 6 2 2 6
45396 - 2 2 6 2 2 6 2 2 6 2 2 6
45397 - 2 2 6 2 2 6 2 2 6 26 26 26
45398 - 54 54 54 38 38 38 18 18 18 10 10 10
45399 - 2 2 6 2 2 6 34 34 34 82 82 82
45400 - 38 38 38 14 14 14 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 0 0 0 0 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 0 0 0
45408 - 0 0 0 0 0 1 0 0 1 0 0 0
45409 - 0 0 0 0 0 0 0 0 0 0 0 0
45410 - 0 0 0 0 0 0 0 0 0 0 0 0
45411 - 0 0 0 0 0 0 0 0 0 0 0 0
45412 - 0 0 0 0 0 0 0 0 0 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 6 6 6
45414 - 30 30 30 78 78 78 30 30 30 2 2 6
45415 - 2 2 6 2 2 6 2 2 6 2 2 6
45416 - 2 2 6 2 2 6 2 2 6 2 2 6
45417 - 2 2 6 2 2 6 2 2 6 10 10 10
45418 - 10 10 10 2 2 6 2 2 6 2 2 6
45419 - 2 2 6 2 2 6 2 2 6 78 78 78
45420 - 50 50 50 18 18 18 6 6 6 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 0 0 0
45428 - 0 0 1 0 0 0 0 0 0 0 0 0
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 10 10 10
45434 - 38 38 38 86 86 86 14 14 14 2 2 6
45435 - 2 2 6 2 2 6 2 2 6 2 2 6
45436 - 2 2 6 2 2 6 2 2 6 2 2 6
45437 - 2 2 6 2 2 6 2 2 6 2 2 6
45438 - 2 2 6 2 2 6 2 2 6 2 2 6
45439 - 2 2 6 2 2 6 2 2 6 54 54 54
45440 - 66 66 66 26 26 26 6 6 6 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 0 0 0 0 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 0 0 0
45448 - 0 0 0 0 0 1 0 0 1 0 0 0
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 14 14 14
45454 - 42 42 42 82 82 82 2 2 6 2 2 6
45455 - 2 2 6 6 6 6 10 10 10 2 2 6
45456 - 2 2 6 2 2 6 2 2 6 2 2 6
45457 - 2 2 6 2 2 6 2 2 6 6 6 6
45458 - 14 14 14 10 10 10 2 2 6 2 2 6
45459 - 2 2 6 2 2 6 2 2 6 18 18 18
45460 - 82 82 82 34 34 34 10 10 10 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 0 0 0
45468 - 0 0 1 0 0 0 0 0 0 0 0 0
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 14 14 14
45474 - 46 46 46 86 86 86 2 2 6 2 2 6
45475 - 6 6 6 6 6 6 22 22 22 34 34 34
45476 - 6 6 6 2 2 6 2 2 6 2 2 6
45477 - 2 2 6 2 2 6 18 18 18 34 34 34
45478 - 10 10 10 50 50 50 22 22 22 2 2 6
45479 - 2 2 6 2 2 6 2 2 6 10 10 10
45480 - 86 86 86 42 42 42 14 14 14 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 0 0 0 0 0 0 0 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 0 0 0
45488 - 0 0 1 0 0 1 0 0 1 0 0 0
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 14 14 14
45494 - 46 46 46 86 86 86 2 2 6 2 2 6
45495 - 38 38 38 116 116 116 94 94 94 22 22 22
45496 - 22 22 22 2 2 6 2 2 6 2 2 6
45497 - 14 14 14 86 86 86 138 138 138 162 162 162
45498 -154 154 154 38 38 38 26 26 26 6 6 6
45499 - 2 2 6 2 2 6 2 2 6 2 2 6
45500 - 86 86 86 46 46 46 14 14 14 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 0 0 0
45502 - 0 0 0 0 0 0 0 0 0 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 0 0 0
45508 - 0 0 0 0 0 0 0 0 0 0 0 0
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 14 14 14
45514 - 46 46 46 86 86 86 2 2 6 14 14 14
45515 -134 134 134 198 198 198 195 195 195 116 116 116
45516 - 10 10 10 2 2 6 2 2 6 6 6 6
45517 -101 98 89 187 187 187 210 210 210 218 218 218
45518 -214 214 214 134 134 134 14 14 14 6 6 6
45519 - 2 2 6 2 2 6 2 2 6 2 2 6
45520 - 86 86 86 50 50 50 18 18 18 6 6 6
45521 - 0 0 0 0 0 0 0 0 0 0 0 0
45522 - 0 0 0 0 0 0 0 0 0 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 1 0 0 0
45528 - 0 0 1 0 0 1 0 0 1 0 0 0
45529 - 0 0 0 0 0 0 0 0 0 0 0 0
45530 - 0 0 0 0 0 0 0 0 0 0 0 0
45531 - 0 0 0 0 0 0 0 0 0 0 0 0
45532 - 0 0 0 0 0 0 0 0 0 0 0 0
45533 - 0 0 0 0 0 0 0 0 0 14 14 14
45534 - 46 46 46 86 86 86 2 2 6 54 54 54
45535 -218 218 218 195 195 195 226 226 226 246 246 246
45536 - 58 58 58 2 2 6 2 2 6 30 30 30
45537 -210 210 210 253 253 253 174 174 174 123 123 123
45538 -221 221 221 234 234 234 74 74 74 2 2 6
45539 - 2 2 6 2 2 6 2 2 6 2 2 6
45540 - 70 70 70 58 58 58 22 22 22 6 6 6
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 0 0 0
45548 - 0 0 0 0 0 0 0 0 0 0 0 0
45549 - 0 0 0 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 14 14 14
45554 - 46 46 46 82 82 82 2 2 6 106 106 106
45555 -170 170 170 26 26 26 86 86 86 226 226 226
45556 -123 123 123 10 10 10 14 14 14 46 46 46
45557 -231 231 231 190 190 190 6 6 6 70 70 70
45558 - 90 90 90 238 238 238 158 158 158 2 2 6
45559 - 2 2 6 2 2 6 2 2 6 2 2 6
45560 - 70 70 70 58 58 58 22 22 22 6 6 6
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 1 0 0 0
45568 - 0 0 1 0 0 1 0 0 1 0 0 0
45569 - 0 0 0 0 0 0 0 0 0 0 0 0
45570 - 0 0 0 0 0 0 0 0 0 0 0 0
45571 - 0 0 0 0 0 0 0 0 0 0 0 0
45572 - 0 0 0 0 0 0 0 0 0 0 0 0
45573 - 0 0 0 0 0 0 0 0 0 14 14 14
45574 - 42 42 42 86 86 86 6 6 6 116 116 116
45575 -106 106 106 6 6 6 70 70 70 149 149 149
45576 -128 128 128 18 18 18 38 38 38 54 54 54
45577 -221 221 221 106 106 106 2 2 6 14 14 14
45578 - 46 46 46 190 190 190 198 198 198 2 2 6
45579 - 2 2 6 2 2 6 2 2 6 2 2 6
45580 - 74 74 74 62 62 62 22 22 22 6 6 6
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 1 0 0 0
45588 - 0 0 1 0 0 0 0 0 1 0 0 0
45589 - 0 0 0 0 0 0 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 14 14 14
45594 - 42 42 42 94 94 94 14 14 14 101 101 101
45595 -128 128 128 2 2 6 18 18 18 116 116 116
45596 -118 98 46 121 92 8 121 92 8 98 78 10
45597 -162 162 162 106 106 106 2 2 6 2 2 6
45598 - 2 2 6 195 195 195 195 195 195 6 6 6
45599 - 2 2 6 2 2 6 2 2 6 2 2 6
45600 - 74 74 74 62 62 62 22 22 22 6 6 6
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 1 0 0 1
45608 - 0 0 1 0 0 0 0 0 1 0 0 0
45609 - 0 0 0 0 0 0 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 10 10 10
45614 - 38 38 38 90 90 90 14 14 14 58 58 58
45615 -210 210 210 26 26 26 54 38 6 154 114 10
45616 -226 170 11 236 186 11 225 175 15 184 144 12
45617 -215 174 15 175 146 61 37 26 9 2 2 6
45618 - 70 70 70 246 246 246 138 138 138 2 2 6
45619 - 2 2 6 2 2 6 2 2 6 2 2 6
45620 - 70 70 70 66 66 66 26 26 26 6 6 6
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 0 0 0
45628 - 0 0 0 0 0 0 0 0 0 0 0 0
45629 - 0 0 0 0 0 0 0 0 0 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 10 10 10
45634 - 38 38 38 86 86 86 14 14 14 10 10 10
45635 -195 195 195 188 164 115 192 133 9 225 175 15
45636 -239 182 13 234 190 10 232 195 16 232 200 30
45637 -245 207 45 241 208 19 232 195 16 184 144 12
45638 -218 194 134 211 206 186 42 42 42 2 2 6
45639 - 2 2 6 2 2 6 2 2 6 2 2 6
45640 - 50 50 50 74 74 74 30 30 30 6 6 6
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 0 0 0
45648 - 0 0 0 0 0 0 0 0 0 0 0 0
45649 - 0 0 0 0 0 0 0 0 0 0 0 0
45650 - 0 0 0 0 0 0 0 0 0 0 0 0
45651 - 0 0 0 0 0 0 0 0 0 0 0 0
45652 - 0 0 0 0 0 0 0 0 0 0 0 0
45653 - 0 0 0 0 0 0 0 0 0 10 10 10
45654 - 34 34 34 86 86 86 14 14 14 2 2 6
45655 -121 87 25 192 133 9 219 162 10 239 182 13
45656 -236 186 11 232 195 16 241 208 19 244 214 54
45657 -246 218 60 246 218 38 246 215 20 241 208 19
45658 -241 208 19 226 184 13 121 87 25 2 2 6
45659 - 2 2 6 2 2 6 2 2 6 2 2 6
45660 - 50 50 50 82 82 82 34 34 34 10 10 10
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 0 0 0
45668 - 0 0 0 0 0 0 0 0 0 0 0 0
45669 - 0 0 0 0 0 0 0 0 0 0 0 0
45670 - 0 0 0 0 0 0 0 0 0 0 0 0
45671 - 0 0 0 0 0 0 0 0 0 0 0 0
45672 - 0 0 0 0 0 0 0 0 0 0 0 0
45673 - 0 0 0 0 0 0 0 0 0 10 10 10
45674 - 34 34 34 82 82 82 30 30 30 61 42 6
45675 -180 123 7 206 145 10 230 174 11 239 182 13
45676 -234 190 10 238 202 15 241 208 19 246 218 74
45677 -246 218 38 246 215 20 246 215 20 246 215 20
45678 -226 184 13 215 174 15 184 144 12 6 6 6
45679 - 2 2 6 2 2 6 2 2 6 2 2 6
45680 - 26 26 26 94 94 94 42 42 42 14 14 14
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 0 0 0 0 0 0
45688 - 0 0 0 0 0 0 0 0 0 0 0 0
45689 - 0 0 0 0 0 0 0 0 0 0 0 0
45690 - 0 0 0 0 0 0 0 0 0 0 0 0
45691 - 0 0 0 0 0 0 0 0 0 0 0 0
45692 - 0 0 0 0 0 0 0 0 0 0 0 0
45693 - 0 0 0 0 0 0 0 0 0 10 10 10
45694 - 30 30 30 78 78 78 50 50 50 104 69 6
45695 -192 133 9 216 158 10 236 178 12 236 186 11
45696 -232 195 16 241 208 19 244 214 54 245 215 43
45697 -246 215 20 246 215 20 241 208 19 198 155 10
45698 -200 144 11 216 158 10 156 118 10 2 2 6
45699 - 2 2 6 2 2 6 2 2 6 2 2 6
45700 - 6 6 6 90 90 90 54 54 54 18 18 18
45701 - 6 6 6 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 0 0 0 0 0 0
45708 - 0 0 0 0 0 0 0 0 0 0 0 0
45709 - 0 0 0 0 0 0 0 0 0 0 0 0
45710 - 0 0 0 0 0 0 0 0 0 0 0 0
45711 - 0 0 0 0 0 0 0 0 0 0 0 0
45712 - 0 0 0 0 0 0 0 0 0 0 0 0
45713 - 0 0 0 0 0 0 0 0 0 10 10 10
45714 - 30 30 30 78 78 78 46 46 46 22 22 22
45715 -137 92 6 210 162 10 239 182 13 238 190 10
45716 -238 202 15 241 208 19 246 215 20 246 215 20
45717 -241 208 19 203 166 17 185 133 11 210 150 10
45718 -216 158 10 210 150 10 102 78 10 2 2 6
45719 - 6 6 6 54 54 54 14 14 14 2 2 6
45720 - 2 2 6 62 62 62 74 74 74 30 30 30
45721 - 10 10 10 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 0 0 0 0 0 0 0 0 0
45728 - 0 0 0 0 0 0 0 0 0 0 0 0
45729 - 0 0 0 0 0 0 0 0 0 0 0 0
45730 - 0 0 0 0 0 0 0 0 0 0 0 0
45731 - 0 0 0 0 0 0 0 0 0 0 0 0
45732 - 0 0 0 0 0 0 0 0 0 0 0 0
45733 - 0 0 0 0 0 0 0 0 0 10 10 10
45734 - 34 34 34 78 78 78 50 50 50 6 6 6
45735 - 94 70 30 139 102 15 190 146 13 226 184 13
45736 -232 200 30 232 195 16 215 174 15 190 146 13
45737 -168 122 10 192 133 9 210 150 10 213 154 11
45738 -202 150 34 182 157 106 101 98 89 2 2 6
45739 - 2 2 6 78 78 78 116 116 116 58 58 58
45740 - 2 2 6 22 22 22 90 90 90 46 46 46
45741 - 18 18 18 6 6 6 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 0 0 0 0 0 0 0 0 0 0 0 0
45748 - 0 0 0 0 0 0 0 0 0 0 0 0
45749 - 0 0 0 0 0 0 0 0 0 0 0 0
45750 - 0 0 0 0 0 0 0 0 0 0 0 0
45751 - 0 0 0 0 0 0 0 0 0 0 0 0
45752 - 0 0 0 0 0 0 0 0 0 0 0 0
45753 - 0 0 0 0 0 0 0 0 0 10 10 10
45754 - 38 38 38 86 86 86 50 50 50 6 6 6
45755 -128 128 128 174 154 114 156 107 11 168 122 10
45756 -198 155 10 184 144 12 197 138 11 200 144 11
45757 -206 145 10 206 145 10 197 138 11 188 164 115
45758 -195 195 195 198 198 198 174 174 174 14 14 14
45759 - 2 2 6 22 22 22 116 116 116 116 116 116
45760 - 22 22 22 2 2 6 74 74 74 70 70 70
45761 - 30 30 30 10 10 10 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 0 0 0
45767 - 0 0 0 0 0 0 0 0 0 0 0 0
45768 - 0 0 0 0 0 0 0 0 0 0 0 0
45769 - 0 0 0 0 0 0 0 0 0 0 0 0
45770 - 0 0 0 0 0 0 0 0 0 0 0 0
45771 - 0 0 0 0 0 0 0 0 0 0 0 0
45772 - 0 0 0 0 0 0 0 0 0 0 0 0
45773 - 0 0 0 0 0 0 6 6 6 18 18 18
45774 - 50 50 50 101 101 101 26 26 26 10 10 10
45775 -138 138 138 190 190 190 174 154 114 156 107 11
45776 -197 138 11 200 144 11 197 138 11 192 133 9
45777 -180 123 7 190 142 34 190 178 144 187 187 187
45778 -202 202 202 221 221 221 214 214 214 66 66 66
45779 - 2 2 6 2 2 6 50 50 50 62 62 62
45780 - 6 6 6 2 2 6 10 10 10 90 90 90
45781 - 50 50 50 18 18 18 6 6 6 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 0 0 0
45787 - 0 0 0 0 0 0 0 0 0 0 0 0
45788 - 0 0 0 0 0 0 0 0 0 0 0 0
45789 - 0 0 0 0 0 0 0 0 0 0 0 0
45790 - 0 0 0 0 0 0 0 0 0 0 0 0
45791 - 0 0 0 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 10 10 10 34 34 34
45794 - 74 74 74 74 74 74 2 2 6 6 6 6
45795 -144 144 144 198 198 198 190 190 190 178 166 146
45796 -154 121 60 156 107 11 156 107 11 168 124 44
45797 -174 154 114 187 187 187 190 190 190 210 210 210
45798 -246 246 246 253 253 253 253 253 253 182 182 182
45799 - 6 6 6 2 2 6 2 2 6 2 2 6
45800 - 2 2 6 2 2 6 2 2 6 62 62 62
45801 - 74 74 74 34 34 34 14 14 14 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 0 0 0 0 0 0
45807 - 0 0 0 0 0 0 0 0 0 0 0 0
45808 - 0 0 0 0 0 0 0 0 0 0 0 0
45809 - 0 0 0 0 0 0 0 0 0 0 0 0
45810 - 0 0 0 0 0 0 0 0 0 0 0 0
45811 - 0 0 0 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 10 10 10 22 22 22 54 54 54
45814 - 94 94 94 18 18 18 2 2 6 46 46 46
45815 -234 234 234 221 221 221 190 190 190 190 190 190
45816 -190 190 190 187 187 187 187 187 187 190 190 190
45817 -190 190 190 195 195 195 214 214 214 242 242 242
45818 -253 253 253 253 253 253 253 253 253 253 253 253
45819 - 82 82 82 2 2 6 2 2 6 2 2 6
45820 - 2 2 6 2 2 6 2 2 6 14 14 14
45821 - 86 86 86 54 54 54 22 22 22 6 6 6
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 0 0 0 0 0 0 0 0 0
45827 - 0 0 0 0 0 0 0 0 0 0 0 0
45828 - 0 0 0 0 0 0 0 0 0 0 0 0
45829 - 0 0 0 0 0 0 0 0 0 0 0 0
45830 - 0 0 0 0 0 0 0 0 0 0 0 0
45831 - 0 0 0 0 0 0 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 6 6 6 18 18 18 46 46 46 90 90 90
45834 - 46 46 46 18 18 18 6 6 6 182 182 182
45835 -253 253 253 246 246 246 206 206 206 190 190 190
45836 -190 190 190 190 190 190 190 190 190 190 190 190
45837 -206 206 206 231 231 231 250 250 250 253 253 253
45838 -253 253 253 253 253 253 253 253 253 253 253 253
45839 -202 202 202 14 14 14 2 2 6 2 2 6
45840 - 2 2 6 2 2 6 2 2 6 2 2 6
45841 - 42 42 42 86 86 86 42 42 42 18 18 18
45842 - 6 6 6 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 0 0 0 0 0 0 0 0 0 0 0 0
45847 - 0 0 0 0 0 0 0 0 0 0 0 0
45848 - 0 0 0 0 0 0 0 0 0 0 0 0
45849 - 0 0 0 0 0 0 0 0 0 0 0 0
45850 - 0 0 0 0 0 0 0 0 0 0 0 0
45851 - 0 0 0 0 0 0 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 6 6 6
45853 - 14 14 14 38 38 38 74 74 74 66 66 66
45854 - 2 2 6 6 6 6 90 90 90 250 250 250
45855 -253 253 253 253 253 253 238 238 238 198 198 198
45856 -190 190 190 190 190 190 195 195 195 221 221 221
45857 -246 246 246 253 253 253 253 253 253 253 253 253
45858 -253 253 253 253 253 253 253 253 253 253 253 253
45859 -253 253 253 82 82 82 2 2 6 2 2 6
45860 - 2 2 6 2 2 6 2 2 6 2 2 6
45861 - 2 2 6 78 78 78 70 70 70 34 34 34
45862 - 14 14 14 6 6 6 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 0 0 0 0 0 0 0 0 0 0 0 0
45867 - 0 0 0 0 0 0 0 0 0 0 0 0
45868 - 0 0 0 0 0 0 0 0 0 0 0 0
45869 - 0 0 0 0 0 0 0 0 0 0 0 0
45870 - 0 0 0 0 0 0 0 0 0 0 0 0
45871 - 0 0 0 0 0 0 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 14 14 14
45873 - 34 34 34 66 66 66 78 78 78 6 6 6
45874 - 2 2 6 18 18 18 218 218 218 253 253 253
45875 -253 253 253 253 253 253 253 253 253 246 246 246
45876 -226 226 226 231 231 231 246 246 246 253 253 253
45877 -253 253 253 253 253 253 253 253 253 253 253 253
45878 -253 253 253 253 253 253 253 253 253 253 253 253
45879 -253 253 253 178 178 178 2 2 6 2 2 6
45880 - 2 2 6 2 2 6 2 2 6 2 2 6
45881 - 2 2 6 18 18 18 90 90 90 62 62 62
45882 - 30 30 30 10 10 10 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 0 0 0 0 0 0 0 0 0 0 0 0
45887 - 0 0 0 0 0 0 0 0 0 0 0 0
45888 - 0 0 0 0 0 0 0 0 0 0 0 0
45889 - 0 0 0 0 0 0 0 0 0 0 0 0
45890 - 0 0 0 0 0 0 0 0 0 0 0 0
45891 - 0 0 0 0 0 0 0 0 0 0 0 0
45892 - 0 0 0 0 0 0 10 10 10 26 26 26
45893 - 58 58 58 90 90 90 18 18 18 2 2 6
45894 - 2 2 6 110 110 110 253 253 253 253 253 253
45895 -253 253 253 253 253 253 253 253 253 253 253 253
45896 -250 250 250 253 253 253 253 253 253 253 253 253
45897 -253 253 253 253 253 253 253 253 253 253 253 253
45898 -253 253 253 253 253 253 253 253 253 253 253 253
45899 -253 253 253 231 231 231 18 18 18 2 2 6
45900 - 2 2 6 2 2 6 2 2 6 2 2 6
45901 - 2 2 6 2 2 6 18 18 18 94 94 94
45902 - 54 54 54 26 26 26 10 10 10 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 0 0 0
45906 - 0 0 0 0 0 0 0 0 0 0 0 0
45907 - 0 0 0 0 0 0 0 0 0 0 0 0
45908 - 0 0 0 0 0 0 0 0 0 0 0 0
45909 - 0 0 0 0 0 0 0 0 0 0 0 0
45910 - 0 0 0 0 0 0 0 0 0 0 0 0
45911 - 0 0 0 0 0 0 0 0 0 0 0 0
45912 - 0 0 0 6 6 6 22 22 22 50 50 50
45913 - 90 90 90 26 26 26 2 2 6 2 2 6
45914 - 14 14 14 195 195 195 250 250 250 253 253 253
45915 -253 253 253 253 253 253 253 253 253 253 253 253
45916 -253 253 253 253 253 253 253 253 253 253 253 253
45917 -253 253 253 253 253 253 253 253 253 253 253 253
45918 -253 253 253 253 253 253 253 253 253 253 253 253
45919 -250 250 250 242 242 242 54 54 54 2 2 6
45920 - 2 2 6 2 2 6 2 2 6 2 2 6
45921 - 2 2 6 2 2 6 2 2 6 38 38 38
45922 - 86 86 86 50 50 50 22 22 22 6 6 6
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 0 0 0
45926 - 0 0 0 0 0 0 0 0 0 0 0 0
45927 - 0 0 0 0 0 0 0 0 0 0 0 0
45928 - 0 0 0 0 0 0 0 0 0 0 0 0
45929 - 0 0 0 0 0 0 0 0 0 0 0 0
45930 - 0 0 0 0 0 0 0 0 0 0 0 0
45931 - 0 0 0 0 0 0 0 0 0 0 0 0
45932 - 6 6 6 14 14 14 38 38 38 82 82 82
45933 - 34 34 34 2 2 6 2 2 6 2 2 6
45934 - 42 42 42 195 195 195 246 246 246 253 253 253
45935 -253 253 253 253 253 253 253 253 253 250 250 250
45936 -242 242 242 242 242 242 250 250 250 253 253 253
45937 -253 253 253 253 253 253 253 253 253 253 253 253
45938 -253 253 253 250 250 250 246 246 246 238 238 238
45939 -226 226 226 231 231 231 101 101 101 6 6 6
45940 - 2 2 6 2 2 6 2 2 6 2 2 6
45941 - 2 2 6 2 2 6 2 2 6 2 2 6
45942 - 38 38 38 82 82 82 42 42 42 14 14 14
45943 - 6 6 6 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 0 0 0
45946 - 0 0 0 0 0 0 0 0 0 0 0 0
45947 - 0 0 0 0 0 0 0 0 0 0 0 0
45948 - 0 0 0 0 0 0 0 0 0 0 0 0
45949 - 0 0 0 0 0 0 0 0 0 0 0 0
45950 - 0 0 0 0 0 0 0 0 0 0 0 0
45951 - 0 0 0 0 0 0 0 0 0 0 0 0
45952 - 10 10 10 26 26 26 62 62 62 66 66 66
45953 - 2 2 6 2 2 6 2 2 6 6 6 6
45954 - 70 70 70 170 170 170 206 206 206 234 234 234
45955 -246 246 246 250 250 250 250 250 250 238 238 238
45956 -226 226 226 231 231 231 238 238 238 250 250 250
45957 -250 250 250 250 250 250 246 246 246 231 231 231
45958 -214 214 214 206 206 206 202 202 202 202 202 202
45959 -198 198 198 202 202 202 182 182 182 18 18 18
45960 - 2 2 6 2 2 6 2 2 6 2 2 6
45961 - 2 2 6 2 2 6 2 2 6 2 2 6
45962 - 2 2 6 62 62 62 66 66 66 30 30 30
45963 - 10 10 10 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 0 0 0 0 0 0
45966 - 0 0 0 0 0 0 0 0 0 0 0 0
45967 - 0 0 0 0 0 0 0 0 0 0 0 0
45968 - 0 0 0 0 0 0 0 0 0 0 0 0
45969 - 0 0 0 0 0 0 0 0 0 0 0 0
45970 - 0 0 0 0 0 0 0 0 0 0 0 0
45971 - 0 0 0 0 0 0 0 0 0 0 0 0
45972 - 14 14 14 42 42 42 82 82 82 18 18 18
45973 - 2 2 6 2 2 6 2 2 6 10 10 10
45974 - 94 94 94 182 182 182 218 218 218 242 242 242
45975 -250 250 250 253 253 253 253 253 253 250 250 250
45976 -234 234 234 253 253 253 253 253 253 253 253 253
45977 -253 253 253 253 253 253 253 253 253 246 246 246
45978 -238 238 238 226 226 226 210 210 210 202 202 202
45979 -195 195 195 195 195 195 210 210 210 158 158 158
45980 - 6 6 6 14 14 14 50 50 50 14 14 14
45981 - 2 2 6 2 2 6 2 2 6 2 2 6
45982 - 2 2 6 6 6 6 86 86 86 46 46 46
45983 - 18 18 18 6 6 6 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 0 0 0 0 0 0
45986 - 0 0 0 0 0 0 0 0 0 0 0 0
45987 - 0 0 0 0 0 0 0 0 0 0 0 0
45988 - 0 0 0 0 0 0 0 0 0 0 0 0
45989 - 0 0 0 0 0 0 0 0 0 0 0 0
45990 - 0 0 0 0 0 0 0 0 0 0 0 0
45991 - 0 0 0 0 0 0 0 0 0 6 6 6
45992 - 22 22 22 54 54 54 70 70 70 2 2 6
45993 - 2 2 6 10 10 10 2 2 6 22 22 22
45994 -166 166 166 231 231 231 250 250 250 253 253 253
45995 -253 253 253 253 253 253 253 253 253 250 250 250
45996 -242 242 242 253 253 253 253 253 253 253 253 253
45997 -253 253 253 253 253 253 253 253 253 253 253 253
45998 -253 253 253 253 253 253 253 253 253 246 246 246
45999 -231 231 231 206 206 206 198 198 198 226 226 226
46000 - 94 94 94 2 2 6 6 6 6 38 38 38
46001 - 30 30 30 2 2 6 2 2 6 2 2 6
46002 - 2 2 6 2 2 6 62 62 62 66 66 66
46003 - 26 26 26 10 10 10 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 0 0 0 0 0 0 0 0 0
46006 - 0 0 0 0 0 0 0 0 0 0 0 0
46007 - 0 0 0 0 0 0 0 0 0 0 0 0
46008 - 0 0 0 0 0 0 0 0 0 0 0 0
46009 - 0 0 0 0 0 0 0 0 0 0 0 0
46010 - 0 0 0 0 0 0 0 0 0 0 0 0
46011 - 0 0 0 0 0 0 0 0 0 10 10 10
46012 - 30 30 30 74 74 74 50 50 50 2 2 6
46013 - 26 26 26 26 26 26 2 2 6 106 106 106
46014 -238 238 238 253 253 253 253 253 253 253 253 253
46015 -253 253 253 253 253 253 253 253 253 253 253 253
46016 -253 253 253 253 253 253 253 253 253 253 253 253
46017 -253 253 253 253 253 253 253 253 253 253 253 253
46018 -253 253 253 253 253 253 253 253 253 253 253 253
46019 -253 253 253 246 246 246 218 218 218 202 202 202
46020 -210 210 210 14 14 14 2 2 6 2 2 6
46021 - 30 30 30 22 22 22 2 2 6 2 2 6
46022 - 2 2 6 2 2 6 18 18 18 86 86 86
46023 - 42 42 42 14 14 14 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 0 0 0 0 0 0 0 0 0
46026 - 0 0 0 0 0 0 0 0 0 0 0 0
46027 - 0 0 0 0 0 0 0 0 0 0 0 0
46028 - 0 0 0 0 0 0 0 0 0 0 0 0
46029 - 0 0 0 0 0 0 0 0 0 0 0 0
46030 - 0 0 0 0 0 0 0 0 0 0 0 0
46031 - 0 0 0 0 0 0 0 0 0 14 14 14
46032 - 42 42 42 90 90 90 22 22 22 2 2 6
46033 - 42 42 42 2 2 6 18 18 18 218 218 218
46034 -253 253 253 253 253 253 253 253 253 253 253 253
46035 -253 253 253 253 253 253 253 253 253 253 253 253
46036 -253 253 253 253 253 253 253 253 253 253 253 253
46037 -253 253 253 253 253 253 253 253 253 253 253 253
46038 -253 253 253 253 253 253 253 253 253 253 253 253
46039 -253 253 253 253 253 253 250 250 250 221 221 221
46040 -218 218 218 101 101 101 2 2 6 14 14 14
46041 - 18 18 18 38 38 38 10 10 10 2 2 6
46042 - 2 2 6 2 2 6 2 2 6 78 78 78
46043 - 58 58 58 22 22 22 6 6 6 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 0 0 0 0 0 0 0 0 0 0 0 0
46046 - 0 0 0 0 0 0 0 0 0 0 0 0
46047 - 0 0 0 0 0 0 0 0 0 0 0 0
46048 - 0 0 0 0 0 0 0 0 0 0 0 0
46049 - 0 0 0 0 0 0 0 0 0 0 0 0
46050 - 0 0 0 0 0 0 0 0 0 0 0 0
46051 - 0 0 0 0 0 0 6 6 6 18 18 18
46052 - 54 54 54 82 82 82 2 2 6 26 26 26
46053 - 22 22 22 2 2 6 123 123 123 253 253 253
46054 -253 253 253 253 253 253 253 253 253 253 253 253
46055 -253 253 253 253 253 253 253 253 253 253 253 253
46056 -253 253 253 253 253 253 253 253 253 253 253 253
46057 -253 253 253 253 253 253 253 253 253 253 253 253
46058 -253 253 253 253 253 253 253 253 253 253 253 253
46059 -253 253 253 253 253 253 253 253 253 250 250 250
46060 -238 238 238 198 198 198 6 6 6 38 38 38
46061 - 58 58 58 26 26 26 38 38 38 2 2 6
46062 - 2 2 6 2 2 6 2 2 6 46 46 46
46063 - 78 78 78 30 30 30 10 10 10 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 0 0 0 0 0 0 0 0 0 0 0 0
46066 - 0 0 0 0 0 0 0 0 0 0 0 0
46067 - 0 0 0 0 0 0 0 0 0 0 0 0
46068 - 0 0 0 0 0 0 0 0 0 0 0 0
46069 - 0 0 0 0 0 0 0 0 0 0 0 0
46070 - 0 0 0 0 0 0 0 0 0 0 0 0
46071 - 0 0 0 0 0 0 10 10 10 30 30 30
46072 - 74 74 74 58 58 58 2 2 6 42 42 42
46073 - 2 2 6 22 22 22 231 231 231 253 253 253
46074 -253 253 253 253 253 253 253 253 253 253 253 253
46075 -253 253 253 253 253 253 253 253 253 250 250 250
46076 -253 253 253 253 253 253 253 253 253 253 253 253
46077 -253 253 253 253 253 253 253 253 253 253 253 253
46078 -253 253 253 253 253 253 253 253 253 253 253 253
46079 -253 253 253 253 253 253 253 253 253 253 253 253
46080 -253 253 253 246 246 246 46 46 46 38 38 38
46081 - 42 42 42 14 14 14 38 38 38 14 14 14
46082 - 2 2 6 2 2 6 2 2 6 6 6 6
46083 - 86 86 86 46 46 46 14 14 14 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 0 0 0
46085 - 0 0 0 0 0 0 0 0 0 0 0 0
46086 - 0 0 0 0 0 0 0 0 0 0 0 0
46087 - 0 0 0 0 0 0 0 0 0 0 0 0
46088 - 0 0 0 0 0 0 0 0 0 0 0 0
46089 - 0 0 0 0 0 0 0 0 0 0 0 0
46090 - 0 0 0 0 0 0 0 0 0 0 0 0
46091 - 0 0 0 6 6 6 14 14 14 42 42 42
46092 - 90 90 90 18 18 18 18 18 18 26 26 26
46093 - 2 2 6 116 116 116 253 253 253 253 253 253
46094 -253 253 253 253 253 253 253 253 253 253 253 253
46095 -253 253 253 253 253 253 250 250 250 238 238 238
46096 -253 253 253 253 253 253 253 253 253 253 253 253
46097 -253 253 253 253 253 253 253 253 253 253 253 253
46098 -253 253 253 253 253 253 253 253 253 253 253 253
46099 -253 253 253 253 253 253 253 253 253 253 253 253
46100 -253 253 253 253 253 253 94 94 94 6 6 6
46101 - 2 2 6 2 2 6 10 10 10 34 34 34
46102 - 2 2 6 2 2 6 2 2 6 2 2 6
46103 - 74 74 74 58 58 58 22 22 22 6 6 6
46104 - 0 0 0 0 0 0 0 0 0 0 0 0
46105 - 0 0 0 0 0 0 0 0 0 0 0 0
46106 - 0 0 0 0 0 0 0 0 0 0 0 0
46107 - 0 0 0 0 0 0 0 0 0 0 0 0
46108 - 0 0 0 0 0 0 0 0 0 0 0 0
46109 - 0 0 0 0 0 0 0 0 0 0 0 0
46110 - 0 0 0 0 0 0 0 0 0 0 0 0
46111 - 0 0 0 10 10 10 26 26 26 66 66 66
46112 - 82 82 82 2 2 6 38 38 38 6 6 6
46113 - 14 14 14 210 210 210 253 253 253 253 253 253
46114 -253 253 253 253 253 253 253 253 253 253 253 253
46115 -253 253 253 253 253 253 246 246 246 242 242 242
46116 -253 253 253 253 253 253 253 253 253 253 253 253
46117 -253 253 253 253 253 253 253 253 253 253 253 253
46118 -253 253 253 253 253 253 253 253 253 253 253 253
46119 -253 253 253 253 253 253 253 253 253 253 253 253
46120 -253 253 253 253 253 253 144 144 144 2 2 6
46121 - 2 2 6 2 2 6 2 2 6 46 46 46
46122 - 2 2 6 2 2 6 2 2 6 2 2 6
46123 - 42 42 42 74 74 74 30 30 30 10 10 10
46124 - 0 0 0 0 0 0 0 0 0 0 0 0
46125 - 0 0 0 0 0 0 0 0 0 0 0 0
46126 - 0 0 0 0 0 0 0 0 0 0 0 0
46127 - 0 0 0 0 0 0 0 0 0 0 0 0
46128 - 0 0 0 0 0 0 0 0 0 0 0 0
46129 - 0 0 0 0 0 0 0 0 0 0 0 0
46130 - 0 0 0 0 0 0 0 0 0 0 0 0
46131 - 6 6 6 14 14 14 42 42 42 90 90 90
46132 - 26 26 26 6 6 6 42 42 42 2 2 6
46133 - 74 74 74 250 250 250 253 253 253 253 253 253
46134 -253 253 253 253 253 253 253 253 253 253 253 253
46135 -253 253 253 253 253 253 242 242 242 242 242 242
46136 -253 253 253 253 253 253 253 253 253 253 253 253
46137 -253 253 253 253 253 253 253 253 253 253 253 253
46138 -253 253 253 253 253 253 253 253 253 253 253 253
46139 -253 253 253 253 253 253 253 253 253 253 253 253
46140 -253 253 253 253 253 253 182 182 182 2 2 6
46141 - 2 2 6 2 2 6 2 2 6 46 46 46
46142 - 2 2 6 2 2 6 2 2 6 2 2 6
46143 - 10 10 10 86 86 86 38 38 38 10 10 10
46144 - 0 0 0 0 0 0 0 0 0 0 0 0
46145 - 0 0 0 0 0 0 0 0 0 0 0 0
46146 - 0 0 0 0 0 0 0 0 0 0 0 0
46147 - 0 0 0 0 0 0 0 0 0 0 0 0
46148 - 0 0 0 0 0 0 0 0 0 0 0 0
46149 - 0 0 0 0 0 0 0 0 0 0 0 0
46150 - 0 0 0 0 0 0 0 0 0 0 0 0
46151 - 10 10 10 26 26 26 66 66 66 82 82 82
46152 - 2 2 6 22 22 22 18 18 18 2 2 6
46153 -149 149 149 253 253 253 253 253 253 253 253 253
46154 -253 253 253 253 253 253 253 253 253 253 253 253
46155 -253 253 253 253 253 253 234 234 234 242 242 242
46156 -253 253 253 253 253 253 253 253 253 253 253 253
46157 -253 253 253 253 253 253 253 253 253 253 253 253
46158 -253 253 253 253 253 253 253 253 253 253 253 253
46159 -253 253 253 253 253 253 253 253 253 253 253 253
46160 -253 253 253 253 253 253 206 206 206 2 2 6
46161 - 2 2 6 2 2 6 2 2 6 38 38 38
46162 - 2 2 6 2 2 6 2 2 6 2 2 6
46163 - 6 6 6 86 86 86 46 46 46 14 14 14
46164 - 0 0 0 0 0 0 0 0 0 0 0 0
46165 - 0 0 0 0 0 0 0 0 0 0 0 0
46166 - 0 0 0 0 0 0 0 0 0 0 0 0
46167 - 0 0 0 0 0 0 0 0 0 0 0 0
46168 - 0 0 0 0 0 0 0 0 0 0 0 0
46169 - 0 0 0 0 0 0 0 0 0 0 0 0
46170 - 0 0 0 0 0 0 0 0 0 6 6 6
46171 - 18 18 18 46 46 46 86 86 86 18 18 18
46172 - 2 2 6 34 34 34 10 10 10 6 6 6
46173 -210 210 210 253 253 253 253 253 253 253 253 253
46174 -253 253 253 253 253 253 253 253 253 253 253 253
46175 -253 253 253 253 253 253 234 234 234 242 242 242
46176 -253 253 253 253 253 253 253 253 253 253 253 253
46177 -253 253 253 253 253 253 253 253 253 253 253 253
46178 -253 253 253 253 253 253 253 253 253 253 253 253
46179 -253 253 253 253 253 253 253 253 253 253 253 253
46180 -253 253 253 253 253 253 221 221 221 6 6 6
46181 - 2 2 6 2 2 6 6 6 6 30 30 30
46182 - 2 2 6 2 2 6 2 2 6 2 2 6
46183 - 2 2 6 82 82 82 54 54 54 18 18 18
46184 - 6 6 6 0 0 0 0 0 0 0 0 0
46185 - 0 0 0 0 0 0 0 0 0 0 0 0
46186 - 0 0 0 0 0 0 0 0 0 0 0 0
46187 - 0 0 0 0 0 0 0 0 0 0 0 0
46188 - 0 0 0 0 0 0 0 0 0 0 0 0
46189 - 0 0 0 0 0 0 0 0 0 0 0 0
46190 - 0 0 0 0 0 0 0 0 0 10 10 10
46191 - 26 26 26 66 66 66 62 62 62 2 2 6
46192 - 2 2 6 38 38 38 10 10 10 26 26 26
46193 -238 238 238 253 253 253 253 253 253 253 253 253
46194 -253 253 253 253 253 253 253 253 253 253 253 253
46195 -253 253 253 253 253 253 231 231 231 238 238 238
46196 -253 253 253 253 253 253 253 253 253 253 253 253
46197 -253 253 253 253 253 253 253 253 253 253 253 253
46198 -253 253 253 253 253 253 253 253 253 253 253 253
46199 -253 253 253 253 253 253 253 253 253 253 253 253
46200 -253 253 253 253 253 253 231 231 231 6 6 6
46201 - 2 2 6 2 2 6 10 10 10 30 30 30
46202 - 2 2 6 2 2 6 2 2 6 2 2 6
46203 - 2 2 6 66 66 66 58 58 58 22 22 22
46204 - 6 6 6 0 0 0 0 0 0 0 0 0
46205 - 0 0 0 0 0 0 0 0 0 0 0 0
46206 - 0 0 0 0 0 0 0 0 0 0 0 0
46207 - 0 0 0 0 0 0 0 0 0 0 0 0
46208 - 0 0 0 0 0 0 0 0 0 0 0 0
46209 - 0 0 0 0 0 0 0 0 0 0 0 0
46210 - 0 0 0 0 0 0 0 0 0 10 10 10
46211 - 38 38 38 78 78 78 6 6 6 2 2 6
46212 - 2 2 6 46 46 46 14 14 14 42 42 42
46213 -246 246 246 253 253 253 253 253 253 253 253 253
46214 -253 253 253 253 253 253 253 253 253 253 253 253
46215 -253 253 253 253 253 253 231 231 231 242 242 242
46216 -253 253 253 253 253 253 253 253 253 253 253 253
46217 -253 253 253 253 253 253 253 253 253 253 253 253
46218 -253 253 253 253 253 253 253 253 253 253 253 253
46219 -253 253 253 253 253 253 253 253 253 253 253 253
46220 -253 253 253 253 253 253 234 234 234 10 10 10
46221 - 2 2 6 2 2 6 22 22 22 14 14 14
46222 - 2 2 6 2 2 6 2 2 6 2 2 6
46223 - 2 2 6 66 66 66 62 62 62 22 22 22
46224 - 6 6 6 0 0 0 0 0 0 0 0 0
46225 - 0 0 0 0 0 0 0 0 0 0 0 0
46226 - 0 0 0 0 0 0 0 0 0 0 0 0
46227 - 0 0 0 0 0 0 0 0 0 0 0 0
46228 - 0 0 0 0 0 0 0 0 0 0 0 0
46229 - 0 0 0 0 0 0 0 0 0 0 0 0
46230 - 0 0 0 0 0 0 6 6 6 18 18 18
46231 - 50 50 50 74 74 74 2 2 6 2 2 6
46232 - 14 14 14 70 70 70 34 34 34 62 62 62
46233 -250 250 250 253 253 253 253 253 253 253 253 253
46234 -253 253 253 253 253 253 253 253 253 253 253 253
46235 -253 253 253 253 253 253 231 231 231 246 246 246
46236 -253 253 253 253 253 253 253 253 253 253 253 253
46237 -253 253 253 253 253 253 253 253 253 253 253 253
46238 -253 253 253 253 253 253 253 253 253 253 253 253
46239 -253 253 253 253 253 253 253 253 253 253 253 253
46240 -253 253 253 253 253 253 234 234 234 14 14 14
46241 - 2 2 6 2 2 6 30 30 30 2 2 6
46242 - 2 2 6 2 2 6 2 2 6 2 2 6
46243 - 2 2 6 66 66 66 62 62 62 22 22 22
46244 - 6 6 6 0 0 0 0 0 0 0 0 0
46245 - 0 0 0 0 0 0 0 0 0 0 0 0
46246 - 0 0 0 0 0 0 0 0 0 0 0 0
46247 - 0 0 0 0 0 0 0 0 0 0 0 0
46248 - 0 0 0 0 0 0 0 0 0 0 0 0
46249 - 0 0 0 0 0 0 0 0 0 0 0 0
46250 - 0 0 0 0 0 0 6 6 6 18 18 18
46251 - 54 54 54 62 62 62 2 2 6 2 2 6
46252 - 2 2 6 30 30 30 46 46 46 70 70 70
46253 -250 250 250 253 253 253 253 253 253 253 253 253
46254 -253 253 253 253 253 253 253 253 253 253 253 253
46255 -253 253 253 253 253 253 231 231 231 246 246 246
46256 -253 253 253 253 253 253 253 253 253 253 253 253
46257 -253 253 253 253 253 253 253 253 253 253 253 253
46258 -253 253 253 253 253 253 253 253 253 253 253 253
46259 -253 253 253 253 253 253 253 253 253 253 253 253
46260 -253 253 253 253 253 253 226 226 226 10 10 10
46261 - 2 2 6 6 6 6 30 30 30 2 2 6
46262 - 2 2 6 2 2 6 2 2 6 2 2 6
46263 - 2 2 6 66 66 66 58 58 58 22 22 22
46264 - 6 6 6 0 0 0 0 0 0 0 0 0
46265 - 0 0 0 0 0 0 0 0 0 0 0 0
46266 - 0 0 0 0 0 0 0 0 0 0 0 0
46267 - 0 0 0 0 0 0 0 0 0 0 0 0
46268 - 0 0 0 0 0 0 0 0 0 0 0 0
46269 - 0 0 0 0 0 0 0 0 0 0 0 0
46270 - 0 0 0 0 0 0 6 6 6 22 22 22
46271 - 58 58 58 62 62 62 2 2 6 2 2 6
46272 - 2 2 6 2 2 6 30 30 30 78 78 78
46273 -250 250 250 253 253 253 253 253 253 253 253 253
46274 -253 253 253 253 253 253 253 253 253 253 253 253
46275 -253 253 253 253 253 253 231 231 231 246 246 246
46276 -253 253 253 253 253 253 253 253 253 253 253 253
46277 -253 253 253 253 253 253 253 253 253 253 253 253
46278 -253 253 253 253 253 253 253 253 253 253 253 253
46279 -253 253 253 253 253 253 253 253 253 253 253 253
46280 -253 253 253 253 253 253 206 206 206 2 2 6
46281 - 22 22 22 34 34 34 18 14 6 22 22 22
46282 - 26 26 26 18 18 18 6 6 6 2 2 6
46283 - 2 2 6 82 82 82 54 54 54 18 18 18
46284 - 6 6 6 0 0 0 0 0 0 0 0 0
46285 - 0 0 0 0 0 0 0 0 0 0 0 0
46286 - 0 0 0 0 0 0 0 0 0 0 0 0
46287 - 0 0 0 0 0 0 0 0 0 0 0 0
46288 - 0 0 0 0 0 0 0 0 0 0 0 0
46289 - 0 0 0 0 0 0 0 0 0 0 0 0
46290 - 0 0 0 0 0 0 6 6 6 26 26 26
46291 - 62 62 62 106 106 106 74 54 14 185 133 11
46292 -210 162 10 121 92 8 6 6 6 62 62 62
46293 -238 238 238 253 253 253 253 253 253 253 253 253
46294 -253 253 253 253 253 253 253 253 253 253 253 253
46295 -253 253 253 253 253 253 231 231 231 246 246 246
46296 -253 253 253 253 253 253 253 253 253 253 253 253
46297 -253 253 253 253 253 253 253 253 253 253 253 253
46298 -253 253 253 253 253 253 253 253 253 253 253 253
46299 -253 253 253 253 253 253 253 253 253 253 253 253
46300 -253 253 253 253 253 253 158 158 158 18 18 18
46301 - 14 14 14 2 2 6 2 2 6 2 2 6
46302 - 6 6 6 18 18 18 66 66 66 38 38 38
46303 - 6 6 6 94 94 94 50 50 50 18 18 18
46304 - 6 6 6 0 0 0 0 0 0 0 0 0
46305 - 0 0 0 0 0 0 0 0 0 0 0 0
46306 - 0 0 0 0 0 0 0 0 0 0 0 0
46307 - 0 0 0 0 0 0 0 0 0 0 0 0
46308 - 0 0 0 0 0 0 0 0 0 0 0 0
46309 - 0 0 0 0 0 0 0 0 0 6 6 6
46310 - 10 10 10 10 10 10 18 18 18 38 38 38
46311 - 78 78 78 142 134 106 216 158 10 242 186 14
46312 -246 190 14 246 190 14 156 118 10 10 10 10
46313 - 90 90 90 238 238 238 253 253 253 253 253 253
46314 -253 253 253 253 253 253 253 253 253 253 253 253
46315 -253 253 253 253 253 253 231 231 231 250 250 250
46316 -253 253 253 253 253 253 253 253 253 253 253 253
46317 -253 253 253 253 253 253 253 253 253 253 253 253
46318 -253 253 253 253 253 253 253 253 253 253 253 253
46319 -253 253 253 253 253 253 253 253 253 246 230 190
46320 -238 204 91 238 204 91 181 142 44 37 26 9
46321 - 2 2 6 2 2 6 2 2 6 2 2 6
46322 - 2 2 6 2 2 6 38 38 38 46 46 46
46323 - 26 26 26 106 106 106 54 54 54 18 18 18
46324 - 6 6 6 0 0 0 0 0 0 0 0 0
46325 - 0 0 0 0 0 0 0 0 0 0 0 0
46326 - 0 0 0 0 0 0 0 0 0 0 0 0
46327 - 0 0 0 0 0 0 0 0 0 0 0 0
46328 - 0 0 0 0 0 0 0 0 0 0 0 0
46329 - 0 0 0 6 6 6 14 14 14 22 22 22
46330 - 30 30 30 38 38 38 50 50 50 70 70 70
46331 -106 106 106 190 142 34 226 170 11 242 186 14
46332 -246 190 14 246 190 14 246 190 14 154 114 10
46333 - 6 6 6 74 74 74 226 226 226 253 253 253
46334 -253 253 253 253 253 253 253 253 253 253 253 253
46335 -253 253 253 253 253 253 231 231 231 250 250 250
46336 -253 253 253 253 253 253 253 253 253 253 253 253
46337 -253 253 253 253 253 253 253 253 253 253 253 253
46338 -253 253 253 253 253 253 253 253 253 253 253 253
46339 -253 253 253 253 253 253 253 253 253 228 184 62
46340 -241 196 14 241 208 19 232 195 16 38 30 10
46341 - 2 2 6 2 2 6 2 2 6 2 2 6
46342 - 2 2 6 6 6 6 30 30 30 26 26 26
46343 -203 166 17 154 142 90 66 66 66 26 26 26
46344 - 6 6 6 0 0 0 0 0 0 0 0 0
46345 - 0 0 0 0 0 0 0 0 0 0 0 0
46346 - 0 0 0 0 0 0 0 0 0 0 0 0
46347 - 0 0 0 0 0 0 0 0 0 0 0 0
46348 - 0 0 0 0 0 0 0 0 0 0 0 0
46349 - 6 6 6 18 18 18 38 38 38 58 58 58
46350 - 78 78 78 86 86 86 101 101 101 123 123 123
46351 -175 146 61 210 150 10 234 174 13 246 186 14
46352 -246 190 14 246 190 14 246 190 14 238 190 10
46353 -102 78 10 2 2 6 46 46 46 198 198 198
46354 -253 253 253 253 253 253 253 253 253 253 253 253
46355 -253 253 253 253 253 253 234 234 234 242 242 242
46356 -253 253 253 253 253 253 253 253 253 253 253 253
46357 -253 253 253 253 253 253 253 253 253 253 253 253
46358 -253 253 253 253 253 253 253 253 253 253 253 253
46359 -253 253 253 253 253 253 253 253 253 224 178 62
46360 -242 186 14 241 196 14 210 166 10 22 18 6
46361 - 2 2 6 2 2 6 2 2 6 2 2 6
46362 - 2 2 6 2 2 6 6 6 6 121 92 8
46363 -238 202 15 232 195 16 82 82 82 34 34 34
46364 - 10 10 10 0 0 0 0 0 0 0 0 0
46365 - 0 0 0 0 0 0 0 0 0 0 0 0
46366 - 0 0 0 0 0 0 0 0 0 0 0 0
46367 - 0 0 0 0 0 0 0 0 0 0 0 0
46368 - 0 0 0 0 0 0 0 0 0 0 0 0
46369 - 14 14 14 38 38 38 70 70 70 154 122 46
46370 -190 142 34 200 144 11 197 138 11 197 138 11
46371 -213 154 11 226 170 11 242 186 14 246 190 14
46372 -246 190 14 246 190 14 246 190 14 246 190 14
46373 -225 175 15 46 32 6 2 2 6 22 22 22
46374 -158 158 158 250 250 250 253 253 253 253 253 253
46375 -253 253 253 253 253 253 253 253 253 253 253 253
46376 -253 253 253 253 253 253 253 253 253 253 253 253
46377 -253 253 253 253 253 253 253 253 253 253 253 253
46378 -253 253 253 253 253 253 253 253 253 253 253 253
46379 -253 253 253 250 250 250 242 242 242 224 178 62
46380 -239 182 13 236 186 11 213 154 11 46 32 6
46381 - 2 2 6 2 2 6 2 2 6 2 2 6
46382 - 2 2 6 2 2 6 61 42 6 225 175 15
46383 -238 190 10 236 186 11 112 100 78 42 42 42
46384 - 14 14 14 0 0 0 0 0 0 0 0 0
46385 - 0 0 0 0 0 0 0 0 0 0 0 0
46386 - 0 0 0 0 0 0 0 0 0 0 0 0
46387 - 0 0 0 0 0 0 0 0 0 0 0 0
46388 - 0 0 0 0 0 0 0 0 0 6 6 6
46389 - 22 22 22 54 54 54 154 122 46 213 154 11
46390 -226 170 11 230 174 11 226 170 11 226 170 11
46391 -236 178 12 242 186 14 246 190 14 246 190 14
46392 -246 190 14 246 190 14 246 190 14 246 190 14
46393 -241 196 14 184 144 12 10 10 10 2 2 6
46394 - 6 6 6 116 116 116 242 242 242 253 253 253
46395 -253 253 253 253 253 253 253 253 253 253 253 253
46396 -253 253 253 253 253 253 253 253 253 253 253 253
46397 -253 253 253 253 253 253 253 253 253 253 253 253
46398 -253 253 253 253 253 253 253 253 253 253 253 253
46399 -253 253 253 231 231 231 198 198 198 214 170 54
46400 -236 178 12 236 178 12 210 150 10 137 92 6
46401 - 18 14 6 2 2 6 2 2 6 2 2 6
46402 - 6 6 6 70 47 6 200 144 11 236 178 12
46403 -239 182 13 239 182 13 124 112 88 58 58 58
46404 - 22 22 22 6 6 6 0 0 0 0 0 0
46405 - 0 0 0 0 0 0 0 0 0 0 0 0
46406 - 0 0 0 0 0 0 0 0 0 0 0 0
46407 - 0 0 0 0 0 0 0 0 0 0 0 0
46408 - 0 0 0 0 0 0 0 0 0 10 10 10
46409 - 30 30 30 70 70 70 180 133 36 226 170 11
46410 -239 182 13 242 186 14 242 186 14 246 186 14
46411 -246 190 14 246 190 14 246 190 14 246 190 14
46412 -246 190 14 246 190 14 246 190 14 246 190 14
46413 -246 190 14 232 195 16 98 70 6 2 2 6
46414 - 2 2 6 2 2 6 66 66 66 221 221 221
46415 -253 253 253 253 253 253 253 253 253 253 253 253
46416 -253 253 253 253 253 253 253 253 253 253 253 253
46417 -253 253 253 253 253 253 253 253 253 253 253 253
46418 -253 253 253 253 253 253 253 253 253 253 253 253
46419 -253 253 253 206 206 206 198 198 198 214 166 58
46420 -230 174 11 230 174 11 216 158 10 192 133 9
46421 -163 110 8 116 81 8 102 78 10 116 81 8
46422 -167 114 7 197 138 11 226 170 11 239 182 13
46423 -242 186 14 242 186 14 162 146 94 78 78 78
46424 - 34 34 34 14 14 14 6 6 6 0 0 0
46425 - 0 0 0 0 0 0 0 0 0 0 0 0
46426 - 0 0 0 0 0 0 0 0 0 0 0 0
46427 - 0 0 0 0 0 0 0 0 0 0 0 0
46428 - 0 0 0 0 0 0 0 0 0 6 6 6
46429 - 30 30 30 78 78 78 190 142 34 226 170 11
46430 -239 182 13 246 190 14 246 190 14 246 190 14
46431 -246 190 14 246 190 14 246 190 14 246 190 14
46432 -246 190 14 246 190 14 246 190 14 246 190 14
46433 -246 190 14 241 196 14 203 166 17 22 18 6
46434 - 2 2 6 2 2 6 2 2 6 38 38 38
46435 -218 218 218 253 253 253 253 253 253 253 253 253
46436 -253 253 253 253 253 253 253 253 253 253 253 253
46437 -253 253 253 253 253 253 253 253 253 253 253 253
46438 -253 253 253 253 253 253 253 253 253 253 253 253
46439 -250 250 250 206 206 206 198 198 198 202 162 69
46440 -226 170 11 236 178 12 224 166 10 210 150 10
46441 -200 144 11 197 138 11 192 133 9 197 138 11
46442 -210 150 10 226 170 11 242 186 14 246 190 14
46443 -246 190 14 246 186 14 225 175 15 124 112 88
46444 - 62 62 62 30 30 30 14 14 14 6 6 6
46445 - 0 0 0 0 0 0 0 0 0 0 0 0
46446 - 0 0 0 0 0 0 0 0 0 0 0 0
46447 - 0 0 0 0 0 0 0 0 0 0 0 0
46448 - 0 0 0 0 0 0 0 0 0 10 10 10
46449 - 30 30 30 78 78 78 174 135 50 224 166 10
46450 -239 182 13 246 190 14 246 190 14 246 190 14
46451 -246 190 14 246 190 14 246 190 14 246 190 14
46452 -246 190 14 246 190 14 246 190 14 246 190 14
46453 -246 190 14 246 190 14 241 196 14 139 102 15
46454 - 2 2 6 2 2 6 2 2 6 2 2 6
46455 - 78 78 78 250 250 250 253 253 253 253 253 253
46456 -253 253 253 253 253 253 253 253 253 253 253 253
46457 -253 253 253 253 253 253 253 253 253 253 253 253
46458 -253 253 253 253 253 253 253 253 253 253 253 253
46459 -250 250 250 214 214 214 198 198 198 190 150 46
46460 -219 162 10 236 178 12 234 174 13 224 166 10
46461 -216 158 10 213 154 11 213 154 11 216 158 10
46462 -226 170 11 239 182 13 246 190 14 246 190 14
46463 -246 190 14 246 190 14 242 186 14 206 162 42
46464 -101 101 101 58 58 58 30 30 30 14 14 14
46465 - 6 6 6 0 0 0 0 0 0 0 0 0
46466 - 0 0 0 0 0 0 0 0 0 0 0 0
46467 - 0 0 0 0 0 0 0 0 0 0 0 0
46468 - 0 0 0 0 0 0 0 0 0 10 10 10
46469 - 30 30 30 74 74 74 174 135 50 216 158 10
46470 -236 178 12 246 190 14 246 190 14 246 190 14
46471 -246 190 14 246 190 14 246 190 14 246 190 14
46472 -246 190 14 246 190 14 246 190 14 246 190 14
46473 -246 190 14 246 190 14 241 196 14 226 184 13
46474 - 61 42 6 2 2 6 2 2 6 2 2 6
46475 - 22 22 22 238 238 238 253 253 253 253 253 253
46476 -253 253 253 253 253 253 253 253 253 253 253 253
46477 -253 253 253 253 253 253 253 253 253 253 253 253
46478 -253 253 253 253 253 253 253 253 253 253 253 253
46479 -253 253 253 226 226 226 187 187 187 180 133 36
46480 -216 158 10 236 178 12 239 182 13 236 178 12
46481 -230 174 11 226 170 11 226 170 11 230 174 11
46482 -236 178 12 242 186 14 246 190 14 246 190 14
46483 -246 190 14 246 190 14 246 186 14 239 182 13
46484 -206 162 42 106 106 106 66 66 66 34 34 34
46485 - 14 14 14 6 6 6 0 0 0 0 0 0
46486 - 0 0 0 0 0 0 0 0 0 0 0 0
46487 - 0 0 0 0 0 0 0 0 0 0 0 0
46488 - 0 0 0 0 0 0 0 0 0 6 6 6
46489 - 26 26 26 70 70 70 163 133 67 213 154 11
46490 -236 178 12 246 190 14 246 190 14 246 190 14
46491 -246 190 14 246 190 14 246 190 14 246 190 14
46492 -246 190 14 246 190 14 246 190 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 241 196 14
46494 -190 146 13 18 14 6 2 2 6 2 2 6
46495 - 46 46 46 246 246 246 253 253 253 253 253 253
46496 -253 253 253 253 253 253 253 253 253 253 253 253
46497 -253 253 253 253 253 253 253 253 253 253 253 253
46498 -253 253 253 253 253 253 253 253 253 253 253 253
46499 -253 253 253 221 221 221 86 86 86 156 107 11
46500 -216 158 10 236 178 12 242 186 14 246 186 14
46501 -242 186 14 239 182 13 239 182 13 242 186 14
46502 -242 186 14 246 186 14 246 190 14 246 190 14
46503 -246 190 14 246 190 14 246 190 14 246 190 14
46504 -242 186 14 225 175 15 142 122 72 66 66 66
46505 - 30 30 30 10 10 10 0 0 0 0 0 0
46506 - 0 0 0 0 0 0 0 0 0 0 0 0
46507 - 0 0 0 0 0 0 0 0 0 0 0 0
46508 - 0 0 0 0 0 0 0 0 0 6 6 6
46509 - 26 26 26 70 70 70 163 133 67 210 150 10
46510 -236 178 12 246 190 14 246 190 14 246 190 14
46511 -246 190 14 246 190 14 246 190 14 246 190 14
46512 -246 190 14 246 190 14 246 190 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -232 195 16 121 92 8 34 34 34 106 106 106
46515 -221 221 221 253 253 253 253 253 253 253 253 253
46516 -253 253 253 253 253 253 253 253 253 253 253 253
46517 -253 253 253 253 253 253 253 253 253 253 253 253
46518 -253 253 253 253 253 253 253 253 253 253 253 253
46519 -242 242 242 82 82 82 18 14 6 163 110 8
46520 -216 158 10 236 178 12 242 186 14 246 190 14
46521 -246 190 14 246 190 14 246 190 14 246 190 14
46522 -246 190 14 246 190 14 246 190 14 246 190 14
46523 -246 190 14 246 190 14 246 190 14 246 190 14
46524 -246 190 14 246 190 14 242 186 14 163 133 67
46525 - 46 46 46 18 18 18 6 6 6 0 0 0
46526 - 0 0 0 0 0 0 0 0 0 0 0 0
46527 - 0 0 0 0 0 0 0 0 0 0 0 0
46528 - 0 0 0 0 0 0 0 0 0 10 10 10
46529 - 30 30 30 78 78 78 163 133 67 210 150 10
46530 -236 178 12 246 186 14 246 190 14 246 190 14
46531 -246 190 14 246 190 14 246 190 14 246 190 14
46532 -246 190 14 246 190 14 246 190 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -241 196 14 215 174 15 190 178 144 253 253 253
46535 -253 253 253 253 253 253 253 253 253 253 253 253
46536 -253 253 253 253 253 253 253 253 253 253 253 253
46537 -253 253 253 253 253 253 253 253 253 253 253 253
46538 -253 253 253 253 253 253 253 253 253 218 218 218
46539 - 58 58 58 2 2 6 22 18 6 167 114 7
46540 -216 158 10 236 178 12 246 186 14 246 190 14
46541 -246 190 14 246 190 14 246 190 14 246 190 14
46542 -246 190 14 246 190 14 246 190 14 246 190 14
46543 -246 190 14 246 190 14 246 190 14 246 190 14
46544 -246 190 14 246 186 14 242 186 14 190 150 46
46545 - 54 54 54 22 22 22 6 6 6 0 0 0
46546 - 0 0 0 0 0 0 0 0 0 0 0 0
46547 - 0 0 0 0 0 0 0 0 0 0 0 0
46548 - 0 0 0 0 0 0 0 0 0 14 14 14
46549 - 38 38 38 86 86 86 180 133 36 213 154 11
46550 -236 178 12 246 186 14 246 190 14 246 190 14
46551 -246 190 14 246 190 14 246 190 14 246 190 14
46552 -246 190 14 246 190 14 246 190 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 190 14 232 195 16 190 146 13 214 214 214
46555 -253 253 253 253 253 253 253 253 253 253 253 253
46556 -253 253 253 253 253 253 253 253 253 253 253 253
46557 -253 253 253 253 253 253 253 253 253 253 253 253
46558 -253 253 253 250 250 250 170 170 170 26 26 26
46559 - 2 2 6 2 2 6 37 26 9 163 110 8
46560 -219 162 10 239 182 13 246 186 14 246 190 14
46561 -246 190 14 246 190 14 246 190 14 246 190 14
46562 -246 190 14 246 190 14 246 190 14 246 190 14
46563 -246 190 14 246 190 14 246 190 14 246 190 14
46564 -246 186 14 236 178 12 224 166 10 142 122 72
46565 - 46 46 46 18 18 18 6 6 6 0 0 0
46566 - 0 0 0 0 0 0 0 0 0 0 0 0
46567 - 0 0 0 0 0 0 0 0 0 0 0 0
46568 - 0 0 0 0 0 0 6 6 6 18 18 18
46569 - 50 50 50 109 106 95 192 133 9 224 166 10
46570 -242 186 14 246 190 14 246 190 14 246 190 14
46571 -246 190 14 246 190 14 246 190 14 246 190 14
46572 -246 190 14 246 190 14 246 190 14 246 190 14
46573 -246 190 14 246 190 14 246 190 14 246 190 14
46574 -242 186 14 226 184 13 210 162 10 142 110 46
46575 -226 226 226 253 253 253 253 253 253 253 253 253
46576 -253 253 253 253 253 253 253 253 253 253 253 253
46577 -253 253 253 253 253 253 253 253 253 253 253 253
46578 -198 198 198 66 66 66 2 2 6 2 2 6
46579 - 2 2 6 2 2 6 50 34 6 156 107 11
46580 -219 162 10 239 182 13 246 186 14 246 190 14
46581 -246 190 14 246 190 14 246 190 14 246 190 14
46582 -246 190 14 246 190 14 246 190 14 246 190 14
46583 -246 190 14 246 190 14 246 190 14 242 186 14
46584 -234 174 13 213 154 11 154 122 46 66 66 66
46585 - 30 30 30 10 10 10 0 0 0 0 0 0
46586 - 0 0 0 0 0 0 0 0 0 0 0 0
46587 - 0 0 0 0 0 0 0 0 0 0 0 0
46588 - 0 0 0 0 0 0 6 6 6 22 22 22
46589 - 58 58 58 154 121 60 206 145 10 234 174 13
46590 -242 186 14 246 186 14 246 190 14 246 190 14
46591 -246 190 14 246 190 14 246 190 14 246 190 14
46592 -246 190 14 246 190 14 246 190 14 246 190 14
46593 -246 190 14 246 190 14 246 190 14 246 190 14
46594 -246 186 14 236 178 12 210 162 10 163 110 8
46595 - 61 42 6 138 138 138 218 218 218 250 250 250
46596 -253 253 253 253 253 253 253 253 253 250 250 250
46597 -242 242 242 210 210 210 144 144 144 66 66 66
46598 - 6 6 6 2 2 6 2 2 6 2 2 6
46599 - 2 2 6 2 2 6 61 42 6 163 110 8
46600 -216 158 10 236 178 12 246 190 14 246 190 14
46601 -246 190 14 246 190 14 246 190 14 246 190 14
46602 -246 190 14 246 190 14 246 190 14 246 190 14
46603 -246 190 14 239 182 13 230 174 11 216 158 10
46604 -190 142 34 124 112 88 70 70 70 38 38 38
46605 - 18 18 18 6 6 6 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 0 0 0
46607 - 0 0 0 0 0 0 0 0 0 0 0 0
46608 - 0 0 0 0 0 0 6 6 6 22 22 22
46609 - 62 62 62 168 124 44 206 145 10 224 166 10
46610 -236 178 12 239 182 13 242 186 14 242 186 14
46611 -246 186 14 246 190 14 246 190 14 246 190 14
46612 -246 190 14 246 190 14 246 190 14 246 190 14
46613 -246 190 14 246 190 14 246 190 14 246 190 14
46614 -246 190 14 236 178 12 216 158 10 175 118 6
46615 - 80 54 7 2 2 6 6 6 6 30 30 30
46616 - 54 54 54 62 62 62 50 50 50 38 38 38
46617 - 14 14 14 2 2 6 2 2 6 2 2 6
46618 - 2 2 6 2 2 6 2 2 6 2 2 6
46619 - 2 2 6 6 6 6 80 54 7 167 114 7
46620 -213 154 11 236 178 12 246 190 14 246 190 14
46621 -246 190 14 246 190 14 246 190 14 246 190 14
46622 -246 190 14 242 186 14 239 182 13 239 182 13
46623 -230 174 11 210 150 10 174 135 50 124 112 88
46624 - 82 82 82 54 54 54 34 34 34 18 18 18
46625 - 6 6 6 0 0 0 0 0 0 0 0 0
46626 - 0 0 0 0 0 0 0 0 0 0 0 0
46627 - 0 0 0 0 0 0 0 0 0 0 0 0
46628 - 0 0 0 0 0 0 6 6 6 18 18 18
46629 - 50 50 50 158 118 36 192 133 9 200 144 11
46630 -216 158 10 219 162 10 224 166 10 226 170 11
46631 -230 174 11 236 178 12 239 182 13 239 182 13
46632 -242 186 14 246 186 14 246 190 14 246 190 14
46633 -246 190 14 246 190 14 246 190 14 246 190 14
46634 -246 186 14 230 174 11 210 150 10 163 110 8
46635 -104 69 6 10 10 10 2 2 6 2 2 6
46636 - 2 2 6 2 2 6 2 2 6 2 2 6
46637 - 2 2 6 2 2 6 2 2 6 2 2 6
46638 - 2 2 6 2 2 6 2 2 6 2 2 6
46639 - 2 2 6 6 6 6 91 60 6 167 114 7
46640 -206 145 10 230 174 11 242 186 14 246 190 14
46641 -246 190 14 246 190 14 246 186 14 242 186 14
46642 -239 182 13 230 174 11 224 166 10 213 154 11
46643 -180 133 36 124 112 88 86 86 86 58 58 58
46644 - 38 38 38 22 22 22 10 10 10 6 6 6
46645 - 0 0 0 0 0 0 0 0 0 0 0 0
46646 - 0 0 0 0 0 0 0 0 0 0 0 0
46647 - 0 0 0 0 0 0 0 0 0 0 0 0
46648 - 0 0 0 0 0 0 0 0 0 14 14 14
46649 - 34 34 34 70 70 70 138 110 50 158 118 36
46650 -167 114 7 180 123 7 192 133 9 197 138 11
46651 -200 144 11 206 145 10 213 154 11 219 162 10
46652 -224 166 10 230 174 11 239 182 13 242 186 14
46653 -246 186 14 246 186 14 246 186 14 246 186 14
46654 -239 182 13 216 158 10 185 133 11 152 99 6
46655 -104 69 6 18 14 6 2 2 6 2 2 6
46656 - 2 2 6 2 2 6 2 2 6 2 2 6
46657 - 2 2 6 2 2 6 2 2 6 2 2 6
46658 - 2 2 6 2 2 6 2 2 6 2 2 6
46659 - 2 2 6 6 6 6 80 54 7 152 99 6
46660 -192 133 9 219 162 10 236 178 12 239 182 13
46661 -246 186 14 242 186 14 239 182 13 236 178 12
46662 -224 166 10 206 145 10 192 133 9 154 121 60
46663 - 94 94 94 62 62 62 42 42 42 22 22 22
46664 - 14 14 14 6 6 6 0 0 0 0 0 0
46665 - 0 0 0 0 0 0 0 0 0 0 0 0
46666 - 0 0 0 0 0 0 0 0 0 0 0 0
46667 - 0 0 0 0 0 0 0 0 0 0 0 0
46668 - 0 0 0 0 0 0 0 0 0 6 6 6
46669 - 18 18 18 34 34 34 58 58 58 78 78 78
46670 -101 98 89 124 112 88 142 110 46 156 107 11
46671 -163 110 8 167 114 7 175 118 6 180 123 7
46672 -185 133 11 197 138 11 210 150 10 219 162 10
46673 -226 170 11 236 178 12 236 178 12 234 174 13
46674 -219 162 10 197 138 11 163 110 8 130 83 6
46675 - 91 60 6 10 10 10 2 2 6 2 2 6
46676 - 18 18 18 38 38 38 38 38 38 38 38 38
46677 - 38 38 38 38 38 38 38 38 38 38 38 38
46678 - 38 38 38 38 38 38 26 26 26 2 2 6
46679 - 2 2 6 6 6 6 70 47 6 137 92 6
46680 -175 118 6 200 144 11 219 162 10 230 174 11
46681 -234 174 13 230 174 11 219 162 10 210 150 10
46682 -192 133 9 163 110 8 124 112 88 82 82 82
46683 - 50 50 50 30 30 30 14 14 14 6 6 6
46684 - 0 0 0 0 0 0 0 0 0 0 0 0
46685 - 0 0 0 0 0 0 0 0 0 0 0 0
46686 - 0 0 0 0 0 0 0 0 0 0 0 0
46687 - 0 0 0 0 0 0 0 0 0 0 0 0
46688 - 0 0 0 0 0 0 0 0 0 0 0 0
46689 - 6 6 6 14 14 14 22 22 22 34 34 34
46690 - 42 42 42 58 58 58 74 74 74 86 86 86
46691 -101 98 89 122 102 70 130 98 46 121 87 25
46692 -137 92 6 152 99 6 163 110 8 180 123 7
46693 -185 133 11 197 138 11 206 145 10 200 144 11
46694 -180 123 7 156 107 11 130 83 6 104 69 6
46695 - 50 34 6 54 54 54 110 110 110 101 98 89
46696 - 86 86 86 82 82 82 78 78 78 78 78 78
46697 - 78 78 78 78 78 78 78 78 78 78 78 78
46698 - 78 78 78 82 82 82 86 86 86 94 94 94
46699 -106 106 106 101 101 101 86 66 34 124 80 6
46700 -156 107 11 180 123 7 192 133 9 200 144 11
46701 -206 145 10 200 144 11 192 133 9 175 118 6
46702 -139 102 15 109 106 95 70 70 70 42 42 42
46703 - 22 22 22 10 10 10 0 0 0 0 0 0
46704 - 0 0 0 0 0 0 0 0 0 0 0 0
46705 - 0 0 0 0 0 0 0 0 0 0 0 0
46706 - 0 0 0 0 0 0 0 0 0 0 0 0
46707 - 0 0 0 0 0 0 0 0 0 0 0 0
46708 - 0 0 0 0 0 0 0 0 0 0 0 0
46709 - 0 0 0 0 0 0 6 6 6 10 10 10
46710 - 14 14 14 22 22 22 30 30 30 38 38 38
46711 - 50 50 50 62 62 62 74 74 74 90 90 90
46712 -101 98 89 112 100 78 121 87 25 124 80 6
46713 -137 92 6 152 99 6 152 99 6 152 99 6
46714 -138 86 6 124 80 6 98 70 6 86 66 30
46715 -101 98 89 82 82 82 58 58 58 46 46 46
46716 - 38 38 38 34 34 34 34 34 34 34 34 34
46717 - 34 34 34 34 34 34 34 34 34 34 34 34
46718 - 34 34 34 34 34 34 38 38 38 42 42 42
46719 - 54 54 54 82 82 82 94 86 76 91 60 6
46720 -134 86 6 156 107 11 167 114 7 175 118 6
46721 -175 118 6 167 114 7 152 99 6 121 87 25
46722 -101 98 89 62 62 62 34 34 34 18 18 18
46723 - 6 6 6 0 0 0 0 0 0 0 0 0
46724 - 0 0 0 0 0 0 0 0 0 0 0 0
46725 - 0 0 0 0 0 0 0 0 0 0 0 0
46726 - 0 0 0 0 0 0 0 0 0 0 0 0
46727 - 0 0 0 0 0 0 0 0 0 0 0 0
46728 - 0 0 0 0 0 0 0 0 0 0 0 0
46729 - 0 0 0 0 0 0 0 0 0 0 0 0
46730 - 0 0 0 6 6 6 6 6 6 10 10 10
46731 - 18 18 18 22 22 22 30 30 30 42 42 42
46732 - 50 50 50 66 66 66 86 86 86 101 98 89
46733 -106 86 58 98 70 6 104 69 6 104 69 6
46734 -104 69 6 91 60 6 82 62 34 90 90 90
46735 - 62 62 62 38 38 38 22 22 22 14 14 14
46736 - 10 10 10 10 10 10 10 10 10 10 10 10
46737 - 10 10 10 10 10 10 6 6 6 10 10 10
46738 - 10 10 10 10 10 10 10 10 10 14 14 14
46739 - 22 22 22 42 42 42 70 70 70 89 81 66
46740 - 80 54 7 104 69 6 124 80 6 137 92 6
46741 -134 86 6 116 81 8 100 82 52 86 86 86
46742 - 58 58 58 30 30 30 14 14 14 6 6 6
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 0 0 0 0 0 0 0 0 0 0 0 0
46745 - 0 0 0 0 0 0 0 0 0 0 0 0
46746 - 0 0 0 0 0 0 0 0 0 0 0 0
46747 - 0 0 0 0 0 0 0 0 0 0 0 0
46748 - 0 0 0 0 0 0 0 0 0 0 0 0
46749 - 0 0 0 0 0 0 0 0 0 0 0 0
46750 - 0 0 0 0 0 0 0 0 0 0 0 0
46751 - 0 0 0 6 6 6 10 10 10 14 14 14
46752 - 18 18 18 26 26 26 38 38 38 54 54 54
46753 - 70 70 70 86 86 86 94 86 76 89 81 66
46754 - 89 81 66 86 86 86 74 74 74 50 50 50
46755 - 30 30 30 14 14 14 6 6 6 0 0 0
46756 - 0 0 0 0 0 0 0 0 0 0 0 0
46757 - 0 0 0 0 0 0 0 0 0 0 0 0
46758 - 0 0 0 0 0 0 0 0 0 0 0 0
46759 - 6 6 6 18 18 18 34 34 34 58 58 58
46760 - 82 82 82 89 81 66 89 81 66 89 81 66
46761 - 94 86 66 94 86 76 74 74 74 50 50 50
46762 - 26 26 26 14 14 14 6 6 6 0 0 0
46763 - 0 0 0 0 0 0 0 0 0 0 0 0
46764 - 0 0 0 0 0 0 0 0 0 0 0 0
46765 - 0 0 0 0 0 0 0 0 0 0 0 0
46766 - 0 0 0 0 0 0 0 0 0 0 0 0
46767 - 0 0 0 0 0 0 0 0 0 0 0 0
46768 - 0 0 0 0 0 0 0 0 0 0 0 0
46769 - 0 0 0 0 0 0 0 0 0 0 0 0
46770 - 0 0 0 0 0 0 0 0 0 0 0 0
46771 - 0 0 0 0 0 0 0 0 0 0 0 0
46772 - 6 6 6 6 6 6 14 14 14 18 18 18
46773 - 30 30 30 38 38 38 46 46 46 54 54 54
46774 - 50 50 50 42 42 42 30 30 30 18 18 18
46775 - 10 10 10 0 0 0 0 0 0 0 0 0
46776 - 0 0 0 0 0 0 0 0 0 0 0 0
46777 - 0 0 0 0 0 0 0 0 0 0 0 0
46778 - 0 0 0 0 0 0 0 0 0 0 0 0
46779 - 0 0 0 6 6 6 14 14 14 26 26 26
46780 - 38 38 38 50 50 50 58 58 58 58 58 58
46781 - 54 54 54 42 42 42 30 30 30 18 18 18
46782 - 10 10 10 0 0 0 0 0 0 0 0 0
46783 - 0 0 0 0 0 0 0 0 0 0 0 0
46784 - 0 0 0 0 0 0 0 0 0 0 0 0
46785 - 0 0 0 0 0 0 0 0 0 0 0 0
46786 - 0 0 0 0 0 0 0 0 0 0 0 0
46787 - 0 0 0 0 0 0 0 0 0 0 0 0
46788 - 0 0 0 0 0 0 0 0 0 0 0 0
46789 - 0 0 0 0 0 0 0 0 0 0 0 0
46790 - 0 0 0 0 0 0 0 0 0 0 0 0
46791 - 0 0 0 0 0 0 0 0 0 0 0 0
46792 - 0 0 0 0 0 0 0 0 0 6 6 6
46793 - 6 6 6 10 10 10 14 14 14 18 18 18
46794 - 18 18 18 14 14 14 10 10 10 6 6 6
46795 - 0 0 0 0 0 0 0 0 0 0 0 0
46796 - 0 0 0 0 0 0 0 0 0 0 0 0
46797 - 0 0 0 0 0 0 0 0 0 0 0 0
46798 - 0 0 0 0 0 0 0 0 0 0 0 0
46799 - 0 0 0 0 0 0 0 0 0 6 6 6
46800 - 14 14 14 18 18 18 22 22 22 22 22 22
46801 - 18 18 18 14 14 14 10 10 10 6 6 6
46802 - 0 0 0 0 0 0 0 0 0 0 0 0
46803 - 0 0 0 0 0 0 0 0 0 0 0 0
46804 - 0 0 0 0 0 0 0 0 0 0 0 0
46805 - 0 0 0 0 0 0 0 0 0 0 0 0
46806 - 0 0 0 0 0 0 0 0 0 0 0 0
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46895 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46896 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46898 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46900 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46901 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46909 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46910 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46911 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46912 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46914 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46915 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46916 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46917 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4
46919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46923 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46924 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46925 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46926 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46928 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46929 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46930 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46931 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4
46933 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46934 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46935 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46936 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46937 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46938 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46939 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46940 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46941 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46942 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46943 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46944 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46945 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46946 +4 4 4 4 4 4
46947 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46948 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46949 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46950 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46951 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46952 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46953 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46954 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46955 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46956 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46957 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46958 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46959 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46960 +4 4 4 4 4 4
46961 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46962 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46963 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46964 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46965 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46966 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46967 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46968 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46969 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46970 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46971 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46972 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46973 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46974 +4 4 4 4 4 4
46975 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46976 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46977 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46978 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46979 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46980 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46981 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46982 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46983 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46984 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46985 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46986 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46987 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46988 +4 4 4 4 4 4
46989 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46990 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46991 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46992 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46993 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46994 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46995 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46996 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46997 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46998 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46999 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
47000 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
47001 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
47002 +4 4 4 4 4 4
47003 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47004 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47005 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
47006 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
47007 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
47008 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
47009 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
47010 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
47011 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
47012 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
47013 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
47014 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
47015 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
47016 +4 4 4 4 4 4
47017 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47018 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47019 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
47020 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
47021 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
47022 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
47023 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
47024 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
47025 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
47026 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
47027 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47028 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47029 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
47030 +4 4 4 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47032 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
47033 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47034 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47035 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47036 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47037 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47038 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47039 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47040 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47041 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47042 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47043 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
47044 +4 4 4 4 4 4
47045 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47046 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47047 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47048 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47049 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47050 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47051 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47052 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47053 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47054 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47055 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47056 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47057 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47058 +0 0 0 4 4 4
47059 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47060 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47061 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47062 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47063 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47064 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47065 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47066 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47067 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47068 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47069 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47070 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47071 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47072 +2 0 0 0 0 0
47073 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47074 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47075 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47076 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47077 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47078 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47079 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47080 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47081 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47082 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47083 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47084 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47085 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47086 +37 38 37 0 0 0
47087 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47088 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47089 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47090 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47091 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47092 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47093 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47094 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47095 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47096 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47097 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47098 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47099 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47100 +85 115 134 4 0 0
47101 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47102 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47103 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47104 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47105 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47106 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47107 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47108 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47109 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47110 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47111 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47112 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47113 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47114 +60 73 81 4 0 0
47115 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47116 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47117 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47118 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47119 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47120 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47121 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47122 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47123 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47124 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47125 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47126 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47127 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47128 +16 19 21 4 0 0
47129 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47130 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47131 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47132 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47133 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47134 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47135 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47136 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47137 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47138 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47139 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47140 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47141 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47142 +4 0 0 4 3 3
47143 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47144 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47145 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47147 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47148 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47149 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47150 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47151 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47152 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47153 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47154 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47155 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47156 +3 2 2 4 4 4
47157 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47158 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47159 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47160 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47161 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47162 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47163 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47164 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47165 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47166 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47167 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47168 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47169 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47170 +4 4 4 4 4 4
47171 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47172 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47173 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47174 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47175 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47176 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47177 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47178 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47179 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47180 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47181 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47182 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47183 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47184 +4 4 4 4 4 4
47185 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47186 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47187 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47188 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47189 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47190 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47191 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47192 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47193 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47194 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47195 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47196 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47197 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47198 +5 5 5 5 5 5
47199 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47200 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47201 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47202 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47203 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47204 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47205 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47206 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47207 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47208 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47209 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47210 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47211 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47212 +5 5 5 4 4 4
47213 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47214 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47215 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47216 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47217 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47218 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47219 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47220 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47221 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47222 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47223 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47224 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4
47227 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47228 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47229 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47230 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47231 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47232 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47233 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47234 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47235 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47236 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47237 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47238 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4
47241 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47242 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47243 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47244 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47245 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47246 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47247 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47248 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47249 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47250 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47251 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4
47255 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47256 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47257 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47258 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47259 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47260 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47261 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47262 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47263 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47264 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47265 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47267 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4
47269 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47270 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47271 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47272 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47273 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47274 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47275 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47276 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47277 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47278 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47279 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47281 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4
47283 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47284 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47285 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47286 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47287 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47288 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47289 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47290 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47291 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47292 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47293 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47295 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4
47297 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47298 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47299 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47300 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47301 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47302 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47303 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47304 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47305 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47306 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47307 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47309 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4
47311 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47312 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47313 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47314 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47315 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47316 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47317 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47318 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47319 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47320 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47321 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47323 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4
47325 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47326 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47327 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47328 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47329 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47330 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47331 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47332 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47333 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47334 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47335 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47336 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47337 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4
47339 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47340 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47341 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47342 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47343 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47344 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47345 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47346 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47347 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47348 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47349 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47350 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47351 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4
47353 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47354 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47355 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47356 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47357 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47358 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47359 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47360 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47361 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47362 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47363 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47364 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47365 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4
47367 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47368 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47369 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47370 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47371 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47372 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47373 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47374 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47375 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47376 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47377 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47378 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47379 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4
47381 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47382 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47383 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47384 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47385 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47386 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47387 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47388 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47389 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47390 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47391 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47392 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47393 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4
47395 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47396 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47397 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47398 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47399 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47400 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47401 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47402 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47403 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47404 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47405 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47406 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47407 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4
47409 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47410 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47411 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47412 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47413 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47414 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47415 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47416 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47417 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47418 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47419 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47420 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47421 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4
47423 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47424 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47425 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47426 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47427 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47428 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47429 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47430 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47431 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47432 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47433 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47434 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47435 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47436 +4 4 4 4 4 4
47437 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47438 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47439 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47440 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47441 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47442 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47443 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47444 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47445 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47446 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47447 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47448 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47449 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4
47451 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47452 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47453 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47454 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47455 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47456 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47457 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47458 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47459 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47460 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47461 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47462 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47463 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4
47465 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47466 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47467 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47468 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47469 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47470 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47471 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47472 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47473 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47474 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47475 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47476 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4
47479 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47480 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47481 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47482 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47483 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47484 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47485 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47486 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47487 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47488 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47489 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47490 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4
47493 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47494 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47495 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47496 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47497 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47498 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47499 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47500 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47501 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47502 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47503 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47504 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4
47507 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47508 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47509 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47510 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47511 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47512 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47513 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47514 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47515 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47516 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47517 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47518 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47520 +4 4 4 4 4 4
47521 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47522 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47523 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47524 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47525 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47526 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47527 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47528 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47529 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47530 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47531 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47534 +4 4 4 4 4 4
47535 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47536 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47537 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47538 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47539 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47540 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47541 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47542 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47543 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47544 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47545 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47548 +4 4 4 4 4 4
47549 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47550 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47551 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47552 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47553 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47554 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47555 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47556 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47557 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47558 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47559 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4
47563 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47564 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47565 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47566 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47567 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47568 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47569 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47570 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47571 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47572 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47573 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47576 +4 4 4 4 4 4
47577 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47578 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47579 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47580 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47581 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47582 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47583 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47584 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47585 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47586 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47587 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4
47591 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47592 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47593 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47594 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47595 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47596 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47597 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47598 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47599 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47600 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47601 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4
47605 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47606 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47607 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47608 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47609 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47610 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47611 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47612 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47613 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47614 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47615 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4
47619 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47620 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47621 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47622 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47623 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47624 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47625 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47626 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47627 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47628 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4
47633 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47634 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47635 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47636 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47637 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47638 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47639 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47640 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47641 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47642 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4
47647 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47648 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47649 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47650 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47651 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47652 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47653 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47654 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47655 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47656 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4
47661 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47662 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47663 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47664 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47665 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47666 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47667 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47668 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47669 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47670 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4
47675 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47676 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47677 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47678 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47679 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47680 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47681 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47682 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47683 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4
47689 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47690 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47691 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47692 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47693 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47694 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47695 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47696 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47697 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4
47703 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47704 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47705 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47706 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47707 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47708 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47709 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47710 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47711 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4
47717 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47718 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47719 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47720 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47721 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47722 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47723 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47724 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47732 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47733 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47734 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47735 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47736 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47737 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47738 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47746 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47747 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47748 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47749 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47750 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47751 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47752 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47761 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47762 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47763 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47764 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47765 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47766 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47775 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47776 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47777 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47778 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47779 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47780 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47786 +4 4 4 4 4 4
47787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47790 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47791 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47792 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47793 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47794 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47800 +4 4 4 4 4 4
47801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47804 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47805 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47806 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47807 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47814 +4 4 4 4 4 4
47815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47818 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47819 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47820 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47821 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47826 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47828 +4 4 4 4 4 4
47829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47832 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47833 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47834 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47835 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47842 +4 4 4 4 4 4
47843 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47844 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47845 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47846 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47847 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47848 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47849 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47850 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47853 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47854 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47856 +4 4 4 4 4 4
47857 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47858 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47859 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47860 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47861 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47862 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47863 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47864 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47865 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47866 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47867 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47868 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47870 +4 4 4 4 4 4
47871 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47872 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47873 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47874 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47875 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47876 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47877 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47878 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47879 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47880 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47881 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47882 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47884 +4 4 4 4 4 4
47885 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47886 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47887 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47888 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47889 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47890 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47891 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47893 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47894 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47895 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47896 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47898 +4 4 4 4 4 4
47899 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47900 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47902 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47903 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47904 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47905 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47906 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47907 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47908 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47909 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47910 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47912 +4 4 4 4 4 4
47913 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47914 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47915 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47916 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47917 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47918 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47919 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47920 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47921 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47922 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47923 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47924 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47925 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47926 +4 4 4 4 4 4
47927 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47928 index fe92eed..106e085 100644
47929 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47930 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47931 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47932 struct mb862xxfb_par *par = info->par;
47933
47934 if (info->var.bits_per_pixel == 32) {
47935 - info->fbops->fb_fillrect = cfb_fillrect;
47936 - info->fbops->fb_copyarea = cfb_copyarea;
47937 - info->fbops->fb_imageblit = cfb_imageblit;
47938 + pax_open_kernel();
47939 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47940 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47941 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47942 + pax_close_kernel();
47943 } else {
47944 outreg(disp, GC_L0EM, 3);
47945 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47946 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47947 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47948 + pax_open_kernel();
47949 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47950 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47951 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47952 + pax_close_kernel();
47953 }
47954 outreg(draw, GDC_REG_DRAW_BASE, 0);
47955 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47956 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47957 index ff22871..b129bed 100644
47958 --- a/drivers/video/nvidia/nvidia.c
47959 +++ b/drivers/video/nvidia/nvidia.c
47960 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47961 info->fix.line_length = (info->var.xres_virtual *
47962 info->var.bits_per_pixel) >> 3;
47963 if (info->var.accel_flags) {
47964 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47965 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47966 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47967 - info->fbops->fb_sync = nvidiafb_sync;
47968 + pax_open_kernel();
47969 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47970 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47971 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47972 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47973 + pax_close_kernel();
47974 info->pixmap.scan_align = 4;
47975 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47976 info->flags |= FBINFO_READS_FAST;
47977 NVResetGraphics(info);
47978 } else {
47979 - info->fbops->fb_imageblit = cfb_imageblit;
47980 - info->fbops->fb_fillrect = cfb_fillrect;
47981 - info->fbops->fb_copyarea = cfb_copyarea;
47982 - info->fbops->fb_sync = NULL;
47983 + pax_open_kernel();
47984 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47985 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47986 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47987 + *(void **)&info->fbops->fb_sync = NULL;
47988 + pax_close_kernel();
47989 info->pixmap.scan_align = 1;
47990 info->flags |= FBINFO_HWACCEL_DISABLED;
47991 info->flags &= ~FBINFO_READS_FAST;
47992 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47993 info->pixmap.size = 8 * 1024;
47994 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47995
47996 - if (!hwcur)
47997 - info->fbops->fb_cursor = NULL;
47998 + if (!hwcur) {
47999 + pax_open_kernel();
48000 + *(void **)&info->fbops->fb_cursor = NULL;
48001 + pax_close_kernel();
48002 + }
48003
48004 info->var.accel_flags = (!noaccel);
48005
48006 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
48007 index 76d9053..dec2bfd 100644
48008 --- a/drivers/video/s1d13xxxfb.c
48009 +++ b/drivers/video/s1d13xxxfb.c
48010 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
48011
48012 switch(prod_id) {
48013 case S1D13506_PROD_ID: /* activate acceleration */
48014 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48015 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48016 + pax_open_kernel();
48017 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
48018 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
48019 + pax_close_kernel();
48020 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
48021 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
48022 break;
48023 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
48024 index 97bd662..39fab85 100644
48025 --- a/drivers/video/smscufx.c
48026 +++ b/drivers/video/smscufx.c
48027 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48028 fb_deferred_io_cleanup(info);
48029 kfree(info->fbdefio);
48030 info->fbdefio = NULL;
48031 - info->fbops->fb_mmap = ufx_ops_mmap;
48032 + pax_open_kernel();
48033 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48034 + pax_close_kernel();
48035 }
48036
48037 pr_debug("released /dev/fb%d user=%d count=%d",
48038 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48039 index 86d449e..8e04dc5 100644
48040 --- a/drivers/video/udlfb.c
48041 +++ b/drivers/video/udlfb.c
48042 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48043 dlfb_urb_completion(urb);
48044
48045 error:
48046 - atomic_add(bytes_sent, &dev->bytes_sent);
48047 - atomic_add(bytes_identical, &dev->bytes_identical);
48048 - atomic_add(width*height*2, &dev->bytes_rendered);
48049 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48050 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48051 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48052 end_cycles = get_cycles();
48053 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48054 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48055 >> 10)), /* Kcycles */
48056 &dev->cpu_kcycles_used);
48057
48058 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48059 dlfb_urb_completion(urb);
48060
48061 error:
48062 - atomic_add(bytes_sent, &dev->bytes_sent);
48063 - atomic_add(bytes_identical, &dev->bytes_identical);
48064 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48065 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48066 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48067 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48068 end_cycles = get_cycles();
48069 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48070 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48071 >> 10)), /* Kcycles */
48072 &dev->cpu_kcycles_used);
48073 }
48074 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48075 fb_deferred_io_cleanup(info);
48076 kfree(info->fbdefio);
48077 info->fbdefio = NULL;
48078 - info->fbops->fb_mmap = dlfb_ops_mmap;
48079 + pax_open_kernel();
48080 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48081 + pax_close_kernel();
48082 }
48083
48084 pr_warn("released /dev/fb%d user=%d count=%d\n",
48085 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48086 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48087 struct dlfb_data *dev = fb_info->par;
48088 return snprintf(buf, PAGE_SIZE, "%u\n",
48089 - atomic_read(&dev->bytes_rendered));
48090 + atomic_read_unchecked(&dev->bytes_rendered));
48091 }
48092
48093 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48094 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48095 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48096 struct dlfb_data *dev = fb_info->par;
48097 return snprintf(buf, PAGE_SIZE, "%u\n",
48098 - atomic_read(&dev->bytes_identical));
48099 + atomic_read_unchecked(&dev->bytes_identical));
48100 }
48101
48102 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48103 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48104 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48105 struct dlfb_data *dev = fb_info->par;
48106 return snprintf(buf, PAGE_SIZE, "%u\n",
48107 - atomic_read(&dev->bytes_sent));
48108 + atomic_read_unchecked(&dev->bytes_sent));
48109 }
48110
48111 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48112 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48113 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48114 struct dlfb_data *dev = fb_info->par;
48115 return snprintf(buf, PAGE_SIZE, "%u\n",
48116 - atomic_read(&dev->cpu_kcycles_used));
48117 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48118 }
48119
48120 static ssize_t edid_show(
48121 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48122 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48123 struct dlfb_data *dev = fb_info->par;
48124
48125 - atomic_set(&dev->bytes_rendered, 0);
48126 - atomic_set(&dev->bytes_identical, 0);
48127 - atomic_set(&dev->bytes_sent, 0);
48128 - atomic_set(&dev->cpu_kcycles_used, 0);
48129 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48130 + atomic_set_unchecked(&dev->bytes_identical, 0);
48131 + atomic_set_unchecked(&dev->bytes_sent, 0);
48132 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48133
48134 return count;
48135 }
48136 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48137 index b75db01..ad2f34a 100644
48138 --- a/drivers/video/uvesafb.c
48139 +++ b/drivers/video/uvesafb.c
48140 @@ -19,6 +19,7 @@
48141 #include <linux/io.h>
48142 #include <linux/mutex.h>
48143 #include <linux/slab.h>
48144 +#include <linux/moduleloader.h>
48145 #include <video/edid.h>
48146 #include <video/uvesafb.h>
48147 #ifdef CONFIG_X86
48148 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48149 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48150 par->pmi_setpal = par->ypan = 0;
48151 } else {
48152 +
48153 +#ifdef CONFIG_PAX_KERNEXEC
48154 +#ifdef CONFIG_MODULES
48155 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48156 +#endif
48157 + if (!par->pmi_code) {
48158 + par->pmi_setpal = par->ypan = 0;
48159 + return 0;
48160 + }
48161 +#endif
48162 +
48163 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48164 + task->t.regs.edi);
48165 +
48166 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48167 + pax_open_kernel();
48168 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48169 + pax_close_kernel();
48170 +
48171 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48172 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48173 +#else
48174 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48175 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48176 +#endif
48177 +
48178 printk(KERN_INFO "uvesafb: protected mode interface info at "
48179 "%04x:%04x\n",
48180 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48181 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48182 par->ypan = ypan;
48183
48184 if (par->pmi_setpal || par->ypan) {
48185 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48186 if (__supported_pte_mask & _PAGE_NX) {
48187 par->pmi_setpal = par->ypan = 0;
48188 printk(KERN_WARNING "uvesafb: NX protection is actively."
48189 "We have better not to use the PMI.\n");
48190 - } else {
48191 + } else
48192 +#endif
48193 uvesafb_vbe_getpmi(task, par);
48194 - }
48195 }
48196 #else
48197 /* The protected mode interface is not available on non-x86. */
48198 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48199 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48200
48201 /* Disable blanking if the user requested so. */
48202 - if (!blank)
48203 - info->fbops->fb_blank = NULL;
48204 + if (!blank) {
48205 + pax_open_kernel();
48206 + *(void **)&info->fbops->fb_blank = NULL;
48207 + pax_close_kernel();
48208 + }
48209
48210 /*
48211 * Find out how much IO memory is required for the mode with
48212 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48213 info->flags = FBINFO_FLAG_DEFAULT |
48214 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48215
48216 - if (!par->ypan)
48217 - info->fbops->fb_pan_display = NULL;
48218 + if (!par->ypan) {
48219 + pax_open_kernel();
48220 + *(void **)&info->fbops->fb_pan_display = NULL;
48221 + pax_close_kernel();
48222 + }
48223 }
48224
48225 static void uvesafb_init_mtrr(struct fb_info *info)
48226 @@ -1836,6 +1866,11 @@ out:
48227 if (par->vbe_modes)
48228 kfree(par->vbe_modes);
48229
48230 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48231 + if (par->pmi_code)
48232 + module_free_exec(NULL, par->pmi_code);
48233 +#endif
48234 +
48235 framebuffer_release(info);
48236 return err;
48237 }
48238 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48239 kfree(par->vbe_state_orig);
48240 if (par->vbe_state_saved)
48241 kfree(par->vbe_state_saved);
48242 +
48243 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48244 + if (par->pmi_code)
48245 + module_free_exec(NULL, par->pmi_code);
48246 +#endif
48247 +
48248 }
48249
48250 framebuffer_release(info);
48251 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48252 index 501b340..d80aa17 100644
48253 --- a/drivers/video/vesafb.c
48254 +++ b/drivers/video/vesafb.c
48255 @@ -9,6 +9,7 @@
48256 */
48257
48258 #include <linux/module.h>
48259 +#include <linux/moduleloader.h>
48260 #include <linux/kernel.h>
48261 #include <linux/errno.h>
48262 #include <linux/string.h>
48263 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48264 static int vram_total __initdata; /* Set total amount of memory */
48265 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48266 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48267 -static void (*pmi_start)(void) __read_mostly;
48268 -static void (*pmi_pal) (void) __read_mostly;
48269 +static void (*pmi_start)(void) __read_only;
48270 +static void (*pmi_pal) (void) __read_only;
48271 static int depth __read_mostly;
48272 static int vga_compat __read_mostly;
48273 /* --------------------------------------------------------------------- */
48274 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48275 unsigned int size_vmode;
48276 unsigned int size_remap;
48277 unsigned int size_total;
48278 + void *pmi_code = NULL;
48279
48280 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48281 return -ENODEV;
48282 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48283 size_remap = size_total;
48284 vesafb_fix.smem_len = size_remap;
48285
48286 -#ifndef __i386__
48287 - screen_info.vesapm_seg = 0;
48288 -#endif
48289 -
48290 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48291 printk(KERN_WARNING
48292 "vesafb: cannot reserve video memory at 0x%lx\n",
48293 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48294 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48295 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48296
48297 +#ifdef __i386__
48298 +
48299 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48300 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48301 + if (!pmi_code)
48302 +#elif !defined(CONFIG_PAX_KERNEXEC)
48303 + if (0)
48304 +#endif
48305 +
48306 +#endif
48307 + screen_info.vesapm_seg = 0;
48308 +
48309 if (screen_info.vesapm_seg) {
48310 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48311 - screen_info.vesapm_seg,screen_info.vesapm_off);
48312 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48313 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48314 }
48315
48316 if (screen_info.vesapm_seg < 0xc000)
48317 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48318
48319 if (ypan || pmi_setpal) {
48320 unsigned short *pmi_base;
48321 +
48322 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48323 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48324 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48325 +
48326 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48327 + pax_open_kernel();
48328 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48329 +#else
48330 + pmi_code = pmi_base;
48331 +#endif
48332 +
48333 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48334 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48335 +
48336 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48337 + pmi_start = ktva_ktla(pmi_start);
48338 + pmi_pal = ktva_ktla(pmi_pal);
48339 + pax_close_kernel();
48340 +#endif
48341 +
48342 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48343 if (pmi_base[3]) {
48344 printk(KERN_INFO "vesafb: pmi: ports = ");
48345 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48346 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48347 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48348
48349 - if (!ypan)
48350 - info->fbops->fb_pan_display = NULL;
48351 + if (!ypan) {
48352 + pax_open_kernel();
48353 + *(void **)&info->fbops->fb_pan_display = NULL;
48354 + pax_close_kernel();
48355 + }
48356
48357 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48358 err = -ENOMEM;
48359 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48360 info->node, info->fix.id);
48361 return 0;
48362 err:
48363 +
48364 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48365 + module_free_exec(NULL, pmi_code);
48366 +#endif
48367 +
48368 if (info->screen_base)
48369 iounmap(info->screen_base);
48370 framebuffer_release(info);
48371 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48372 index 88714ae..16c2e11 100644
48373 --- a/drivers/video/via/via_clock.h
48374 +++ b/drivers/video/via/via_clock.h
48375 @@ -56,7 +56,7 @@ struct via_clock {
48376
48377 void (*set_engine_pll_state)(u8 state);
48378 void (*set_engine_pll)(struct via_pll_config config);
48379 -};
48380 +} __no_const;
48381
48382
48383 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48384 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48385 index fef20db..d28b1ab 100644
48386 --- a/drivers/xen/xenfs/xenstored.c
48387 +++ b/drivers/xen/xenfs/xenstored.c
48388 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48389 static int xsd_kva_open(struct inode *inode, struct file *file)
48390 {
48391 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48392 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48393 + NULL);
48394 +#else
48395 xen_store_interface);
48396 +#endif
48397 +
48398 if (!file->private_data)
48399 return -ENOMEM;
48400 return 0;
48401 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48402 index 890bed5..17ae73e 100644
48403 --- a/fs/9p/vfs_inode.c
48404 +++ b/fs/9p/vfs_inode.c
48405 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48406 void
48407 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48408 {
48409 - char *s = nd_get_link(nd);
48410 + const char *s = nd_get_link(nd);
48411
48412 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48413 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48414 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48415 index 0efd152..b5802ad 100644
48416 --- a/fs/Kconfig.binfmt
48417 +++ b/fs/Kconfig.binfmt
48418 @@ -89,7 +89,7 @@ config HAVE_AOUT
48419
48420 config BINFMT_AOUT
48421 tristate "Kernel support for a.out and ECOFF binaries"
48422 - depends on HAVE_AOUT
48423 + depends on HAVE_AOUT && BROKEN
48424 ---help---
48425 A.out (Assembler.OUTput) is a set of formats for libraries and
48426 executables used in the earliest versions of UNIX. Linux used
48427 diff --git a/fs/aio.c b/fs/aio.c
48428 index ed762ae..ee07789 100644
48429 --- a/fs/aio.c
48430 +++ b/fs/aio.c
48431 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48432 size += sizeof(struct io_event) * nr_events;
48433 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48434
48435 - if (nr_pages < 0)
48436 + if (nr_pages <= 0)
48437 return -EINVAL;
48438
48439 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48440 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48441 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48442 {
48443 ssize_t ret;
48444 + struct iovec iovstack;
48445
48446 #ifdef CONFIG_COMPAT
48447 if (compat)
48448 ret = compat_rw_copy_check_uvector(type,
48449 (struct compat_iovec __user *)kiocb->ki_buf,
48450 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48451 + kiocb->ki_nbytes, 1, &iovstack,
48452 &kiocb->ki_iovec);
48453 else
48454 #endif
48455 ret = rw_copy_check_uvector(type,
48456 (struct iovec __user *)kiocb->ki_buf,
48457 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48458 + kiocb->ki_nbytes, 1, &iovstack,
48459 &kiocb->ki_iovec);
48460 if (ret < 0)
48461 goto out;
48462 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48463 if (ret < 0)
48464 goto out;
48465
48466 + if (kiocb->ki_iovec == &iovstack) {
48467 + kiocb->ki_inline_vec = iovstack;
48468 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48469 + }
48470 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48471 kiocb->ki_cur_seg = 0;
48472 /* ki_nbytes/left now reflect bytes instead of segs */
48473 diff --git a/fs/attr.c b/fs/attr.c
48474 index 1449adb..a2038c2 100644
48475 --- a/fs/attr.c
48476 +++ b/fs/attr.c
48477 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48478 unsigned long limit;
48479
48480 limit = rlimit(RLIMIT_FSIZE);
48481 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48482 if (limit != RLIM_INFINITY && offset > limit)
48483 goto out_sig;
48484 if (offset > inode->i_sb->s_maxbytes)
48485 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48486 index 03bc1d3..6205356 100644
48487 --- a/fs/autofs4/waitq.c
48488 +++ b/fs/autofs4/waitq.c
48489 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48490 {
48491 unsigned long sigpipe, flags;
48492 mm_segment_t fs;
48493 - const char *data = (const char *)addr;
48494 + const char __user *data = (const char __force_user *)addr;
48495 ssize_t wr = 0;
48496
48497 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48498 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48499 return 1;
48500 }
48501
48502 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48503 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48504 +#endif
48505 +
48506 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48507 enum autofs_notify notify)
48508 {
48509 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48510
48511 /* If this is a direct mount request create a dummy name */
48512 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48513 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48514 + /* this name does get written to userland via autofs4_write() */
48515 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48516 +#else
48517 qstr.len = sprintf(name, "%p", dentry);
48518 +#endif
48519 else {
48520 qstr.len = autofs4_getpath(sbi, dentry, &name);
48521 if (!qstr.len) {
48522 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48523 index 2722387..c8dd2a7 100644
48524 --- a/fs/befs/endian.h
48525 +++ b/fs/befs/endian.h
48526 @@ -11,7 +11,7 @@
48527
48528 #include <asm/byteorder.h>
48529
48530 -static inline u64
48531 +static inline u64 __intentional_overflow(-1)
48532 fs64_to_cpu(const struct super_block *sb, fs64 n)
48533 {
48534 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48535 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48536 return (__force fs64)cpu_to_be64(n);
48537 }
48538
48539 -static inline u32
48540 +static inline u32 __intentional_overflow(-1)
48541 fs32_to_cpu(const struct super_block *sb, fs32 n)
48542 {
48543 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48544 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48545 index 2b3bda8..6a2d4be 100644
48546 --- a/fs/befs/linuxvfs.c
48547 +++ b/fs/befs/linuxvfs.c
48548 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48549 {
48550 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48551 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48552 - char *link = nd_get_link(nd);
48553 + const char *link = nd_get_link(nd);
48554 if (!IS_ERR(link))
48555 kfree(link);
48556 }
48557 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48558 index 6043567..16a9239 100644
48559 --- a/fs/binfmt_aout.c
48560 +++ b/fs/binfmt_aout.c
48561 @@ -16,6 +16,7 @@
48562 #include <linux/string.h>
48563 #include <linux/fs.h>
48564 #include <linux/file.h>
48565 +#include <linux/security.h>
48566 #include <linux/stat.h>
48567 #include <linux/fcntl.h>
48568 #include <linux/ptrace.h>
48569 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48570 #endif
48571 # define START_STACK(u) ((void __user *)u.start_stack)
48572
48573 + memset(&dump, 0, sizeof(dump));
48574 +
48575 fs = get_fs();
48576 set_fs(KERNEL_DS);
48577 has_dumped = 1;
48578 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48579
48580 /* If the size of the dump file exceeds the rlimit, then see what would happen
48581 if we wrote the stack, but not the data area. */
48582 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48583 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48584 dump.u_dsize = 0;
48585
48586 /* Make sure we have enough room to write the stack and data areas. */
48587 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48588 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48589 dump.u_ssize = 0;
48590
48591 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48592 rlim = rlimit(RLIMIT_DATA);
48593 if (rlim >= RLIM_INFINITY)
48594 rlim = ~0;
48595 +
48596 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48597 if (ex.a_data + ex.a_bss > rlim)
48598 return -ENOMEM;
48599
48600 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48601
48602 install_exec_creds(bprm);
48603
48604 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48605 + current->mm->pax_flags = 0UL;
48606 +#endif
48607 +
48608 +#ifdef CONFIG_PAX_PAGEEXEC
48609 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48610 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48611 +
48612 +#ifdef CONFIG_PAX_EMUTRAMP
48613 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48614 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48615 +#endif
48616 +
48617 +#ifdef CONFIG_PAX_MPROTECT
48618 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48619 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48620 +#endif
48621 +
48622 + }
48623 +#endif
48624 +
48625 if (N_MAGIC(ex) == OMAGIC) {
48626 unsigned long text_addr, map_size;
48627 loff_t pos;
48628 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48629 }
48630
48631 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48632 - PROT_READ | PROT_WRITE | PROT_EXEC,
48633 + PROT_READ | PROT_WRITE,
48634 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48635 fd_offset + ex.a_text);
48636 if (error != N_DATADDR(ex)) {
48637 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48638 index 5843a47..160fbe2 100644
48639 --- a/fs/binfmt_elf.c
48640 +++ b/fs/binfmt_elf.c
48641 @@ -33,6 +33,7 @@
48642 #include <linux/elf.h>
48643 #include <linux/utsname.h>
48644 #include <linux/coredump.h>
48645 +#include <linux/xattr.h>
48646 #include <asm/uaccess.h>
48647 #include <asm/param.h>
48648 #include <asm/page.h>
48649 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48650 #define elf_core_dump NULL
48651 #endif
48652
48653 +#ifdef CONFIG_PAX_MPROTECT
48654 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48655 +#endif
48656 +
48657 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48658 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48659 #else
48660 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48661 .load_binary = load_elf_binary,
48662 .load_shlib = load_elf_library,
48663 .core_dump = elf_core_dump,
48664 +
48665 +#ifdef CONFIG_PAX_MPROTECT
48666 + .handle_mprotect= elf_handle_mprotect,
48667 +#endif
48668 +
48669 .min_coredump = ELF_EXEC_PAGESIZE,
48670 };
48671
48672 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48673
48674 static int set_brk(unsigned long start, unsigned long end)
48675 {
48676 + unsigned long e = end;
48677 +
48678 start = ELF_PAGEALIGN(start);
48679 end = ELF_PAGEALIGN(end);
48680 if (end > start) {
48681 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48682 if (BAD_ADDR(addr))
48683 return addr;
48684 }
48685 - current->mm->start_brk = current->mm->brk = end;
48686 + current->mm->start_brk = current->mm->brk = e;
48687 return 0;
48688 }
48689
48690 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48691 elf_addr_t __user *u_rand_bytes;
48692 const char *k_platform = ELF_PLATFORM;
48693 const char *k_base_platform = ELF_BASE_PLATFORM;
48694 - unsigned char k_rand_bytes[16];
48695 + u32 k_rand_bytes[4];
48696 int items;
48697 elf_addr_t *elf_info;
48698 int ei_index = 0;
48699 const struct cred *cred = current_cred();
48700 struct vm_area_struct *vma;
48701 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48702
48703 /*
48704 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48705 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48706 * Generate 16 random bytes for userspace PRNG seeding.
48707 */
48708 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48709 - u_rand_bytes = (elf_addr_t __user *)
48710 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48711 + srandom32(k_rand_bytes[0] ^ random32());
48712 + srandom32(k_rand_bytes[1] ^ random32());
48713 + srandom32(k_rand_bytes[2] ^ random32());
48714 + srandom32(k_rand_bytes[3] ^ random32());
48715 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48716 + u_rand_bytes = (elf_addr_t __user *) p;
48717 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48718 return -EFAULT;
48719
48720 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48721 return -EFAULT;
48722 current->mm->env_end = p;
48723
48724 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48725 +
48726 /* Put the elf_info on the stack in the right place. */
48727 sp = (elf_addr_t __user *)envp + 1;
48728 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48729 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48730 return -EFAULT;
48731 return 0;
48732 }
48733 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48734 an ELF header */
48735
48736 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48737 - struct file *interpreter, unsigned long *interp_map_addr,
48738 - unsigned long no_base)
48739 + struct file *interpreter, unsigned long no_base)
48740 {
48741 struct elf_phdr *elf_phdata;
48742 struct elf_phdr *eppnt;
48743 - unsigned long load_addr = 0;
48744 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48745 int load_addr_set = 0;
48746 unsigned long last_bss = 0, elf_bss = 0;
48747 - unsigned long error = ~0UL;
48748 + unsigned long error = -EINVAL;
48749 unsigned long total_size;
48750 int retval, i, size;
48751
48752 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48753 goto out_close;
48754 }
48755
48756 +#ifdef CONFIG_PAX_SEGMEXEC
48757 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48758 + pax_task_size = SEGMEXEC_TASK_SIZE;
48759 +#endif
48760 +
48761 eppnt = elf_phdata;
48762 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48763 if (eppnt->p_type == PT_LOAD) {
48764 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48765 map_addr = elf_map(interpreter, load_addr + vaddr,
48766 eppnt, elf_prot, elf_type, total_size);
48767 total_size = 0;
48768 - if (!*interp_map_addr)
48769 - *interp_map_addr = map_addr;
48770 error = map_addr;
48771 if (BAD_ADDR(map_addr))
48772 goto out_close;
48773 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48774 k = load_addr + eppnt->p_vaddr;
48775 if (BAD_ADDR(k) ||
48776 eppnt->p_filesz > eppnt->p_memsz ||
48777 - eppnt->p_memsz > TASK_SIZE ||
48778 - TASK_SIZE - eppnt->p_memsz < k) {
48779 + eppnt->p_memsz > pax_task_size ||
48780 + pax_task_size - eppnt->p_memsz < k) {
48781 error = -ENOMEM;
48782 goto out_close;
48783 }
48784 @@ -530,6 +551,315 @@ out:
48785 return error;
48786 }
48787
48788 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48789 +#ifdef CONFIG_PAX_SOFTMODE
48790 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48791 +{
48792 + unsigned long pax_flags = 0UL;
48793 +
48794 +#ifdef CONFIG_PAX_PAGEEXEC
48795 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48796 + pax_flags |= MF_PAX_PAGEEXEC;
48797 +#endif
48798 +
48799 +#ifdef CONFIG_PAX_SEGMEXEC
48800 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48801 + pax_flags |= MF_PAX_SEGMEXEC;
48802 +#endif
48803 +
48804 +#ifdef CONFIG_PAX_EMUTRAMP
48805 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48806 + pax_flags |= MF_PAX_EMUTRAMP;
48807 +#endif
48808 +
48809 +#ifdef CONFIG_PAX_MPROTECT
48810 + if (elf_phdata->p_flags & PF_MPROTECT)
48811 + pax_flags |= MF_PAX_MPROTECT;
48812 +#endif
48813 +
48814 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48815 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48816 + pax_flags |= MF_PAX_RANDMMAP;
48817 +#endif
48818 +
48819 + return pax_flags;
48820 +}
48821 +#endif
48822 +
48823 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48824 +{
48825 + unsigned long pax_flags = 0UL;
48826 +
48827 +#ifdef CONFIG_PAX_PAGEEXEC
48828 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48829 + pax_flags |= MF_PAX_PAGEEXEC;
48830 +#endif
48831 +
48832 +#ifdef CONFIG_PAX_SEGMEXEC
48833 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48834 + pax_flags |= MF_PAX_SEGMEXEC;
48835 +#endif
48836 +
48837 +#ifdef CONFIG_PAX_EMUTRAMP
48838 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48839 + pax_flags |= MF_PAX_EMUTRAMP;
48840 +#endif
48841 +
48842 +#ifdef CONFIG_PAX_MPROTECT
48843 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48844 + pax_flags |= MF_PAX_MPROTECT;
48845 +#endif
48846 +
48847 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48848 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48849 + pax_flags |= MF_PAX_RANDMMAP;
48850 +#endif
48851 +
48852 + return pax_flags;
48853 +}
48854 +#endif
48855 +
48856 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48857 +#ifdef CONFIG_PAX_SOFTMODE
48858 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48859 +{
48860 + unsigned long pax_flags = 0UL;
48861 +
48862 +#ifdef CONFIG_PAX_PAGEEXEC
48863 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48864 + pax_flags |= MF_PAX_PAGEEXEC;
48865 +#endif
48866 +
48867 +#ifdef CONFIG_PAX_SEGMEXEC
48868 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48869 + pax_flags |= MF_PAX_SEGMEXEC;
48870 +#endif
48871 +
48872 +#ifdef CONFIG_PAX_EMUTRAMP
48873 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48874 + pax_flags |= MF_PAX_EMUTRAMP;
48875 +#endif
48876 +
48877 +#ifdef CONFIG_PAX_MPROTECT
48878 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48879 + pax_flags |= MF_PAX_MPROTECT;
48880 +#endif
48881 +
48882 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48883 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48884 + pax_flags |= MF_PAX_RANDMMAP;
48885 +#endif
48886 +
48887 + return pax_flags;
48888 +}
48889 +#endif
48890 +
48891 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48892 +{
48893 + unsigned long pax_flags = 0UL;
48894 +
48895 +#ifdef CONFIG_PAX_PAGEEXEC
48896 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48897 + pax_flags |= MF_PAX_PAGEEXEC;
48898 +#endif
48899 +
48900 +#ifdef CONFIG_PAX_SEGMEXEC
48901 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48902 + pax_flags |= MF_PAX_SEGMEXEC;
48903 +#endif
48904 +
48905 +#ifdef CONFIG_PAX_EMUTRAMP
48906 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48907 + pax_flags |= MF_PAX_EMUTRAMP;
48908 +#endif
48909 +
48910 +#ifdef CONFIG_PAX_MPROTECT
48911 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48912 + pax_flags |= MF_PAX_MPROTECT;
48913 +#endif
48914 +
48915 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48916 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48917 + pax_flags |= MF_PAX_RANDMMAP;
48918 +#endif
48919 +
48920 + return pax_flags;
48921 +}
48922 +#endif
48923 +
48924 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48925 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48926 +{
48927 + unsigned long pax_flags = 0UL;
48928 +
48929 +#ifdef CONFIG_PAX_EI_PAX
48930 +
48931 +#ifdef CONFIG_PAX_PAGEEXEC
48932 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48933 + pax_flags |= MF_PAX_PAGEEXEC;
48934 +#endif
48935 +
48936 +#ifdef CONFIG_PAX_SEGMEXEC
48937 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48938 + pax_flags |= MF_PAX_SEGMEXEC;
48939 +#endif
48940 +
48941 +#ifdef CONFIG_PAX_EMUTRAMP
48942 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48943 + pax_flags |= MF_PAX_EMUTRAMP;
48944 +#endif
48945 +
48946 +#ifdef CONFIG_PAX_MPROTECT
48947 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48948 + pax_flags |= MF_PAX_MPROTECT;
48949 +#endif
48950 +
48951 +#ifdef CONFIG_PAX_ASLR
48952 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48953 + pax_flags |= MF_PAX_RANDMMAP;
48954 +#endif
48955 +
48956 +#else
48957 +
48958 +#ifdef CONFIG_PAX_PAGEEXEC
48959 + pax_flags |= MF_PAX_PAGEEXEC;
48960 +#endif
48961 +
48962 +#ifdef CONFIG_PAX_SEGMEXEC
48963 + pax_flags |= MF_PAX_SEGMEXEC;
48964 +#endif
48965 +
48966 +#ifdef CONFIG_PAX_MPROTECT
48967 + pax_flags |= MF_PAX_MPROTECT;
48968 +#endif
48969 +
48970 +#ifdef CONFIG_PAX_RANDMMAP
48971 + if (randomize_va_space)
48972 + pax_flags |= MF_PAX_RANDMMAP;
48973 +#endif
48974 +
48975 +#endif
48976 +
48977 + return pax_flags;
48978 +}
48979 +
48980 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48981 +{
48982 +
48983 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48984 + unsigned long i;
48985 +
48986 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48987 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48988 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48989 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48990 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48991 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48992 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48993 + return ~0UL;
48994 +
48995 +#ifdef CONFIG_PAX_SOFTMODE
48996 + if (pax_softmode)
48997 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48998 + else
48999 +#endif
49000 +
49001 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
49002 + break;
49003 + }
49004 +#endif
49005 +
49006 + return ~0UL;
49007 +}
49008 +
49009 +static unsigned long pax_parse_xattr_pax(struct file * const file)
49010 +{
49011 +
49012 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
49013 + ssize_t xattr_size, i;
49014 + unsigned char xattr_value[5];
49015 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
49016 +
49017 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
49018 + if (xattr_size <= 0 || xattr_size > 5)
49019 + return ~0UL;
49020 +
49021 + for (i = 0; i < xattr_size; i++)
49022 + switch (xattr_value[i]) {
49023 + default:
49024 + return ~0UL;
49025 +
49026 +#define parse_flag(option1, option2, flag) \
49027 + case option1: \
49028 + if (pax_flags_hardmode & MF_PAX_##flag) \
49029 + return ~0UL; \
49030 + pax_flags_hardmode |= MF_PAX_##flag; \
49031 + break; \
49032 + case option2: \
49033 + if (pax_flags_softmode & MF_PAX_##flag) \
49034 + return ~0UL; \
49035 + pax_flags_softmode |= MF_PAX_##flag; \
49036 + break;
49037 +
49038 + parse_flag('p', 'P', PAGEEXEC);
49039 + parse_flag('e', 'E', EMUTRAMP);
49040 + parse_flag('m', 'M', MPROTECT);
49041 + parse_flag('r', 'R', RANDMMAP);
49042 + parse_flag('s', 'S', SEGMEXEC);
49043 +
49044 +#undef parse_flag
49045 + }
49046 +
49047 + if (pax_flags_hardmode & pax_flags_softmode)
49048 + return ~0UL;
49049 +
49050 +#ifdef CONFIG_PAX_SOFTMODE
49051 + if (pax_softmode)
49052 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49053 + else
49054 +#endif
49055 +
49056 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49057 +#else
49058 + return ~0UL;
49059 +#endif
49060 +
49061 +}
49062 +
49063 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49064 +{
49065 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49066 +
49067 + pax_flags = pax_parse_ei_pax(elf_ex);
49068 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49069 + xattr_pax_flags = pax_parse_xattr_pax(file);
49070 +
49071 + if (pt_pax_flags == ~0UL)
49072 + pt_pax_flags = xattr_pax_flags;
49073 + else if (xattr_pax_flags == ~0UL)
49074 + xattr_pax_flags = pt_pax_flags;
49075 + if (pt_pax_flags != xattr_pax_flags)
49076 + return -EINVAL;
49077 + if (pt_pax_flags != ~0UL)
49078 + pax_flags = pt_pax_flags;
49079 +
49080 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49081 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49082 + if ((__supported_pte_mask & _PAGE_NX))
49083 + pax_flags &= ~MF_PAX_SEGMEXEC;
49084 + else
49085 + pax_flags &= ~MF_PAX_PAGEEXEC;
49086 + }
49087 +#endif
49088 +
49089 + if (0 > pax_check_flags(&pax_flags))
49090 + return -EINVAL;
49091 +
49092 + current->mm->pax_flags = pax_flags;
49093 + return 0;
49094 +}
49095 +#endif
49096 +
49097 /*
49098 * These are the functions used to load ELF style executables and shared
49099 * libraries. There is no binary dependent code anywhere else.
49100 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49101 {
49102 unsigned int random_variable = 0;
49103
49104 +#ifdef CONFIG_PAX_RANDUSTACK
49105 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49106 + return stack_top - current->mm->delta_stack;
49107 +#endif
49108 +
49109 if ((current->flags & PF_RANDOMIZE) &&
49110 !(current->personality & ADDR_NO_RANDOMIZE)) {
49111 random_variable = get_random_int() & STACK_RND_MASK;
49112 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49113 unsigned long load_addr = 0, load_bias = 0;
49114 int load_addr_set = 0;
49115 char * elf_interpreter = NULL;
49116 - unsigned long error;
49117 + unsigned long error = 0;
49118 struct elf_phdr *elf_ppnt, *elf_phdata;
49119 unsigned long elf_bss, elf_brk;
49120 int retval, i;
49121 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49122 unsigned long start_code, end_code, start_data, end_data;
49123 unsigned long reloc_func_desc __maybe_unused = 0;
49124 int executable_stack = EXSTACK_DEFAULT;
49125 - unsigned long def_flags = 0;
49126 struct pt_regs *regs = current_pt_regs();
49127 struct {
49128 struct elfhdr elf_ex;
49129 struct elfhdr interp_elf_ex;
49130 } *loc;
49131 + unsigned long pax_task_size = TASK_SIZE;
49132
49133 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49134 if (!loc) {
49135 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49136 goto out_free_dentry;
49137
49138 /* OK, This is the point of no return */
49139 - current->mm->def_flags = def_flags;
49140 +
49141 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49142 + current->mm->pax_flags = 0UL;
49143 +#endif
49144 +
49145 +#ifdef CONFIG_PAX_DLRESOLVE
49146 + current->mm->call_dl_resolve = 0UL;
49147 +#endif
49148 +
49149 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49150 + current->mm->call_syscall = 0UL;
49151 +#endif
49152 +
49153 +#ifdef CONFIG_PAX_ASLR
49154 + current->mm->delta_mmap = 0UL;
49155 + current->mm->delta_stack = 0UL;
49156 +#endif
49157 +
49158 + current->mm->def_flags = 0;
49159 +
49160 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49161 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49162 + send_sig(SIGKILL, current, 0);
49163 + goto out_free_dentry;
49164 + }
49165 +#endif
49166 +
49167 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49168 + pax_set_initial_flags(bprm);
49169 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49170 + if (pax_set_initial_flags_func)
49171 + (pax_set_initial_flags_func)(bprm);
49172 +#endif
49173 +
49174 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49175 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49176 + current->mm->context.user_cs_limit = PAGE_SIZE;
49177 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49178 + }
49179 +#endif
49180 +
49181 +#ifdef CONFIG_PAX_SEGMEXEC
49182 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49183 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49184 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49185 + pax_task_size = SEGMEXEC_TASK_SIZE;
49186 + current->mm->def_flags |= VM_NOHUGEPAGE;
49187 + }
49188 +#endif
49189 +
49190 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49191 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49192 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49193 + put_cpu();
49194 + }
49195 +#endif
49196
49197 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49198 may depend on the personality. */
49199 SET_PERSONALITY(loc->elf_ex);
49200 +
49201 +#ifdef CONFIG_PAX_ASLR
49202 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49203 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49204 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49205 + }
49206 +#endif
49207 +
49208 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49209 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49210 + executable_stack = EXSTACK_DISABLE_X;
49211 + current->personality &= ~READ_IMPLIES_EXEC;
49212 + } else
49213 +#endif
49214 +
49215 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49216 current->personality |= READ_IMPLIES_EXEC;
49217
49218 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49219 #else
49220 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49221 #endif
49222 +
49223 +#ifdef CONFIG_PAX_RANDMMAP
49224 + /* PaX: randomize base address at the default exe base if requested */
49225 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49226 +#ifdef CONFIG_SPARC64
49227 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49228 +#else
49229 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49230 +#endif
49231 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49232 + elf_flags |= MAP_FIXED;
49233 + }
49234 +#endif
49235 +
49236 }
49237
49238 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49239 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49240 * allowed task size. Note that p_filesz must always be
49241 * <= p_memsz so it is only necessary to check p_memsz.
49242 */
49243 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49244 - elf_ppnt->p_memsz > TASK_SIZE ||
49245 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49246 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49247 + elf_ppnt->p_memsz > pax_task_size ||
49248 + pax_task_size - elf_ppnt->p_memsz < k) {
49249 /* set_brk can never work. Avoid overflows. */
49250 send_sig(SIGKILL, current, 0);
49251 retval = -EINVAL;
49252 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49253 goto out_free_dentry;
49254 }
49255 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49256 - send_sig(SIGSEGV, current, 0);
49257 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49258 - goto out_free_dentry;
49259 + /*
49260 + * This bss-zeroing can fail if the ELF
49261 + * file specifies odd protections. So
49262 + * we don't check the return value
49263 + */
49264 }
49265
49266 +#ifdef CONFIG_PAX_RANDMMAP
49267 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49268 + unsigned long start, size, flags, vm_flags;
49269 +
49270 + start = ELF_PAGEALIGN(elf_brk);
49271 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49272 + flags = MAP_FIXED | MAP_PRIVATE;
49273 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49274 +
49275 + down_write(&current->mm->mmap_sem);
49276 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49277 + retval = -ENOMEM;
49278 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49279 +// if (current->personality & ADDR_NO_RANDOMIZE)
49280 +// vm_flags |= VM_READ | VM_MAYREAD;
49281 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49282 + retval = IS_ERR_VALUE(start) ? start : 0;
49283 + }
49284 + up_write(&current->mm->mmap_sem);
49285 + if (retval == 0)
49286 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49287 + if (retval < 0) {
49288 + send_sig(SIGKILL, current, 0);
49289 + goto out_free_dentry;
49290 + }
49291 + }
49292 +#endif
49293 +
49294 if (elf_interpreter) {
49295 - unsigned long interp_map_addr = 0;
49296 -
49297 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49298 interpreter,
49299 - &interp_map_addr,
49300 load_bias);
49301 if (!IS_ERR((void *)elf_entry)) {
49302 /*
49303 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49304 * Decide what to dump of a segment, part, all or none.
49305 */
49306 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49307 - unsigned long mm_flags)
49308 + unsigned long mm_flags, long signr)
49309 {
49310 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49311
49312 @@ -1153,7 +1599,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49313 if (vma->vm_file == NULL)
49314 return 0;
49315
49316 - if (FILTER(MAPPED_PRIVATE))
49317 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49318 goto whole;
49319
49320 /*
49321 @@ -1375,9 +1821,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49322 {
49323 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49324 int i = 0;
49325 - do
49326 + do {
49327 i += 2;
49328 - while (auxv[i - 2] != AT_NULL);
49329 + } while (auxv[i - 2] != AT_NULL);
49330 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49331 }
49332
49333 @@ -2007,14 +2453,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49334 }
49335
49336 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49337 - unsigned long mm_flags)
49338 + struct coredump_params *cprm)
49339 {
49340 struct vm_area_struct *vma;
49341 size_t size = 0;
49342
49343 for (vma = first_vma(current, gate_vma); vma != NULL;
49344 vma = next_vma(vma, gate_vma))
49345 - size += vma_dump_size(vma, mm_flags);
49346 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49347 return size;
49348 }
49349
49350 @@ -2108,7 +2554,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49351
49352 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49353
49354 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49355 + offset += elf_core_vma_data_size(gate_vma, cprm);
49356 offset += elf_core_extra_data_size();
49357 e_shoff = offset;
49358
49359 @@ -2122,10 +2568,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49360 offset = dataoff;
49361
49362 size += sizeof(*elf);
49363 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49364 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49365 goto end_coredump;
49366
49367 size += sizeof(*phdr4note);
49368 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49369 if (size > cprm->limit
49370 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49371 goto end_coredump;
49372 @@ -2139,7 +2587,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49373 phdr.p_offset = offset;
49374 phdr.p_vaddr = vma->vm_start;
49375 phdr.p_paddr = 0;
49376 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49377 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49378 phdr.p_memsz = vma->vm_end - vma->vm_start;
49379 offset += phdr.p_filesz;
49380 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49381 @@ -2150,6 +2598,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49382 phdr.p_align = ELF_EXEC_PAGESIZE;
49383
49384 size += sizeof(phdr);
49385 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49386 if (size > cprm->limit
49387 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49388 goto end_coredump;
49389 @@ -2174,7 +2623,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49390 unsigned long addr;
49391 unsigned long end;
49392
49393 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49394 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49395
49396 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49397 struct page *page;
49398 @@ -2183,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49399 page = get_dump_page(addr);
49400 if (page) {
49401 void *kaddr = kmap(page);
49402 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49403 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49404 !dump_write(cprm->file, kaddr,
49405 PAGE_SIZE);
49406 @@ -2200,6 +2650,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49407
49408 if (e_phnum == PN_XNUM) {
49409 size += sizeof(*shdr4extnum);
49410 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49411 if (size > cprm->limit
49412 || !dump_write(cprm->file, shdr4extnum,
49413 sizeof(*shdr4extnum)))
49414 @@ -2220,6 +2671,97 @@ out:
49415
49416 #endif /* CONFIG_ELF_CORE */
49417
49418 +#ifdef CONFIG_PAX_MPROTECT
49419 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49420 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49421 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49422 + *
49423 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49424 + * basis because we want to allow the common case and not the special ones.
49425 + */
49426 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49427 +{
49428 + struct elfhdr elf_h;
49429 + struct elf_phdr elf_p;
49430 + unsigned long i;
49431 + unsigned long oldflags;
49432 + bool is_textrel_rw, is_textrel_rx, is_relro;
49433 +
49434 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49435 + return;
49436 +
49437 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49438 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49439 +
49440 +#ifdef CONFIG_PAX_ELFRELOCS
49441 + /* possible TEXTREL */
49442 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49443 + is_textrel_rx = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
49444 +#else
49445 + is_textrel_rw = false;
49446 + is_textrel_rx = false;
49447 +#endif
49448 +
49449 + /* possible RELRO */
49450 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49451 +
49452 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49453 + return;
49454 +
49455 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49456 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49457 +
49458 +#ifdef CONFIG_PAX_ETEXECRELOCS
49459 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49460 +#else
49461 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49462 +#endif
49463 +
49464 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49465 + !elf_check_arch(&elf_h) ||
49466 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49467 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49468 + return;
49469 +
49470 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49471 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49472 + return;
49473 + switch (elf_p.p_type) {
49474 + case PT_DYNAMIC:
49475 + if (!is_textrel_rw && !is_textrel_rx)
49476 + continue;
49477 + i = 0UL;
49478 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49479 + elf_dyn dyn;
49480 +
49481 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49482 + return;
49483 + if (dyn.d_tag == DT_NULL)
49484 + return;
49485 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49486 + gr_log_textrel(vma);
49487 + if (is_textrel_rw)
49488 + vma->vm_flags |= VM_MAYWRITE;
49489 + else
49490 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49491 + vma->vm_flags &= ~VM_MAYWRITE;
49492 + return;
49493 + }
49494 + i++;
49495 + }
49496 + return;
49497 +
49498 + case PT_GNU_RELRO:
49499 + if (!is_relro)
49500 + continue;
49501 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49502 + vma->vm_flags &= ~VM_MAYWRITE;
49503 + return;
49504 + }
49505 + }
49506 +}
49507 +#endif
49508 +
49509 static int __init init_elf_binfmt(void)
49510 {
49511 register_binfmt(&elf_format);
49512 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49513 index b563719..3868998 100644
49514 --- a/fs/binfmt_flat.c
49515 +++ b/fs/binfmt_flat.c
49516 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49517 realdatastart = (unsigned long) -ENOMEM;
49518 printk("Unable to allocate RAM for process data, errno %d\n",
49519 (int)-realdatastart);
49520 + down_write(&current->mm->mmap_sem);
49521 vm_munmap(textpos, text_len);
49522 + up_write(&current->mm->mmap_sem);
49523 ret = realdatastart;
49524 goto err;
49525 }
49526 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49527 }
49528 if (IS_ERR_VALUE(result)) {
49529 printk("Unable to read data+bss, errno %d\n", (int)-result);
49530 + down_write(&current->mm->mmap_sem);
49531 vm_munmap(textpos, text_len);
49532 vm_munmap(realdatastart, len);
49533 + up_write(&current->mm->mmap_sem);
49534 ret = result;
49535 goto err;
49536 }
49537 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49538 }
49539 if (IS_ERR_VALUE(result)) {
49540 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49541 + down_write(&current->mm->mmap_sem);
49542 vm_munmap(textpos, text_len + data_len + extra +
49543 MAX_SHARED_LIBS * sizeof(unsigned long));
49544 + up_write(&current->mm->mmap_sem);
49545 ret = result;
49546 goto err;
49547 }
49548 diff --git a/fs/bio.c b/fs/bio.c
49549 index b96fc6c..431d628 100644
49550 --- a/fs/bio.c
49551 +++ b/fs/bio.c
49552 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49553 /*
49554 * Overflow, abort
49555 */
49556 - if (end < start)
49557 + if (end < start || end - start > INT_MAX - nr_pages)
49558 return ERR_PTR(-EINVAL);
49559
49560 nr_pages += end - start;
49561 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49562 /*
49563 * Overflow, abort
49564 */
49565 - if (end < start)
49566 + if (end < start || end - start > INT_MAX - nr_pages)
49567 return ERR_PTR(-EINVAL);
49568
49569 nr_pages += end - start;
49570 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49571 const int read = bio_data_dir(bio) == READ;
49572 struct bio_map_data *bmd = bio->bi_private;
49573 int i;
49574 - char *p = bmd->sgvecs[0].iov_base;
49575 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49576
49577 __bio_for_each_segment(bvec, bio, i, 0) {
49578 char *addr = page_address(bvec->bv_page);
49579 diff --git a/fs/block_dev.c b/fs/block_dev.c
49580 index 883dc49..f27794a 100644
49581 --- a/fs/block_dev.c
49582 +++ b/fs/block_dev.c
49583 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49584 else if (bdev->bd_contains == bdev)
49585 return true; /* is a whole device which isn't held */
49586
49587 - else if (whole->bd_holder == bd_may_claim)
49588 + else if (whole->bd_holder == (void *)bd_may_claim)
49589 return true; /* is a partition of a device that is being partitioned */
49590 else if (whole->bd_holder != NULL)
49591 return false; /* is a partition of a held device */
49592 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49593 index ce1c169..1ef484f 100644
49594 --- a/fs/btrfs/ctree.c
49595 +++ b/fs/btrfs/ctree.c
49596 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49597 free_extent_buffer(buf);
49598 add_root_to_dirty_list(root);
49599 } else {
49600 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49601 - parent_start = parent->start;
49602 - else
49603 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49604 + if (parent)
49605 + parent_start = parent->start;
49606 + else
49607 + parent_start = 0;
49608 + } else
49609 parent_start = 0;
49610
49611 WARN_ON(trans->transid != btrfs_header_generation(parent));
49612 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
49613 index d170412..a575d77 100644
49614 --- a/fs/btrfs/extent-tree.c
49615 +++ b/fs/btrfs/extent-tree.c
49616 @@ -6019,7 +6019,7 @@ again:
49617 if (ret == -ENOSPC) {
49618 if (!final_tried) {
49619 num_bytes = num_bytes >> 1;
49620 - num_bytes = num_bytes & ~(root->sectorsize - 1);
49621 + num_bytes = num_bytes & ~((u64)root->sectorsize - 1);
49622 num_bytes = max(num_bytes, min_alloc_size);
49623 if (num_bytes == min_alloc_size)
49624 final_tried = true;
49625 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49626 index 7c4e6cc..8ad78b2 100644
49627 --- a/fs/btrfs/inode.c
49628 +++ b/fs/btrfs/inode.c
49629 @@ -17,6 +17,7 @@
49630 */
49631
49632 #include <linux/kernel.h>
49633 +#include <linux/module.h>
49634 #include <linux/bio.h>
49635 #include <linux/buffer_head.h>
49636 #include <linux/file.h>
49637 @@ -7314,7 +7315,7 @@ fail:
49638 return -ENOMEM;
49639 }
49640
49641 -static int btrfs_getattr(struct vfsmount *mnt,
49642 +int btrfs_getattr(struct vfsmount *mnt,
49643 struct dentry *dentry, struct kstat *stat)
49644 {
49645 struct inode *inode = dentry->d_inode;
49646 @@ -7328,6 +7329,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49647 return 0;
49648 }
49649
49650 +EXPORT_SYMBOL(btrfs_getattr);
49651 +
49652 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49653 +{
49654 + return BTRFS_I(inode)->root->anon_dev;
49655 +}
49656 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49657 +
49658 /*
49659 * If a file is moved, it will inherit the cow and compression flags of the new
49660 * directory.
49661 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49662 index 338f259..b657640 100644
49663 --- a/fs/btrfs/ioctl.c
49664 +++ b/fs/btrfs/ioctl.c
49665 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49666 for (i = 0; i < num_types; i++) {
49667 struct btrfs_space_info *tmp;
49668
49669 + /* Don't copy in more than we allocated */
49670 if (!slot_count)
49671 break;
49672
49673 + slot_count--;
49674 +
49675 info = NULL;
49676 rcu_read_lock();
49677 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49678 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49679 memcpy(dest, &space, sizeof(space));
49680 dest++;
49681 space_args.total_spaces++;
49682 - slot_count--;
49683 }
49684 - if (!slot_count)
49685 - break;
49686 }
49687 up_read(&info->groups_sem);
49688 }
49689 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49690 index 300e09a..9fe4539 100644
49691 --- a/fs/btrfs/relocation.c
49692 +++ b/fs/btrfs/relocation.c
49693 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49694 }
49695 spin_unlock(&rc->reloc_root_tree.lock);
49696
49697 - BUG_ON((struct btrfs_root *)node->data != root);
49698 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49699
49700 if (!del) {
49701 spin_lock(&rc->reloc_root_tree.lock);
49702 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49703 index d8982e9..29a85fa 100644
49704 --- a/fs/btrfs/super.c
49705 +++ b/fs/btrfs/super.c
49706 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49707 function, line, errstr);
49708 return;
49709 }
49710 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49711 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49712 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49713 }
49714 /*
49715 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49716 index 622f469..e8d2d55 100644
49717 --- a/fs/cachefiles/bind.c
49718 +++ b/fs/cachefiles/bind.c
49719 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49720 args);
49721
49722 /* start by checking things over */
49723 - ASSERT(cache->fstop_percent >= 0 &&
49724 - cache->fstop_percent < cache->fcull_percent &&
49725 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49726 cache->fcull_percent < cache->frun_percent &&
49727 cache->frun_percent < 100);
49728
49729 - ASSERT(cache->bstop_percent >= 0 &&
49730 - cache->bstop_percent < cache->bcull_percent &&
49731 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49732 cache->bcull_percent < cache->brun_percent &&
49733 cache->brun_percent < 100);
49734
49735 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49736 index 0a1467b..6a53245 100644
49737 --- a/fs/cachefiles/daemon.c
49738 +++ b/fs/cachefiles/daemon.c
49739 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49740 if (n > buflen)
49741 return -EMSGSIZE;
49742
49743 - if (copy_to_user(_buffer, buffer, n) != 0)
49744 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49745 return -EFAULT;
49746
49747 return n;
49748 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49749 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49750 return -EIO;
49751
49752 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49753 + if (datalen > PAGE_SIZE - 1)
49754 return -EOPNOTSUPP;
49755
49756 /* drag the command string into the kernel so we can parse it */
49757 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49758 if (args[0] != '%' || args[1] != '\0')
49759 return -EINVAL;
49760
49761 - if (fstop < 0 || fstop >= cache->fcull_percent)
49762 + if (fstop >= cache->fcull_percent)
49763 return cachefiles_daemon_range_error(cache, args);
49764
49765 cache->fstop_percent = fstop;
49766 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49767 if (args[0] != '%' || args[1] != '\0')
49768 return -EINVAL;
49769
49770 - if (bstop < 0 || bstop >= cache->bcull_percent)
49771 + if (bstop >= cache->bcull_percent)
49772 return cachefiles_daemon_range_error(cache, args);
49773
49774 cache->bstop_percent = bstop;
49775 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49776 index 4938251..7e01445 100644
49777 --- a/fs/cachefiles/internal.h
49778 +++ b/fs/cachefiles/internal.h
49779 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49780 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49781 struct rb_root active_nodes; /* active nodes (can't be culled) */
49782 rwlock_t active_lock; /* lock for active_nodes */
49783 - atomic_t gravecounter; /* graveyard uniquifier */
49784 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49785 unsigned frun_percent; /* when to stop culling (% files) */
49786 unsigned fcull_percent; /* when to start culling (% files) */
49787 unsigned fstop_percent; /* when to stop allocating (% files) */
49788 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49789 * proc.c
49790 */
49791 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49792 -extern atomic_t cachefiles_lookup_histogram[HZ];
49793 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49794 -extern atomic_t cachefiles_create_histogram[HZ];
49795 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49796 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49797 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49798
49799 extern int __init cachefiles_proc_init(void);
49800 extern void cachefiles_proc_cleanup(void);
49801 static inline
49802 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49803 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49804 {
49805 unsigned long jif = jiffies - start_jif;
49806 if (jif >= HZ)
49807 jif = HZ - 1;
49808 - atomic_inc(&histogram[jif]);
49809 + atomic_inc_unchecked(&histogram[jif]);
49810 }
49811
49812 #else
49813 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49814 index 8c01c5fc..15f982e 100644
49815 --- a/fs/cachefiles/namei.c
49816 +++ b/fs/cachefiles/namei.c
49817 @@ -317,7 +317,7 @@ try_again:
49818 /* first step is to make up a grave dentry in the graveyard */
49819 sprintf(nbuffer, "%08x%08x",
49820 (uint32_t) get_seconds(),
49821 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49822 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49823
49824 /* do the multiway lock magic */
49825 trap = lock_rename(cache->graveyard, dir);
49826 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49827 index eccd339..4c1d995 100644
49828 --- a/fs/cachefiles/proc.c
49829 +++ b/fs/cachefiles/proc.c
49830 @@ -14,9 +14,9 @@
49831 #include <linux/seq_file.h>
49832 #include "internal.h"
49833
49834 -atomic_t cachefiles_lookup_histogram[HZ];
49835 -atomic_t cachefiles_mkdir_histogram[HZ];
49836 -atomic_t cachefiles_create_histogram[HZ];
49837 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49838 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49839 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49840
49841 /*
49842 * display the latency histogram
49843 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49844 return 0;
49845 default:
49846 index = (unsigned long) v - 3;
49847 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49848 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49849 - z = atomic_read(&cachefiles_create_histogram[index]);
49850 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49851 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49852 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49853 if (x == 0 && y == 0 && z == 0)
49854 return 0;
49855
49856 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49857 index 4809922..aab2c39 100644
49858 --- a/fs/cachefiles/rdwr.c
49859 +++ b/fs/cachefiles/rdwr.c
49860 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49861 old_fs = get_fs();
49862 set_fs(KERNEL_DS);
49863 ret = file->f_op->write(
49864 - file, (const void __user *) data, len, &pos);
49865 + file, (const void __force_user *) data, len, &pos);
49866 set_fs(old_fs);
49867 kunmap(page);
49868 if (ret != len)
49869 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49870 index 8c1aabe..bbf856a 100644
49871 --- a/fs/ceph/dir.c
49872 +++ b/fs/ceph/dir.c
49873 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49874 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49875 struct ceph_mds_client *mdsc = fsc->mdsc;
49876 unsigned frag = fpos_frag(filp->f_pos);
49877 - int off = fpos_off(filp->f_pos);
49878 + unsigned int off = fpos_off(filp->f_pos);
49879 int err;
49880 u32 ftype;
49881 struct ceph_mds_reply_info_parsed *rinfo;
49882 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49883 index d9ea6ed..1e6c8ac 100644
49884 --- a/fs/cifs/cifs_debug.c
49885 +++ b/fs/cifs/cifs_debug.c
49886 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49887
49888 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49889 #ifdef CONFIG_CIFS_STATS2
49890 - atomic_set(&totBufAllocCount, 0);
49891 - atomic_set(&totSmBufAllocCount, 0);
49892 + atomic_set_unchecked(&totBufAllocCount, 0);
49893 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49894 #endif /* CONFIG_CIFS_STATS2 */
49895 spin_lock(&cifs_tcp_ses_lock);
49896 list_for_each(tmp1, &cifs_tcp_ses_list) {
49897 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49898 tcon = list_entry(tmp3,
49899 struct cifs_tcon,
49900 tcon_list);
49901 - atomic_set(&tcon->num_smbs_sent, 0);
49902 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49903 if (server->ops->clear_stats)
49904 server->ops->clear_stats(tcon);
49905 }
49906 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49907 smBufAllocCount.counter, cifs_min_small);
49908 #ifdef CONFIG_CIFS_STATS2
49909 seq_printf(m, "Total Large %d Small %d Allocations\n",
49910 - atomic_read(&totBufAllocCount),
49911 - atomic_read(&totSmBufAllocCount));
49912 + atomic_read_unchecked(&totBufAllocCount),
49913 + atomic_read_unchecked(&totSmBufAllocCount));
49914 #endif /* CONFIG_CIFS_STATS2 */
49915
49916 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49917 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49918 if (tcon->need_reconnect)
49919 seq_puts(m, "\tDISCONNECTED ");
49920 seq_printf(m, "\nSMBs: %d",
49921 - atomic_read(&tcon->num_smbs_sent));
49922 + atomic_read_unchecked(&tcon->num_smbs_sent));
49923 if (server->ops->print_stats)
49924 server->ops->print_stats(m, tcon);
49925 }
49926 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49927 index b9db388..9a73d6d 100644
49928 --- a/fs/cifs/cifsfs.c
49929 +++ b/fs/cifs/cifsfs.c
49930 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49931 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49932 cifs_req_cachep = kmem_cache_create("cifs_request",
49933 CIFSMaxBufSize + max_hdr_size, 0,
49934 - SLAB_HWCACHE_ALIGN, NULL);
49935 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49936 if (cifs_req_cachep == NULL)
49937 return -ENOMEM;
49938
49939 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49940 efficient to alloc 1 per page off the slab compared to 17K (5page)
49941 alloc of large cifs buffers even when page debugging is on */
49942 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49943 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49944 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49945 NULL);
49946 if (cifs_sm_req_cachep == NULL) {
49947 mempool_destroy(cifs_req_poolp);
49948 @@ -1138,8 +1138,8 @@ init_cifs(void)
49949 atomic_set(&bufAllocCount, 0);
49950 atomic_set(&smBufAllocCount, 0);
49951 #ifdef CONFIG_CIFS_STATS2
49952 - atomic_set(&totBufAllocCount, 0);
49953 - atomic_set(&totSmBufAllocCount, 0);
49954 + atomic_set_unchecked(&totBufAllocCount, 0);
49955 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49956 #endif /* CONFIG_CIFS_STATS2 */
49957
49958 atomic_set(&midCount, 0);
49959 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49960 index e6899ce..d6b2920 100644
49961 --- a/fs/cifs/cifsglob.h
49962 +++ b/fs/cifs/cifsglob.h
49963 @@ -751,35 +751,35 @@ struct cifs_tcon {
49964 __u16 Flags; /* optional support bits */
49965 enum statusEnum tidStatus;
49966 #ifdef CONFIG_CIFS_STATS
49967 - atomic_t num_smbs_sent;
49968 + atomic_unchecked_t num_smbs_sent;
49969 union {
49970 struct {
49971 - atomic_t num_writes;
49972 - atomic_t num_reads;
49973 - atomic_t num_flushes;
49974 - atomic_t num_oplock_brks;
49975 - atomic_t num_opens;
49976 - atomic_t num_closes;
49977 - atomic_t num_deletes;
49978 - atomic_t num_mkdirs;
49979 - atomic_t num_posixopens;
49980 - atomic_t num_posixmkdirs;
49981 - atomic_t num_rmdirs;
49982 - atomic_t num_renames;
49983 - atomic_t num_t2renames;
49984 - atomic_t num_ffirst;
49985 - atomic_t num_fnext;
49986 - atomic_t num_fclose;
49987 - atomic_t num_hardlinks;
49988 - atomic_t num_symlinks;
49989 - atomic_t num_locks;
49990 - atomic_t num_acl_get;
49991 - atomic_t num_acl_set;
49992 + atomic_unchecked_t num_writes;
49993 + atomic_unchecked_t num_reads;
49994 + atomic_unchecked_t num_flushes;
49995 + atomic_unchecked_t num_oplock_brks;
49996 + atomic_unchecked_t num_opens;
49997 + atomic_unchecked_t num_closes;
49998 + atomic_unchecked_t num_deletes;
49999 + atomic_unchecked_t num_mkdirs;
50000 + atomic_unchecked_t num_posixopens;
50001 + atomic_unchecked_t num_posixmkdirs;
50002 + atomic_unchecked_t num_rmdirs;
50003 + atomic_unchecked_t num_renames;
50004 + atomic_unchecked_t num_t2renames;
50005 + atomic_unchecked_t num_ffirst;
50006 + atomic_unchecked_t num_fnext;
50007 + atomic_unchecked_t num_fclose;
50008 + atomic_unchecked_t num_hardlinks;
50009 + atomic_unchecked_t num_symlinks;
50010 + atomic_unchecked_t num_locks;
50011 + atomic_unchecked_t num_acl_get;
50012 + atomic_unchecked_t num_acl_set;
50013 } cifs_stats;
50014 #ifdef CONFIG_CIFS_SMB2
50015 struct {
50016 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50017 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50018 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
50019 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
50020 } smb2_stats;
50021 #endif /* CONFIG_CIFS_SMB2 */
50022 } stats;
50023 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
50024 }
50025
50026 #ifdef CONFIG_CIFS_STATS
50027 -#define cifs_stats_inc atomic_inc
50028 +#define cifs_stats_inc atomic_inc_unchecked
50029
50030 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
50031 unsigned int bytes)
50032 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
50033 /* Various Debug counters */
50034 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
50035 #ifdef CONFIG_CIFS_STATS2
50036 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
50037 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
50038 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
50039 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
50040 #endif
50041 GLOBAL_EXTERN atomic_t smBufAllocCount;
50042 GLOBAL_EXTERN atomic_t midCount;
50043 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
50044 index 51dc2fb..1e12a33 100644
50045 --- a/fs/cifs/link.c
50046 +++ b/fs/cifs/link.c
50047 @@ -616,7 +616,7 @@ symlink_exit:
50048
50049 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50050 {
50051 - char *p = nd_get_link(nd);
50052 + const char *p = nd_get_link(nd);
50053 if (!IS_ERR(p))
50054 kfree(p);
50055 }
50056 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50057 index 3a00c0d..42d901c 100644
50058 --- a/fs/cifs/misc.c
50059 +++ b/fs/cifs/misc.c
50060 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50061 memset(ret_buf, 0, buf_size + 3);
50062 atomic_inc(&bufAllocCount);
50063 #ifdef CONFIG_CIFS_STATS2
50064 - atomic_inc(&totBufAllocCount);
50065 + atomic_inc_unchecked(&totBufAllocCount);
50066 #endif /* CONFIG_CIFS_STATS2 */
50067 }
50068
50069 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50070 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50071 atomic_inc(&smBufAllocCount);
50072 #ifdef CONFIG_CIFS_STATS2
50073 - atomic_inc(&totSmBufAllocCount);
50074 + atomic_inc_unchecked(&totSmBufAllocCount);
50075 #endif /* CONFIG_CIFS_STATS2 */
50076
50077 }
50078 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50079 index 47bc5a8..10decbe 100644
50080 --- a/fs/cifs/smb1ops.c
50081 +++ b/fs/cifs/smb1ops.c
50082 @@ -586,27 +586,27 @@ static void
50083 cifs_clear_stats(struct cifs_tcon *tcon)
50084 {
50085 #ifdef CONFIG_CIFS_STATS
50086 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50087 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50088 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50089 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50090 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50091 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50092 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50093 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50094 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50095 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50096 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50097 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50098 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50099 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50100 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50101 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50102 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50103 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50104 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50105 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50106 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50107 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50108 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50109 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50110 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50111 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50112 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50113 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50114 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50115 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50116 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50117 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50118 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50119 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50120 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50121 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50122 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50123 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50124 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50125 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50126 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50127 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50128 #endif
50129 }
50130
50131 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50132 {
50133 #ifdef CONFIG_CIFS_STATS
50134 seq_printf(m, " Oplocks breaks: %d",
50135 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50136 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50137 seq_printf(m, "\nReads: %d Bytes: %llu",
50138 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50139 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50140 (long long)(tcon->bytes_read));
50141 seq_printf(m, "\nWrites: %d Bytes: %llu",
50142 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50143 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50144 (long long)(tcon->bytes_written));
50145 seq_printf(m, "\nFlushes: %d",
50146 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50147 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50148 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50149 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50150 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50151 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50152 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50153 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50154 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50155 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50156 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50157 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50158 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50159 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50160 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50161 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50162 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50163 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50164 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50165 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50166 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50167 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50168 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50169 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50170 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50171 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50172 seq_printf(m, "\nRenames: %d T2 Renames %d",
50173 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50174 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50175 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50176 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50177 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50178 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50179 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50180 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50181 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50182 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50183 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50184 #endif
50185 }
50186
50187 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50188 index bceffe7..cd1ae59 100644
50189 --- a/fs/cifs/smb2ops.c
50190 +++ b/fs/cifs/smb2ops.c
50191 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50192 #ifdef CONFIG_CIFS_STATS
50193 int i;
50194 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50195 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50196 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50197 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50198 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50199 }
50200 #endif
50201 }
50202 @@ -284,66 +284,66 @@ static void
50203 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50204 {
50205 #ifdef CONFIG_CIFS_STATS
50206 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50207 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50208 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50209 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50210 seq_printf(m, "\nNegotiates: %d sent %d failed",
50211 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50212 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50213 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50214 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50215 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50216 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50217 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50218 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50219 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50220 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50221 seq_printf(m, "\nLogoffs: %d sent %d failed",
50222 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50223 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50224 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50225 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50226 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50227 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50228 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50229 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50230 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50231 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50232 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50233 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50234 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50235 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50236 seq_printf(m, "\nCreates: %d sent %d failed",
50237 - atomic_read(&sent[SMB2_CREATE_HE]),
50238 - atomic_read(&failed[SMB2_CREATE_HE]));
50239 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50240 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50241 seq_printf(m, "\nCloses: %d sent %d failed",
50242 - atomic_read(&sent[SMB2_CLOSE_HE]),
50243 - atomic_read(&failed[SMB2_CLOSE_HE]));
50244 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50245 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50246 seq_printf(m, "\nFlushes: %d sent %d failed",
50247 - atomic_read(&sent[SMB2_FLUSH_HE]),
50248 - atomic_read(&failed[SMB2_FLUSH_HE]));
50249 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50250 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50251 seq_printf(m, "\nReads: %d sent %d failed",
50252 - atomic_read(&sent[SMB2_READ_HE]),
50253 - atomic_read(&failed[SMB2_READ_HE]));
50254 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50255 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50256 seq_printf(m, "\nWrites: %d sent %d failed",
50257 - atomic_read(&sent[SMB2_WRITE_HE]),
50258 - atomic_read(&failed[SMB2_WRITE_HE]));
50259 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50260 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50261 seq_printf(m, "\nLocks: %d sent %d failed",
50262 - atomic_read(&sent[SMB2_LOCK_HE]),
50263 - atomic_read(&failed[SMB2_LOCK_HE]));
50264 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50265 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50266 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50267 - atomic_read(&sent[SMB2_IOCTL_HE]),
50268 - atomic_read(&failed[SMB2_IOCTL_HE]));
50269 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50270 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50271 seq_printf(m, "\nCancels: %d sent %d failed",
50272 - atomic_read(&sent[SMB2_CANCEL_HE]),
50273 - atomic_read(&failed[SMB2_CANCEL_HE]));
50274 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50275 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50276 seq_printf(m, "\nEchos: %d sent %d failed",
50277 - atomic_read(&sent[SMB2_ECHO_HE]),
50278 - atomic_read(&failed[SMB2_ECHO_HE]));
50279 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50280 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50281 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50282 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50283 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50284 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50285 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50286 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50287 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50288 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50289 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50290 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50291 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50292 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50293 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50294 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50295 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50296 seq_printf(m, "\nSetInfos: %d sent %d failed",
50297 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50298 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50299 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50300 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50301 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50302 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50303 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50304 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50305 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50306 #endif
50307 }
50308
50309 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50310 index 41d9d07..dbb4772 100644
50311 --- a/fs/cifs/smb2pdu.c
50312 +++ b/fs/cifs/smb2pdu.c
50313 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50314 default:
50315 cERROR(1, "info level %u isn't supported",
50316 srch_inf->info_level);
50317 - rc = -EINVAL;
50318 - goto qdir_exit;
50319 + return -EINVAL;
50320 }
50321
50322 req->FileIndex = cpu_to_le32(index);
50323 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50324 index 958ae0e..505c9d0 100644
50325 --- a/fs/coda/cache.c
50326 +++ b/fs/coda/cache.c
50327 @@ -24,7 +24,7 @@
50328 #include "coda_linux.h"
50329 #include "coda_cache.h"
50330
50331 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50332 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50333
50334 /* replace or extend an acl cache hit */
50335 void coda_cache_enter(struct inode *inode, int mask)
50336 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50337 struct coda_inode_info *cii = ITOC(inode);
50338
50339 spin_lock(&cii->c_lock);
50340 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50341 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50342 if (cii->c_uid != current_fsuid()) {
50343 cii->c_uid = current_fsuid();
50344 cii->c_cached_perm = mask;
50345 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50346 {
50347 struct coda_inode_info *cii = ITOC(inode);
50348 spin_lock(&cii->c_lock);
50349 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50350 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50351 spin_unlock(&cii->c_lock);
50352 }
50353
50354 /* remove all acl caches */
50355 void coda_cache_clear_all(struct super_block *sb)
50356 {
50357 - atomic_inc(&permission_epoch);
50358 + atomic_inc_unchecked(&permission_epoch);
50359 }
50360
50361
50362 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50363 spin_lock(&cii->c_lock);
50364 hit = (mask & cii->c_cached_perm) == mask &&
50365 cii->c_uid == current_fsuid() &&
50366 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50367 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50368 spin_unlock(&cii->c_lock);
50369
50370 return hit;
50371 diff --git a/fs/compat.c b/fs/compat.c
50372 index a06dcbc..dacb6d3 100644
50373 --- a/fs/compat.c
50374 +++ b/fs/compat.c
50375 @@ -54,7 +54,7 @@
50376 #include <asm/ioctls.h>
50377 #include "internal.h"
50378
50379 -int compat_log = 1;
50380 +int compat_log = 0;
50381
50382 int compat_printk(const char *fmt, ...)
50383 {
50384 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50385
50386 set_fs(KERNEL_DS);
50387 /* The __user pointer cast is valid because of the set_fs() */
50388 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50389 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50390 set_fs(oldfs);
50391 /* truncating is ok because it's a user address */
50392 if (!ret)
50393 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50394 goto out;
50395
50396 ret = -EINVAL;
50397 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50398 + if (nr_segs > UIO_MAXIOV)
50399 goto out;
50400 if (nr_segs > fast_segs) {
50401 ret = -ENOMEM;
50402 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50403
50404 struct compat_readdir_callback {
50405 struct compat_old_linux_dirent __user *dirent;
50406 + struct file * file;
50407 int result;
50408 };
50409
50410 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50411 buf->result = -EOVERFLOW;
50412 return -EOVERFLOW;
50413 }
50414 +
50415 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50416 + return 0;
50417 +
50418 buf->result++;
50419 dirent = buf->dirent;
50420 if (!access_ok(VERIFY_WRITE, dirent,
50421 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50422
50423 buf.result = 0;
50424 buf.dirent = dirent;
50425 + buf.file = f.file;
50426
50427 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50428 if (buf.result)
50429 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50430 struct compat_getdents_callback {
50431 struct compat_linux_dirent __user *current_dir;
50432 struct compat_linux_dirent __user *previous;
50433 + struct file * file;
50434 int count;
50435 int error;
50436 };
50437 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50438 buf->error = -EOVERFLOW;
50439 return -EOVERFLOW;
50440 }
50441 +
50442 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50443 + return 0;
50444 +
50445 dirent = buf->previous;
50446 if (dirent) {
50447 if (__put_user(offset, &dirent->d_off))
50448 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50449 buf.previous = NULL;
50450 buf.count = count;
50451 buf.error = 0;
50452 + buf.file = f.file;
50453
50454 error = vfs_readdir(f.file, compat_filldir, &buf);
50455 if (error >= 0)
50456 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50457 struct compat_getdents_callback64 {
50458 struct linux_dirent64 __user *current_dir;
50459 struct linux_dirent64 __user *previous;
50460 + struct file * file;
50461 int count;
50462 int error;
50463 };
50464 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50465 buf->error = -EINVAL; /* only used if we fail.. */
50466 if (reclen > buf->count)
50467 return -EINVAL;
50468 +
50469 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50470 + return 0;
50471 +
50472 dirent = buf->previous;
50473
50474 if (dirent) {
50475 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50476 buf.previous = NULL;
50477 buf.count = count;
50478 buf.error = 0;
50479 + buf.file = f.file;
50480
50481 error = vfs_readdir(f.file, compat_filldir64, &buf);
50482 if (error >= 0)
50483 error = buf.error;
50484 lastdirent = buf.previous;
50485 if (lastdirent) {
50486 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50487 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50488 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50489 error = -EFAULT;
50490 else
50491 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50492 index a81147e..20bf2b5 100644
50493 --- a/fs/compat_binfmt_elf.c
50494 +++ b/fs/compat_binfmt_elf.c
50495 @@ -30,11 +30,13 @@
50496 #undef elf_phdr
50497 #undef elf_shdr
50498 #undef elf_note
50499 +#undef elf_dyn
50500 #undef elf_addr_t
50501 #define elfhdr elf32_hdr
50502 #define elf_phdr elf32_phdr
50503 #define elf_shdr elf32_shdr
50504 #define elf_note elf32_note
50505 +#define elf_dyn Elf32_Dyn
50506 #define elf_addr_t Elf32_Addr
50507
50508 /*
50509 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50510 index e2f57a0..3c78771 100644
50511 --- a/fs/compat_ioctl.c
50512 +++ b/fs/compat_ioctl.c
50513 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50514 return -EFAULT;
50515 if (__get_user(udata, &ss32->iomem_base))
50516 return -EFAULT;
50517 - ss.iomem_base = compat_ptr(udata);
50518 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50519 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50520 __get_user(ss.port_high, &ss32->port_high))
50521 return -EFAULT;
50522 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50523 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50524 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50525 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50526 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50527 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50528 return -EFAULT;
50529
50530 return ioctl_preallocate(file, p);
50531 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50532 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50533 {
50534 unsigned int a, b;
50535 - a = *(unsigned int *)p;
50536 - b = *(unsigned int *)q;
50537 + a = *(const unsigned int *)p;
50538 + b = *(const unsigned int *)q;
50539 if (a > b)
50540 return 1;
50541 if (a < b)
50542 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50543 index 712b10f..c33c4ca 100644
50544 --- a/fs/configfs/dir.c
50545 +++ b/fs/configfs/dir.c
50546 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50547 static int configfs_depend_prep(struct dentry *origin,
50548 struct config_item *target)
50549 {
50550 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50551 + struct configfs_dirent *child_sd, *sd;
50552 int ret = 0;
50553
50554 - BUG_ON(!origin || !sd);
50555 + BUG_ON(!origin || !origin->d_fsdata);
50556 + sd = origin->d_fsdata;
50557
50558 if (sd->s_element == target) /* Boo-yah */
50559 goto out;
50560 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50561 }
50562 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50563 struct configfs_dirent *next;
50564 - const char * name;
50565 + const unsigned char * name;
50566 + char d_name[sizeof(next->s_dentry->d_iname)];
50567 int len;
50568 struct inode *inode = NULL;
50569
50570 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50571 continue;
50572
50573 name = configfs_get_name(next);
50574 - len = strlen(name);
50575 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50576 + len = next->s_dentry->d_name.len;
50577 + memcpy(d_name, name, len);
50578 + name = d_name;
50579 + } else
50580 + len = strlen(name);
50581
50582 /*
50583 * We'll have a dentry and an inode for
50584 diff --git a/fs/coredump.c b/fs/coredump.c
50585 index 1774932..5812106 100644
50586 --- a/fs/coredump.c
50587 +++ b/fs/coredump.c
50588 @@ -52,7 +52,7 @@ struct core_name {
50589 char *corename;
50590 int used, size;
50591 };
50592 -static atomic_t call_count = ATOMIC_INIT(1);
50593 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50594
50595 /* The maximal length of core_pattern is also specified in sysctl.c */
50596
50597 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50598 {
50599 char *old_corename = cn->corename;
50600
50601 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50602 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50603 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50604
50605 if (!cn->corename) {
50606 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50607 int pid_in_pattern = 0;
50608 int err = 0;
50609
50610 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50611 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50612 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50613 cn->used = 0;
50614
50615 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50616 pipe = file->f_path.dentry->d_inode->i_pipe;
50617
50618 pipe_lock(pipe);
50619 - pipe->readers++;
50620 - pipe->writers--;
50621 + atomic_inc(&pipe->readers);
50622 + atomic_dec(&pipe->writers);
50623
50624 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50625 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50626 wake_up_interruptible_sync(&pipe->wait);
50627 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50628 pipe_wait(pipe);
50629 }
50630
50631 - pipe->readers--;
50632 - pipe->writers++;
50633 + atomic_dec(&pipe->readers);
50634 + atomic_inc(&pipe->writers);
50635 pipe_unlock(pipe);
50636
50637 }
50638 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50639 int ispipe;
50640 struct files_struct *displaced;
50641 bool need_nonrelative = false;
50642 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50643 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50644 + long signr = siginfo->si_signo;
50645 struct coredump_params cprm = {
50646 .siginfo = siginfo,
50647 .regs = signal_pt_regs(),
50648 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50649 .mm_flags = mm->flags,
50650 };
50651
50652 - audit_core_dumps(siginfo->si_signo);
50653 + audit_core_dumps(signr);
50654 +
50655 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50656 + gr_handle_brute_attach(cprm.mm_flags);
50657
50658 binfmt = mm->binfmt;
50659 if (!binfmt || !binfmt->core_dump)
50660 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50661 need_nonrelative = true;
50662 }
50663
50664 - retval = coredump_wait(siginfo->si_signo, &core_state);
50665 + retval = coredump_wait(signr, &core_state);
50666 if (retval < 0)
50667 goto fail_creds;
50668
50669 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50670 }
50671 cprm.limit = RLIM_INFINITY;
50672
50673 - dump_count = atomic_inc_return(&core_dump_count);
50674 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50675 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50676 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50677 task_tgid_vnr(current), current->comm);
50678 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50679 } else {
50680 struct inode *inode;
50681
50682 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50683 +
50684 if (cprm.limit < binfmt->min_coredump)
50685 goto fail_unlock;
50686
50687 @@ -640,7 +646,7 @@ close_fail:
50688 filp_close(cprm.file, NULL);
50689 fail_dropcount:
50690 if (ispipe)
50691 - atomic_dec(&core_dump_count);
50692 + atomic_dec_unchecked(&core_dump_count);
50693 fail_unlock:
50694 kfree(cn.corename);
50695 fail_corename:
50696 @@ -659,7 +665,7 @@ fail:
50697 */
50698 int dump_write(struct file *file, const void *addr, int nr)
50699 {
50700 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50701 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50702 }
50703 EXPORT_SYMBOL(dump_write);
50704
50705 diff --git a/fs/dcache.c b/fs/dcache.c
50706 index de73da2..2ed907b 100644
50707 --- a/fs/dcache.c
50708 +++ b/fs/dcache.c
50709 @@ -3141,7 +3141,7 @@ void __init vfs_caches_init(unsigned long mempages)
50710 mempages -= reserve;
50711
50712 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50713 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50714 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50715
50716 dcache_init();
50717 inode_init();
50718 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50719 index a5f12b7..4ee8a6f 100644
50720 --- a/fs/debugfs/inode.c
50721 +++ b/fs/debugfs/inode.c
50722 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50723 */
50724 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50725 {
50726 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50727 + return __create_file(name, S_IFDIR | S_IRWXU,
50728 +#else
50729 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50730 +#endif
50731 parent, NULL, NULL);
50732 }
50733 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50734 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50735 index cc7709e..7e7211f 100644
50736 --- a/fs/ecryptfs/inode.c
50737 +++ b/fs/ecryptfs/inode.c
50738 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50739 old_fs = get_fs();
50740 set_fs(get_ds());
50741 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50742 - (char __user *)lower_buf,
50743 + (char __force_user *)lower_buf,
50744 PATH_MAX);
50745 set_fs(old_fs);
50746 if (rc < 0)
50747 @@ -706,7 +706,7 @@ out:
50748 static void
50749 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50750 {
50751 - char *buf = nd_get_link(nd);
50752 + const char *buf = nd_get_link(nd);
50753 if (!IS_ERR(buf)) {
50754 /* Free the char* */
50755 kfree(buf);
50756 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50757 index 412e6ed..d8263e8 100644
50758 --- a/fs/ecryptfs/miscdev.c
50759 +++ b/fs/ecryptfs/miscdev.c
50760 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50761 int rc;
50762
50763 mutex_lock(&ecryptfs_daemon_hash_mux);
50764 - rc = try_module_get(THIS_MODULE);
50765 - if (rc == 0) {
50766 - rc = -EIO;
50767 - printk(KERN_ERR "%s: Error attempting to increment module use "
50768 - "count; rc = [%d]\n", __func__, rc);
50769 - goto out_unlock_daemon_list;
50770 - }
50771 rc = ecryptfs_find_daemon_by_euid(&daemon);
50772 if (!rc) {
50773 rc = -EINVAL;
50774 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50775 if (rc) {
50776 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50777 "rc = [%d]\n", __func__, rc);
50778 - goto out_module_put_unlock_daemon_list;
50779 + goto out_unlock_daemon_list;
50780 }
50781 mutex_lock(&daemon->mux);
50782 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50783 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50784 atomic_inc(&ecryptfs_num_miscdev_opens);
50785 out_unlock_daemon:
50786 mutex_unlock(&daemon->mux);
50787 -out_module_put_unlock_daemon_list:
50788 - if (rc)
50789 - module_put(THIS_MODULE);
50790 out_unlock_daemon_list:
50791 mutex_unlock(&ecryptfs_daemon_hash_mux);
50792 return rc;
50793 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50794 "bug.\n", __func__, rc);
50795 BUG();
50796 }
50797 - module_put(THIS_MODULE);
50798 return rc;
50799 }
50800
50801 @@ -315,7 +304,7 @@ check_list:
50802 goto out_unlock_msg_ctx;
50803 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50804 if (msg_ctx->msg) {
50805 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50806 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50807 goto out_unlock_msg_ctx;
50808 i += packet_length_size;
50809 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50810 @@ -471,6 +460,7 @@ out_free:
50811
50812
50813 static const struct file_operations ecryptfs_miscdev_fops = {
50814 + .owner = THIS_MODULE,
50815 .open = ecryptfs_miscdev_open,
50816 .poll = ecryptfs_miscdev_poll,
50817 .read = ecryptfs_miscdev_read,
50818 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50819 index b2a34a1..162fa69 100644
50820 --- a/fs/ecryptfs/read_write.c
50821 +++ b/fs/ecryptfs/read_write.c
50822 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50823 return -EIO;
50824 fs_save = get_fs();
50825 set_fs(get_ds());
50826 - rc = vfs_write(lower_file, data, size, &offset);
50827 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50828 set_fs(fs_save);
50829 mark_inode_dirty_sync(ecryptfs_inode);
50830 return rc;
50831 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50832 return -EIO;
50833 fs_save = get_fs();
50834 set_fs(get_ds());
50835 - rc = vfs_read(lower_file, data, size, &offset);
50836 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50837 set_fs(fs_save);
50838 return rc;
50839 }
50840 diff --git a/fs/exec.c b/fs/exec.c
50841 index ac014f1..5fe5784 100644
50842 --- a/fs/exec.c
50843 +++ b/fs/exec.c
50844 @@ -55,8 +55,20 @@
50845 #include <linux/pipe_fs_i.h>
50846 #include <linux/oom.h>
50847 #include <linux/compat.h>
50848 +#include <linux/random.h>
50849 +#include <linux/seq_file.h>
50850 +#include <linux/coredump.h>
50851 +#include <linux/mman.h>
50852 +
50853 +#ifdef CONFIG_PAX_REFCOUNT
50854 +#include <linux/kallsyms.h>
50855 +#include <linux/kdebug.h>
50856 +#endif
50857 +
50858 +#include <trace/events/fs.h>
50859
50860 #include <asm/uaccess.h>
50861 +#include <asm/sections.h>
50862 #include <asm/mmu_context.h>
50863 #include <asm/tlb.h>
50864
50865 @@ -66,6 +78,18 @@
50866
50867 #include <trace/events/sched.h>
50868
50869 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50870 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50871 +{
50872 + pr_warn_once("PAX: PAX_HAVE_ACL_FLAGS was enabled without providing the pax_set_initial_flags callback, this is probably not what you wanted.\n");
50873 +}
50874 +#endif
50875 +
50876 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50877 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50878 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50879 +#endif
50880 +
50881 int suid_dumpable = 0;
50882
50883 static LIST_HEAD(formats);
50884 @@ -75,8 +99,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50885 {
50886 BUG_ON(!fmt);
50887 write_lock(&binfmt_lock);
50888 - insert ? list_add(&fmt->lh, &formats) :
50889 - list_add_tail(&fmt->lh, &formats);
50890 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50891 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50892 write_unlock(&binfmt_lock);
50893 }
50894
50895 @@ -85,7 +109,7 @@ EXPORT_SYMBOL(__register_binfmt);
50896 void unregister_binfmt(struct linux_binfmt * fmt)
50897 {
50898 write_lock(&binfmt_lock);
50899 - list_del(&fmt->lh);
50900 + pax_list_del((struct list_head *)&fmt->lh);
50901 write_unlock(&binfmt_lock);
50902 }
50903
50904 @@ -180,18 +204,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50905 int write)
50906 {
50907 struct page *page;
50908 - int ret;
50909
50910 -#ifdef CONFIG_STACK_GROWSUP
50911 - if (write) {
50912 - ret = expand_downwards(bprm->vma, pos);
50913 - if (ret < 0)
50914 - return NULL;
50915 - }
50916 -#endif
50917 - ret = get_user_pages(current, bprm->mm, pos,
50918 - 1, write, 1, &page, NULL);
50919 - if (ret <= 0)
50920 + if (0 > expand_downwards(bprm->vma, pos))
50921 + return NULL;
50922 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50923 return NULL;
50924
50925 if (write) {
50926 @@ -207,6 +223,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50927 if (size <= ARG_MAX)
50928 return page;
50929
50930 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50931 + // only allow 512KB for argv+env on suid/sgid binaries
50932 + // to prevent easy ASLR exhaustion
50933 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50934 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50935 + (size > (512 * 1024))) {
50936 + put_page(page);
50937 + return NULL;
50938 + }
50939 +#endif
50940 +
50941 /*
50942 * Limit to 1/4-th the stack size for the argv+env strings.
50943 * This ensures that:
50944 @@ -266,6 +293,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50945 vma->vm_end = STACK_TOP_MAX;
50946 vma->vm_start = vma->vm_end - PAGE_SIZE;
50947 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50948 +
50949 +#ifdef CONFIG_PAX_SEGMEXEC
50950 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50951 +#endif
50952 +
50953 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50954 INIT_LIST_HEAD(&vma->anon_vma_chain);
50955
50956 @@ -276,6 +308,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50957 mm->stack_vm = mm->total_vm = 1;
50958 up_write(&mm->mmap_sem);
50959 bprm->p = vma->vm_end - sizeof(void *);
50960 +
50961 +#ifdef CONFIG_PAX_RANDUSTACK
50962 + if (randomize_va_space)
50963 + bprm->p ^= random32() & ~PAGE_MASK;
50964 +#endif
50965 +
50966 return 0;
50967 err:
50968 up_write(&mm->mmap_sem);
50969 @@ -396,7 +434,7 @@ struct user_arg_ptr {
50970 } ptr;
50971 };
50972
50973 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50974 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50975 {
50976 const char __user *native;
50977
50978 @@ -405,14 +443,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50979 compat_uptr_t compat;
50980
50981 if (get_user(compat, argv.ptr.compat + nr))
50982 - return ERR_PTR(-EFAULT);
50983 + return (const char __force_user *)ERR_PTR(-EFAULT);
50984
50985 return compat_ptr(compat);
50986 }
50987 #endif
50988
50989 if (get_user(native, argv.ptr.native + nr))
50990 - return ERR_PTR(-EFAULT);
50991 + return (const char __force_user *)ERR_PTR(-EFAULT);
50992
50993 return native;
50994 }
50995 @@ -431,7 +469,7 @@ static int count(struct user_arg_ptr argv, int max)
50996 if (!p)
50997 break;
50998
50999 - if (IS_ERR(p))
51000 + if (IS_ERR((const char __force_kernel *)p))
51001 return -EFAULT;
51002
51003 if (i >= max)
51004 @@ -466,7 +504,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
51005
51006 ret = -EFAULT;
51007 str = get_user_arg_ptr(argv, argc);
51008 - if (IS_ERR(str))
51009 + if (IS_ERR((const char __force_kernel *)str))
51010 goto out;
51011
51012 len = strnlen_user(str, MAX_ARG_STRLEN);
51013 @@ -548,7 +586,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
51014 int r;
51015 mm_segment_t oldfs = get_fs();
51016 struct user_arg_ptr argv = {
51017 - .ptr.native = (const char __user *const __user *)__argv,
51018 + .ptr.native = (const char __force_user *const __force_user *)__argv,
51019 };
51020
51021 set_fs(KERNEL_DS);
51022 @@ -583,7 +621,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51023 unsigned long new_end = old_end - shift;
51024 struct mmu_gather tlb;
51025
51026 - BUG_ON(new_start > new_end);
51027 + if (new_start >= new_end || new_start < mmap_min_addr)
51028 + return -ENOMEM;
51029
51030 /*
51031 * ensure there are no vmas between where we want to go
51032 @@ -592,6 +631,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
51033 if (vma != find_vma(mm, new_start))
51034 return -EFAULT;
51035
51036 +#ifdef CONFIG_PAX_SEGMEXEC
51037 + BUG_ON(pax_find_mirror_vma(vma));
51038 +#endif
51039 +
51040 /*
51041 * cover the whole range: [new_start, old_end)
51042 */
51043 @@ -672,10 +715,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51044 stack_top = arch_align_stack(stack_top);
51045 stack_top = PAGE_ALIGN(stack_top);
51046
51047 - if (unlikely(stack_top < mmap_min_addr) ||
51048 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
51049 - return -ENOMEM;
51050 -
51051 stack_shift = vma->vm_end - stack_top;
51052
51053 bprm->p -= stack_shift;
51054 @@ -687,8 +726,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51055 bprm->exec -= stack_shift;
51056
51057 down_write(&mm->mmap_sem);
51058 +
51059 + /* Move stack pages down in memory. */
51060 + if (stack_shift) {
51061 + ret = shift_arg_pages(vma, stack_shift);
51062 + if (ret)
51063 + goto out_unlock;
51064 + }
51065 +
51066 vm_flags = VM_STACK_FLAGS;
51067
51068 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51069 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51070 + vm_flags &= ~VM_EXEC;
51071 +
51072 +#ifdef CONFIG_PAX_MPROTECT
51073 + if (mm->pax_flags & MF_PAX_MPROTECT)
51074 + vm_flags &= ~VM_MAYEXEC;
51075 +#endif
51076 +
51077 + }
51078 +#endif
51079 +
51080 /*
51081 * Adjust stack execute permissions; explicitly enable for
51082 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51083 @@ -707,13 +766,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51084 goto out_unlock;
51085 BUG_ON(prev != vma);
51086
51087 - /* Move stack pages down in memory. */
51088 - if (stack_shift) {
51089 - ret = shift_arg_pages(vma, stack_shift);
51090 - if (ret)
51091 - goto out_unlock;
51092 - }
51093 -
51094 /* mprotect_fixup is overkill to remove the temporary stack flags */
51095 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51096
51097 @@ -737,6 +789,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51098 #endif
51099 current->mm->start_stack = bprm->p;
51100 ret = expand_stack(vma, stack_base);
51101 +
51102 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51103 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51104 + unsigned long size, flags, vm_flags;
51105 +
51106 + size = STACK_TOP - vma->vm_end;
51107 + flags = MAP_FIXED | MAP_PRIVATE;
51108 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51109 +
51110 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51111 +
51112 +#ifdef CONFIG_X86
51113 + if (!ret) {
51114 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51115 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51116 + }
51117 +#endif
51118 +
51119 + }
51120 +#endif
51121 +
51122 if (ret)
51123 ret = -EFAULT;
51124
51125 @@ -772,6 +845,8 @@ struct file *open_exec(const char *name)
51126
51127 fsnotify_open(file);
51128
51129 + trace_open_exec(name);
51130 +
51131 err = deny_write_access(file);
51132 if (err)
51133 goto exit;
51134 @@ -795,7 +870,7 @@ int kernel_read(struct file *file, loff_t offset,
51135 old_fs = get_fs();
51136 set_fs(get_ds());
51137 /* The cast to a user pointer is valid due to the set_fs() */
51138 - result = vfs_read(file, (void __user *)addr, count, &pos);
51139 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51140 set_fs(old_fs);
51141 return result;
51142 }
51143 @@ -1250,7 +1325,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51144 }
51145 rcu_read_unlock();
51146
51147 - if (p->fs->users > n_fs) {
51148 + if (atomic_read(&p->fs->users) > n_fs) {
51149 bprm->unsafe |= LSM_UNSAFE_SHARE;
51150 } else {
51151 res = -EAGAIN;
51152 @@ -1450,6 +1525,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51153
51154 EXPORT_SYMBOL(search_binary_handler);
51155
51156 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51157 +static DEFINE_PER_CPU(u64, exec_counter);
51158 +static int __init init_exec_counters(void)
51159 +{
51160 + unsigned int cpu;
51161 +
51162 + for_each_possible_cpu(cpu) {
51163 + per_cpu(exec_counter, cpu) = (u64)cpu;
51164 + }
51165 +
51166 + return 0;
51167 +}
51168 +early_initcall(init_exec_counters);
51169 +static inline void increment_exec_counter(void)
51170 +{
51171 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51172 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51173 +}
51174 +#else
51175 +static inline void increment_exec_counter(void) {}
51176 +#endif
51177 +
51178 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51179 + struct user_arg_ptr argv);
51180 +
51181 /*
51182 * sys_execve() executes a new program.
51183 */
51184 @@ -1457,6 +1557,11 @@ static int do_execve_common(const char *filename,
51185 struct user_arg_ptr argv,
51186 struct user_arg_ptr envp)
51187 {
51188 +#ifdef CONFIG_GRKERNSEC
51189 + struct file *old_exec_file;
51190 + struct acl_subject_label *old_acl;
51191 + struct rlimit old_rlim[RLIM_NLIMITS];
51192 +#endif
51193 struct linux_binprm *bprm;
51194 struct file *file;
51195 struct files_struct *displaced;
51196 @@ -1464,6 +1569,8 @@ static int do_execve_common(const char *filename,
51197 int retval;
51198 const struct cred *cred = current_cred();
51199
51200 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51201 +
51202 /*
51203 * We move the actual failure in case of RLIMIT_NPROC excess from
51204 * set*uid() to execve() because too many poorly written programs
51205 @@ -1504,12 +1611,27 @@ static int do_execve_common(const char *filename,
51206 if (IS_ERR(file))
51207 goto out_unmark;
51208
51209 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51210 + retval = -EPERM;
51211 + goto out_file;
51212 + }
51213 +
51214 sched_exec();
51215
51216 bprm->file = file;
51217 bprm->filename = filename;
51218 bprm->interp = filename;
51219
51220 + if (gr_process_user_ban()) {
51221 + retval = -EPERM;
51222 + goto out_file;
51223 + }
51224 +
51225 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51226 + retval = -EACCES;
51227 + goto out_file;
51228 + }
51229 +
51230 retval = bprm_mm_init(bprm);
51231 if (retval)
51232 goto out_file;
51233 @@ -1526,24 +1648,65 @@ static int do_execve_common(const char *filename,
51234 if (retval < 0)
51235 goto out;
51236
51237 +#ifdef CONFIG_GRKERNSEC
51238 + old_acl = current->acl;
51239 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51240 + old_exec_file = current->exec_file;
51241 + get_file(file);
51242 + current->exec_file = file;
51243 +#endif
51244 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51245 + /* limit suid stack to 8MB
51246 + * we saved the old limits above and will restore them if this exec fails
51247 + */
51248 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51249 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51250 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51251 +#endif
51252 +
51253 + if (!gr_tpe_allow(file)) {
51254 + retval = -EACCES;
51255 + goto out_fail;
51256 + }
51257 +
51258 + if (gr_check_crash_exec(file)) {
51259 + retval = -EACCES;
51260 + goto out_fail;
51261 + }
51262 +
51263 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51264 + bprm->unsafe);
51265 + if (retval < 0)
51266 + goto out_fail;
51267 +
51268 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51269 if (retval < 0)
51270 - goto out;
51271 + goto out_fail;
51272
51273 bprm->exec = bprm->p;
51274 retval = copy_strings(bprm->envc, envp, bprm);
51275 if (retval < 0)
51276 - goto out;
51277 + goto out_fail;
51278
51279 retval = copy_strings(bprm->argc, argv, bprm);
51280 if (retval < 0)
51281 - goto out;
51282 + goto out_fail;
51283 +
51284 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51285 +
51286 + gr_handle_exec_args(bprm, argv);
51287
51288 retval = search_binary_handler(bprm);
51289 if (retval < 0)
51290 - goto out;
51291 + goto out_fail;
51292 +#ifdef CONFIG_GRKERNSEC
51293 + if (old_exec_file)
51294 + fput(old_exec_file);
51295 +#endif
51296
51297 /* execve succeeded */
51298 +
51299 + increment_exec_counter();
51300 current->fs->in_exec = 0;
51301 current->in_execve = 0;
51302 acct_update_integrals(current);
51303 @@ -1552,6 +1715,14 @@ static int do_execve_common(const char *filename,
51304 put_files_struct(displaced);
51305 return retval;
51306
51307 +out_fail:
51308 +#ifdef CONFIG_GRKERNSEC
51309 + current->acl = old_acl;
51310 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51311 + fput(current->exec_file);
51312 + current->exec_file = old_exec_file;
51313 +#endif
51314 +
51315 out:
51316 if (bprm->mm) {
51317 acct_arg_size(bprm, 0);
51318 @@ -1700,3 +1871,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51319 return error;
51320 }
51321 #endif
51322 +
51323 +int pax_check_flags(unsigned long *flags)
51324 +{
51325 + int retval = 0;
51326 +
51327 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51328 + if (*flags & MF_PAX_SEGMEXEC)
51329 + {
51330 + *flags &= ~MF_PAX_SEGMEXEC;
51331 + retval = -EINVAL;
51332 + }
51333 +#endif
51334 +
51335 + if ((*flags & MF_PAX_PAGEEXEC)
51336 +
51337 +#ifdef CONFIG_PAX_PAGEEXEC
51338 + && (*flags & MF_PAX_SEGMEXEC)
51339 +#endif
51340 +
51341 + )
51342 + {
51343 + *flags &= ~MF_PAX_PAGEEXEC;
51344 + retval = -EINVAL;
51345 + }
51346 +
51347 + if ((*flags & MF_PAX_MPROTECT)
51348 +
51349 +#ifdef CONFIG_PAX_MPROTECT
51350 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51351 +#endif
51352 +
51353 + )
51354 + {
51355 + *flags &= ~MF_PAX_MPROTECT;
51356 + retval = -EINVAL;
51357 + }
51358 +
51359 + if ((*flags & MF_PAX_EMUTRAMP)
51360 +
51361 +#ifdef CONFIG_PAX_EMUTRAMP
51362 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51363 +#endif
51364 +
51365 + )
51366 + {
51367 + *flags &= ~MF_PAX_EMUTRAMP;
51368 + retval = -EINVAL;
51369 + }
51370 +
51371 + return retval;
51372 +}
51373 +
51374 +EXPORT_SYMBOL(pax_check_flags);
51375 +
51376 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51377 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51378 +{
51379 + struct task_struct *tsk = current;
51380 + struct mm_struct *mm = current->mm;
51381 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51382 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51383 + char *path_exec = NULL;
51384 + char *path_fault = NULL;
51385 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51386 + siginfo_t info = { };
51387 +
51388 + if (buffer_exec && buffer_fault) {
51389 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51390 +
51391 + down_read(&mm->mmap_sem);
51392 + vma = mm->mmap;
51393 + while (vma && (!vma_exec || !vma_fault)) {
51394 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51395 + vma_exec = vma;
51396 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51397 + vma_fault = vma;
51398 + vma = vma->vm_next;
51399 + }
51400 + if (vma_exec) {
51401 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51402 + if (IS_ERR(path_exec))
51403 + path_exec = "<path too long>";
51404 + else {
51405 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51406 + if (path_exec) {
51407 + *path_exec = 0;
51408 + path_exec = buffer_exec;
51409 + } else
51410 + path_exec = "<path too long>";
51411 + }
51412 + }
51413 + if (vma_fault) {
51414 + start = vma_fault->vm_start;
51415 + end = vma_fault->vm_end;
51416 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51417 + if (vma_fault->vm_file) {
51418 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51419 + if (IS_ERR(path_fault))
51420 + path_fault = "<path too long>";
51421 + else {
51422 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51423 + if (path_fault) {
51424 + *path_fault = 0;
51425 + path_fault = buffer_fault;
51426 + } else
51427 + path_fault = "<path too long>";
51428 + }
51429 + } else
51430 + path_fault = "<anonymous mapping>";
51431 + }
51432 + up_read(&mm->mmap_sem);
51433 + }
51434 + if (tsk->signal->curr_ip)
51435 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51436 + else
51437 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51438 + printk(KERN_ERR "PAX: terminating task: %s(%s):%d, uid/euid: %u/%u, PC: %p, SP: %p\n", path_exec, tsk->comm, task_pid_nr(tsk),
51439 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51440 + free_page((unsigned long)buffer_exec);
51441 + free_page((unsigned long)buffer_fault);
51442 + pax_report_insns(regs, pc, sp);
51443 + info.si_signo = SIGKILL;
51444 + info.si_errno = 0;
51445 + info.si_code = SI_KERNEL;
51446 + info.si_pid = 0;
51447 + info.si_uid = 0;
51448 + do_coredump(&info);
51449 +}
51450 +#endif
51451 +
51452 +#ifdef CONFIG_PAX_REFCOUNT
51453 +void pax_report_refcount_overflow(struct pt_regs *regs)
51454 +{
51455 + if (current->signal->curr_ip)
51456 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51457 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51458 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51459 + else
51460 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51461 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51462 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51463 + show_regs(regs);
51464 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51465 +}
51466 +#endif
51467 +
51468 +#ifdef CONFIG_PAX_USERCOPY
51469 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51470 +static noinline int check_stack_object(const void *obj, unsigned long len)
51471 +{
51472 + const void * const stack = task_stack_page(current);
51473 + const void * const stackend = stack + THREAD_SIZE;
51474 +
51475 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51476 + const void *frame = NULL;
51477 + const void *oldframe;
51478 +#endif
51479 +
51480 + if (obj + len < obj)
51481 + return -1;
51482 +
51483 + if (obj + len <= stack || stackend <= obj)
51484 + return 0;
51485 +
51486 + if (obj < stack || stackend < obj + len)
51487 + return -1;
51488 +
51489 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51490 + oldframe = __builtin_frame_address(1);
51491 + if (oldframe)
51492 + frame = __builtin_frame_address(2);
51493 + /*
51494 + low ----------------------------------------------> high
51495 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51496 + ^----------------^
51497 + allow copies only within here
51498 + */
51499 + while (stack <= frame && frame < stackend) {
51500 + /* if obj + len extends past the last frame, this
51501 + check won't pass and the next frame will be 0,
51502 + causing us to bail out and correctly report
51503 + the copy as invalid
51504 + */
51505 + if (obj + len <= frame)
51506 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51507 + oldframe = frame;
51508 + frame = *(const void * const *)frame;
51509 + }
51510 + return -1;
51511 +#else
51512 + return 1;
51513 +#endif
51514 +}
51515 +
51516 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51517 +{
51518 + if (current->signal->curr_ip)
51519 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51520 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51521 + else
51522 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51523 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51524 + dump_stack();
51525 + gr_handle_kernel_exploit();
51526 + do_group_exit(SIGKILL);
51527 +}
51528 +#endif
51529 +
51530 +#ifdef CONFIG_PAX_USERCOPY
51531 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51532 +{
51533 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51534 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51535 +#ifdef CONFIG_MODULES
51536 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51537 +#else
51538 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51539 +#endif
51540 +
51541 +#else
51542 + unsigned long textlow = _stext;
51543 + unsigned long texthigh = _etext;
51544 +#endif
51545 +
51546 + if (high < textlow || low > texthigh)
51547 + return false;
51548 + else
51549 + return true;
51550 +}
51551 +#endif
51552 +
51553 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51554 +{
51555 +
51556 +#ifdef CONFIG_PAX_USERCOPY
51557 + const char *type;
51558 +
51559 + if (!n)
51560 + return;
51561 +
51562 + type = check_heap_object(ptr, n);
51563 + if (!type) {
51564 + int ret = check_stack_object(ptr, n);
51565 + if (ret == 1 || ret == 2)
51566 + return;
51567 + if (ret == 0) {
51568 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51569 + type = "<kernel text>";
51570 + else
51571 + return;
51572 + } else
51573 + type = "<process stack>";
51574 + }
51575 +
51576 + pax_report_usercopy(ptr, n, to_user, type);
51577 +#endif
51578 +
51579 +}
51580 +EXPORT_SYMBOL(__check_object_size);
51581 +
51582 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51583 +void pax_track_stack(void)
51584 +{
51585 + unsigned long sp = (unsigned long)&sp;
51586 + if (sp < current_thread_info()->lowest_stack &&
51587 + sp > (unsigned long)task_stack_page(current))
51588 + current_thread_info()->lowest_stack = sp;
51589 +}
51590 +EXPORT_SYMBOL(pax_track_stack);
51591 +#endif
51592 +
51593 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51594 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51595 +{
51596 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51597 + dump_stack();
51598 + do_group_exit(SIGKILL);
51599 +}
51600 +EXPORT_SYMBOL(report_size_overflow);
51601 +#endif
51602 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51603 index 2616d0e..2ffdec9 100644
51604 --- a/fs/ext2/balloc.c
51605 +++ b/fs/ext2/balloc.c
51606 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51607
51608 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51609 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51610 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51611 + if (free_blocks < root_blocks + 1 &&
51612 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51613 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51614 - !in_group_p (sbi->s_resgid))) {
51615 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51616 return 0;
51617 }
51618 return 1;
51619 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51620 index 22548f5..41521d8 100644
51621 --- a/fs/ext3/balloc.c
51622 +++ b/fs/ext3/balloc.c
51623 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51624
51625 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51626 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51627 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51628 + if (free_blocks < root_blocks + 1 &&
51629 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51630 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51631 - !in_group_p (sbi->s_resgid))) {
51632 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51633 return 0;
51634 }
51635 return 1;
51636 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51637 index 92e68b3..115d987 100644
51638 --- a/fs/ext4/balloc.c
51639 +++ b/fs/ext4/balloc.c
51640 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51641 /* Hm, nope. Are (enough) root reserved clusters available? */
51642 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51643 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51644 - capable(CAP_SYS_RESOURCE) ||
51645 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51646 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51647 + capable_nolog(CAP_SYS_RESOURCE)) {
51648
51649 if (free_clusters >= (nclusters + dirty_clusters))
51650 return 1;
51651 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51652 index bbcd6a0..2824592 100644
51653 --- a/fs/ext4/ext4.h
51654 +++ b/fs/ext4/ext4.h
51655 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51656 unsigned long s_mb_last_start;
51657
51658 /* stats for buddy allocator */
51659 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51660 - atomic_t s_bal_success; /* we found long enough chunks */
51661 - atomic_t s_bal_allocated; /* in blocks */
51662 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51663 - atomic_t s_bal_goals; /* goal hits */
51664 - atomic_t s_bal_breaks; /* too long searches */
51665 - atomic_t s_bal_2orders; /* 2^order hits */
51666 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51667 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51668 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51669 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51670 + atomic_unchecked_t s_bal_goals; /* goal hits */
51671 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51672 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51673 spinlock_t s_bal_lock;
51674 unsigned long s_mb_buddies_generated;
51675 unsigned long long s_mb_generation_time;
51676 - atomic_t s_mb_lost_chunks;
51677 - atomic_t s_mb_preallocated;
51678 - atomic_t s_mb_discarded;
51679 + atomic_unchecked_t s_mb_lost_chunks;
51680 + atomic_unchecked_t s_mb_preallocated;
51681 + atomic_unchecked_t s_mb_discarded;
51682 atomic_t s_lock_busy;
51683
51684 /* locality groups */
51685 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51686 index b443e62..a2109f6 100644
51687 --- a/fs/ext4/mballoc.c
51688 +++ b/fs/ext4/mballoc.c
51689 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51690 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51691
51692 if (EXT4_SB(sb)->s_mb_stats)
51693 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51694 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51695
51696 break;
51697 }
51698 @@ -2044,7 +2044,7 @@ repeat:
51699 ac->ac_status = AC_STATUS_CONTINUE;
51700 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51701 cr = 3;
51702 - atomic_inc(&sbi->s_mb_lost_chunks);
51703 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51704 goto repeat;
51705 }
51706 }
51707 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51708 if (sbi->s_mb_stats) {
51709 ext4_msg(sb, KERN_INFO,
51710 "mballoc: %u blocks %u reqs (%u success)",
51711 - atomic_read(&sbi->s_bal_allocated),
51712 - atomic_read(&sbi->s_bal_reqs),
51713 - atomic_read(&sbi->s_bal_success));
51714 + atomic_read_unchecked(&sbi->s_bal_allocated),
51715 + atomic_read_unchecked(&sbi->s_bal_reqs),
51716 + atomic_read_unchecked(&sbi->s_bal_success));
51717 ext4_msg(sb, KERN_INFO,
51718 "mballoc: %u extents scanned, %u goal hits, "
51719 "%u 2^N hits, %u breaks, %u lost",
51720 - atomic_read(&sbi->s_bal_ex_scanned),
51721 - atomic_read(&sbi->s_bal_goals),
51722 - atomic_read(&sbi->s_bal_2orders),
51723 - atomic_read(&sbi->s_bal_breaks),
51724 - atomic_read(&sbi->s_mb_lost_chunks));
51725 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51726 + atomic_read_unchecked(&sbi->s_bal_goals),
51727 + atomic_read_unchecked(&sbi->s_bal_2orders),
51728 + atomic_read_unchecked(&sbi->s_bal_breaks),
51729 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51730 ext4_msg(sb, KERN_INFO,
51731 "mballoc: %lu generated and it took %Lu",
51732 sbi->s_mb_buddies_generated,
51733 sbi->s_mb_generation_time);
51734 ext4_msg(sb, KERN_INFO,
51735 "mballoc: %u preallocated, %u discarded",
51736 - atomic_read(&sbi->s_mb_preallocated),
51737 - atomic_read(&sbi->s_mb_discarded));
51738 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51739 + atomic_read_unchecked(&sbi->s_mb_discarded));
51740 }
51741
51742 free_percpu(sbi->s_locality_groups);
51743 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51744 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51745
51746 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51747 - atomic_inc(&sbi->s_bal_reqs);
51748 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51749 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51750 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51751 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51752 - atomic_inc(&sbi->s_bal_success);
51753 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51754 + atomic_inc_unchecked(&sbi->s_bal_success);
51755 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51756 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51757 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51758 - atomic_inc(&sbi->s_bal_goals);
51759 + atomic_inc_unchecked(&sbi->s_bal_goals);
51760 if (ac->ac_found > sbi->s_mb_max_to_scan)
51761 - atomic_inc(&sbi->s_bal_breaks);
51762 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51763 }
51764
51765 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51766 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51767 trace_ext4_mb_new_inode_pa(ac, pa);
51768
51769 ext4_mb_use_inode_pa(ac, pa);
51770 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51771 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51772
51773 ei = EXT4_I(ac->ac_inode);
51774 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51775 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51776 trace_ext4_mb_new_group_pa(ac, pa);
51777
51778 ext4_mb_use_group_pa(ac, pa);
51779 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51780 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51781
51782 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51783 lg = ac->ac_lg;
51784 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51785 * from the bitmap and continue.
51786 */
51787 }
51788 - atomic_add(free, &sbi->s_mb_discarded);
51789 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51790
51791 return err;
51792 }
51793 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51794 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51795 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51796 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51797 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51798 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51799 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51800
51801 return 0;
51802 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51803 index 5575a45..12f7424 100644
51804 --- a/fs/ext4/super.c
51805 +++ b/fs/ext4/super.c
51806 @@ -2432,7 +2432,7 @@ struct ext4_attr {
51807 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51808 const char *, size_t);
51809 int offset;
51810 -};
51811 +} __do_const;
51812
51813 static int parse_strtoul(const char *buf,
51814 unsigned long max, unsigned long *value)
51815 diff --git a/fs/fcntl.c b/fs/fcntl.c
51816 index 71a600a..20d87b1 100644
51817 --- a/fs/fcntl.c
51818 +++ b/fs/fcntl.c
51819 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51820 if (err)
51821 return err;
51822
51823 + if (gr_handle_chroot_fowner(pid, type))
51824 + return -ENOENT;
51825 + if (gr_check_protected_task_fowner(pid, type))
51826 + return -EACCES;
51827 +
51828 f_modown(filp, pid, type, force);
51829 return 0;
51830 }
51831 diff --git a/fs/fhandle.c b/fs/fhandle.c
51832 index 999ff5c..41f4109 100644
51833 --- a/fs/fhandle.c
51834 +++ b/fs/fhandle.c
51835 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51836 } else
51837 retval = 0;
51838 /* copy the mount id */
51839 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51840 - sizeof(*mnt_id)) ||
51841 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51842 copy_to_user(ufh, handle,
51843 sizeof(struct file_handle) + handle_bytes))
51844 retval = -EFAULT;
51845 diff --git a/fs/fifo.c b/fs/fifo.c
51846 index cf6f434..3d7942c 100644
51847 --- a/fs/fifo.c
51848 +++ b/fs/fifo.c
51849 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51850 */
51851 filp->f_op = &read_pipefifo_fops;
51852 pipe->r_counter++;
51853 - if (pipe->readers++ == 0)
51854 + if (atomic_inc_return(&pipe->readers) == 1)
51855 wake_up_partner(inode);
51856
51857 - if (!pipe->writers) {
51858 + if (!atomic_read(&pipe->writers)) {
51859 if ((filp->f_flags & O_NONBLOCK)) {
51860 /* suppress POLLHUP until we have
51861 * seen a writer */
51862 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51863 * errno=ENXIO when there is no process reading the FIFO.
51864 */
51865 ret = -ENXIO;
51866 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51867 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51868 goto err;
51869
51870 filp->f_op = &write_pipefifo_fops;
51871 pipe->w_counter++;
51872 - if (!pipe->writers++)
51873 + if (atomic_inc_return(&pipe->writers) == 1)
51874 wake_up_partner(inode);
51875
51876 - if (!pipe->readers) {
51877 + if (!atomic_read(&pipe->readers)) {
51878 if (wait_for_partner(inode, &pipe->r_counter))
51879 goto err_wr;
51880 }
51881 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51882 */
51883 filp->f_op = &rdwr_pipefifo_fops;
51884
51885 - pipe->readers++;
51886 - pipe->writers++;
51887 + atomic_inc(&pipe->readers);
51888 + atomic_inc(&pipe->writers);
51889 pipe->r_counter++;
51890 pipe->w_counter++;
51891 - if (pipe->readers == 1 || pipe->writers == 1)
51892 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51893 wake_up_partner(inode);
51894 break;
51895
51896 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51897 return 0;
51898
51899 err_rd:
51900 - if (!--pipe->readers)
51901 + if (atomic_dec_and_test(&pipe->readers))
51902 wake_up_interruptible(&pipe->wait);
51903 ret = -ERESTARTSYS;
51904 goto err;
51905
51906 err_wr:
51907 - if (!--pipe->writers)
51908 + if (atomic_dec_and_test(&pipe->writers))
51909 wake_up_interruptible(&pipe->wait);
51910 ret = -ERESTARTSYS;
51911 goto err;
51912
51913 err:
51914 - if (!pipe->readers && !pipe->writers)
51915 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51916 free_pipe_info(inode);
51917
51918 err_nocleanup:
51919 diff --git a/fs/file.c b/fs/file.c
51920 index 2b3570b..c57924b 100644
51921 --- a/fs/file.c
51922 +++ b/fs/file.c
51923 @@ -16,6 +16,7 @@
51924 #include <linux/slab.h>
51925 #include <linux/vmalloc.h>
51926 #include <linux/file.h>
51927 +#include <linux/security.h>
51928 #include <linux/fdtable.h>
51929 #include <linux/bitops.h>
51930 #include <linux/interrupt.h>
51931 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51932 if (!file)
51933 return __close_fd(files, fd);
51934
51935 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51936 if (fd >= rlimit(RLIMIT_NOFILE))
51937 return -EBADF;
51938
51939 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51940 if (unlikely(oldfd == newfd))
51941 return -EINVAL;
51942
51943 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51944 if (newfd >= rlimit(RLIMIT_NOFILE))
51945 return -EBADF;
51946
51947 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51948 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51949 {
51950 int err;
51951 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51952 if (from >= rlimit(RLIMIT_NOFILE))
51953 return -EINVAL;
51954 err = alloc_fd(from, flags);
51955 diff --git a/fs/filesystems.c b/fs/filesystems.c
51956 index da165f6..3671bdb 100644
51957 --- a/fs/filesystems.c
51958 +++ b/fs/filesystems.c
51959 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51960 int len = dot ? dot - name : strlen(name);
51961
51962 fs = __get_fs_type(name, len);
51963 +
51964 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51965 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51966 +#else
51967 if (!fs && (request_module("%.*s", len, name) == 0))
51968 +#endif
51969 fs = __get_fs_type(name, len);
51970
51971 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51972 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51973 index fe6ca58..65318cf 100644
51974 --- a/fs/fs_struct.c
51975 +++ b/fs/fs_struct.c
51976 @@ -4,6 +4,7 @@
51977 #include <linux/path.h>
51978 #include <linux/slab.h>
51979 #include <linux/fs_struct.h>
51980 +#include <linux/grsecurity.h>
51981 #include "internal.h"
51982
51983 /*
51984 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51985 write_seqcount_begin(&fs->seq);
51986 old_root = fs->root;
51987 fs->root = *path;
51988 + gr_set_chroot_entries(current, path);
51989 write_seqcount_end(&fs->seq);
51990 spin_unlock(&fs->lock);
51991 if (old_root.dentry)
51992 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51993 return 1;
51994 }
51995
51996 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51997 +{
51998 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51999 + return 0;
52000 + *p = *new;
52001 +
52002 + /* This function is only called from pivot_root(). Leave our
52003 + gr_chroot_dentry and is_chrooted flags as-is, so that a
52004 + pivoted root isn't treated as a chroot
52005 + */
52006 + //gr_set_chroot_entries(task, new);
52007 +
52008 + return 1;
52009 +}
52010 +
52011 void chroot_fs_refs(struct path *old_root, struct path *new_root)
52012 {
52013 struct task_struct *g, *p;
52014 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
52015 int hits = 0;
52016 spin_lock(&fs->lock);
52017 write_seqcount_begin(&fs->seq);
52018 - hits += replace_path(&fs->root, old_root, new_root);
52019 + hits += replace_root_path(p, &fs->root, old_root, new_root);
52020 hits += replace_path(&fs->pwd, old_root, new_root);
52021 write_seqcount_end(&fs->seq);
52022 while (hits--) {
52023 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
52024 task_lock(tsk);
52025 spin_lock(&fs->lock);
52026 tsk->fs = NULL;
52027 - kill = !--fs->users;
52028 + gr_clear_chroot_entries(tsk);
52029 + kill = !atomic_dec_return(&fs->users);
52030 spin_unlock(&fs->lock);
52031 task_unlock(tsk);
52032 if (kill)
52033 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52034 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
52035 /* We don't need to lock fs - think why ;-) */
52036 if (fs) {
52037 - fs->users = 1;
52038 + atomic_set(&fs->users, 1);
52039 fs->in_exec = 0;
52040 spin_lock_init(&fs->lock);
52041 seqcount_init(&fs->seq);
52042 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
52043 spin_lock(&old->lock);
52044 fs->root = old->root;
52045 path_get(&fs->root);
52046 + /* instead of calling gr_set_chroot_entries here,
52047 + we call it from every caller of this function
52048 + */
52049 fs->pwd = old->pwd;
52050 path_get(&fs->pwd);
52051 spin_unlock(&old->lock);
52052 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
52053
52054 task_lock(current);
52055 spin_lock(&fs->lock);
52056 - kill = !--fs->users;
52057 + kill = !atomic_dec_return(&fs->users);
52058 current->fs = new_fs;
52059 + gr_set_chroot_entries(current, &new_fs->root);
52060 spin_unlock(&fs->lock);
52061 task_unlock(current);
52062
52063 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
52064
52065 int current_umask(void)
52066 {
52067 - return current->fs->umask;
52068 + return current->fs->umask | gr_acl_umask();
52069 }
52070 EXPORT_SYMBOL(current_umask);
52071
52072 /* to be mentioned only in INIT_TASK */
52073 struct fs_struct init_fs = {
52074 - .users = 1,
52075 + .users = ATOMIC_INIT(1),
52076 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
52077 .seq = SEQCNT_ZERO,
52078 .umask = 0022,
52079 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
52080 index 8dcb114..b1072e2 100644
52081 --- a/fs/fscache/cookie.c
52082 +++ b/fs/fscache/cookie.c
52083 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52084 parent ? (char *) parent->def->name : "<no-parent>",
52085 def->name, netfs_data);
52086
52087 - fscache_stat(&fscache_n_acquires);
52088 + fscache_stat_unchecked(&fscache_n_acquires);
52089
52090 /* if there's no parent cookie, then we don't create one here either */
52091 if (!parent) {
52092 - fscache_stat(&fscache_n_acquires_null);
52093 + fscache_stat_unchecked(&fscache_n_acquires_null);
52094 _leave(" [no parent]");
52095 return NULL;
52096 }
52097 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52098 /* allocate and initialise a cookie */
52099 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52100 if (!cookie) {
52101 - fscache_stat(&fscache_n_acquires_oom);
52102 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52103 _leave(" [ENOMEM]");
52104 return NULL;
52105 }
52106 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52107
52108 switch (cookie->def->type) {
52109 case FSCACHE_COOKIE_TYPE_INDEX:
52110 - fscache_stat(&fscache_n_cookie_index);
52111 + fscache_stat_unchecked(&fscache_n_cookie_index);
52112 break;
52113 case FSCACHE_COOKIE_TYPE_DATAFILE:
52114 - fscache_stat(&fscache_n_cookie_data);
52115 + fscache_stat_unchecked(&fscache_n_cookie_data);
52116 break;
52117 default:
52118 - fscache_stat(&fscache_n_cookie_special);
52119 + fscache_stat_unchecked(&fscache_n_cookie_special);
52120 break;
52121 }
52122
52123 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52124 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52125 atomic_dec(&parent->n_children);
52126 __fscache_cookie_put(cookie);
52127 - fscache_stat(&fscache_n_acquires_nobufs);
52128 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52129 _leave(" = NULL");
52130 return NULL;
52131 }
52132 }
52133
52134 - fscache_stat(&fscache_n_acquires_ok);
52135 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52136 _leave(" = %p", cookie);
52137 return cookie;
52138 }
52139 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52140 cache = fscache_select_cache_for_object(cookie->parent);
52141 if (!cache) {
52142 up_read(&fscache_addremove_sem);
52143 - fscache_stat(&fscache_n_acquires_no_cache);
52144 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52145 _leave(" = -ENOMEDIUM [no cache]");
52146 return -ENOMEDIUM;
52147 }
52148 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52149 object = cache->ops->alloc_object(cache, cookie);
52150 fscache_stat_d(&fscache_n_cop_alloc_object);
52151 if (IS_ERR(object)) {
52152 - fscache_stat(&fscache_n_object_no_alloc);
52153 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52154 ret = PTR_ERR(object);
52155 goto error;
52156 }
52157
52158 - fscache_stat(&fscache_n_object_alloc);
52159 + fscache_stat_unchecked(&fscache_n_object_alloc);
52160
52161 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52162
52163 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52164
52165 _enter("{%s}", cookie->def->name);
52166
52167 - fscache_stat(&fscache_n_invalidates);
52168 + fscache_stat_unchecked(&fscache_n_invalidates);
52169
52170 /* Only permit invalidation of data files. Invalidating an index will
52171 * require the caller to release all its attachments to the tree rooted
52172 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52173 struct fscache_object *object;
52174 struct hlist_node *_p;
52175
52176 - fscache_stat(&fscache_n_updates);
52177 + fscache_stat_unchecked(&fscache_n_updates);
52178
52179 if (!cookie) {
52180 - fscache_stat(&fscache_n_updates_null);
52181 + fscache_stat_unchecked(&fscache_n_updates_null);
52182 _leave(" [no cookie]");
52183 return;
52184 }
52185 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52186 struct fscache_object *object;
52187 unsigned long event;
52188
52189 - fscache_stat(&fscache_n_relinquishes);
52190 + fscache_stat_unchecked(&fscache_n_relinquishes);
52191 if (retire)
52192 - fscache_stat(&fscache_n_relinquishes_retire);
52193 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52194
52195 if (!cookie) {
52196 - fscache_stat(&fscache_n_relinquishes_null);
52197 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52198 _leave(" [no cookie]");
52199 return;
52200 }
52201 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52202
52203 /* wait for the cookie to finish being instantiated (or to fail) */
52204 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52205 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52206 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52207 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52208 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52209 }
52210 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52211 index ee38fef..0a326d4 100644
52212 --- a/fs/fscache/internal.h
52213 +++ b/fs/fscache/internal.h
52214 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52215 * stats.c
52216 */
52217 #ifdef CONFIG_FSCACHE_STATS
52218 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52219 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52220 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52221 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52222
52223 -extern atomic_t fscache_n_op_pend;
52224 -extern atomic_t fscache_n_op_run;
52225 -extern atomic_t fscache_n_op_enqueue;
52226 -extern atomic_t fscache_n_op_deferred_release;
52227 -extern atomic_t fscache_n_op_release;
52228 -extern atomic_t fscache_n_op_gc;
52229 -extern atomic_t fscache_n_op_cancelled;
52230 -extern atomic_t fscache_n_op_rejected;
52231 +extern atomic_unchecked_t fscache_n_op_pend;
52232 +extern atomic_unchecked_t fscache_n_op_run;
52233 +extern atomic_unchecked_t fscache_n_op_enqueue;
52234 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52235 +extern atomic_unchecked_t fscache_n_op_release;
52236 +extern atomic_unchecked_t fscache_n_op_gc;
52237 +extern atomic_unchecked_t fscache_n_op_cancelled;
52238 +extern atomic_unchecked_t fscache_n_op_rejected;
52239
52240 -extern atomic_t fscache_n_attr_changed;
52241 -extern atomic_t fscache_n_attr_changed_ok;
52242 -extern atomic_t fscache_n_attr_changed_nobufs;
52243 -extern atomic_t fscache_n_attr_changed_nomem;
52244 -extern atomic_t fscache_n_attr_changed_calls;
52245 +extern atomic_unchecked_t fscache_n_attr_changed;
52246 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52247 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52248 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52249 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52250
52251 -extern atomic_t fscache_n_allocs;
52252 -extern atomic_t fscache_n_allocs_ok;
52253 -extern atomic_t fscache_n_allocs_wait;
52254 -extern atomic_t fscache_n_allocs_nobufs;
52255 -extern atomic_t fscache_n_allocs_intr;
52256 -extern atomic_t fscache_n_allocs_object_dead;
52257 -extern atomic_t fscache_n_alloc_ops;
52258 -extern atomic_t fscache_n_alloc_op_waits;
52259 +extern atomic_unchecked_t fscache_n_allocs;
52260 +extern atomic_unchecked_t fscache_n_allocs_ok;
52261 +extern atomic_unchecked_t fscache_n_allocs_wait;
52262 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52263 +extern atomic_unchecked_t fscache_n_allocs_intr;
52264 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52265 +extern atomic_unchecked_t fscache_n_alloc_ops;
52266 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52267
52268 -extern atomic_t fscache_n_retrievals;
52269 -extern atomic_t fscache_n_retrievals_ok;
52270 -extern atomic_t fscache_n_retrievals_wait;
52271 -extern atomic_t fscache_n_retrievals_nodata;
52272 -extern atomic_t fscache_n_retrievals_nobufs;
52273 -extern atomic_t fscache_n_retrievals_intr;
52274 -extern atomic_t fscache_n_retrievals_nomem;
52275 -extern atomic_t fscache_n_retrievals_object_dead;
52276 -extern atomic_t fscache_n_retrieval_ops;
52277 -extern atomic_t fscache_n_retrieval_op_waits;
52278 +extern atomic_unchecked_t fscache_n_retrievals;
52279 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52280 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52281 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52282 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52283 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52284 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52285 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52286 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52287 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52288
52289 -extern atomic_t fscache_n_stores;
52290 -extern atomic_t fscache_n_stores_ok;
52291 -extern atomic_t fscache_n_stores_again;
52292 -extern atomic_t fscache_n_stores_nobufs;
52293 -extern atomic_t fscache_n_stores_oom;
52294 -extern atomic_t fscache_n_store_ops;
52295 -extern atomic_t fscache_n_store_calls;
52296 -extern atomic_t fscache_n_store_pages;
52297 -extern atomic_t fscache_n_store_radix_deletes;
52298 -extern atomic_t fscache_n_store_pages_over_limit;
52299 +extern atomic_unchecked_t fscache_n_stores;
52300 +extern atomic_unchecked_t fscache_n_stores_ok;
52301 +extern atomic_unchecked_t fscache_n_stores_again;
52302 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52303 +extern atomic_unchecked_t fscache_n_stores_oom;
52304 +extern atomic_unchecked_t fscache_n_store_ops;
52305 +extern atomic_unchecked_t fscache_n_store_calls;
52306 +extern atomic_unchecked_t fscache_n_store_pages;
52307 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52308 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52309
52310 -extern atomic_t fscache_n_store_vmscan_not_storing;
52311 -extern atomic_t fscache_n_store_vmscan_gone;
52312 -extern atomic_t fscache_n_store_vmscan_busy;
52313 -extern atomic_t fscache_n_store_vmscan_cancelled;
52314 -extern atomic_t fscache_n_store_vmscan_wait;
52315 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52316 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52317 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52318 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52319 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52320
52321 -extern atomic_t fscache_n_marks;
52322 -extern atomic_t fscache_n_uncaches;
52323 +extern atomic_unchecked_t fscache_n_marks;
52324 +extern atomic_unchecked_t fscache_n_uncaches;
52325
52326 -extern atomic_t fscache_n_acquires;
52327 -extern atomic_t fscache_n_acquires_null;
52328 -extern atomic_t fscache_n_acquires_no_cache;
52329 -extern atomic_t fscache_n_acquires_ok;
52330 -extern atomic_t fscache_n_acquires_nobufs;
52331 -extern atomic_t fscache_n_acquires_oom;
52332 +extern atomic_unchecked_t fscache_n_acquires;
52333 +extern atomic_unchecked_t fscache_n_acquires_null;
52334 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52335 +extern atomic_unchecked_t fscache_n_acquires_ok;
52336 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52337 +extern atomic_unchecked_t fscache_n_acquires_oom;
52338
52339 -extern atomic_t fscache_n_invalidates;
52340 -extern atomic_t fscache_n_invalidates_run;
52341 +extern atomic_unchecked_t fscache_n_invalidates;
52342 +extern atomic_unchecked_t fscache_n_invalidates_run;
52343
52344 -extern atomic_t fscache_n_updates;
52345 -extern atomic_t fscache_n_updates_null;
52346 -extern atomic_t fscache_n_updates_run;
52347 +extern atomic_unchecked_t fscache_n_updates;
52348 +extern atomic_unchecked_t fscache_n_updates_null;
52349 +extern atomic_unchecked_t fscache_n_updates_run;
52350
52351 -extern atomic_t fscache_n_relinquishes;
52352 -extern atomic_t fscache_n_relinquishes_null;
52353 -extern atomic_t fscache_n_relinquishes_waitcrt;
52354 -extern atomic_t fscache_n_relinquishes_retire;
52355 +extern atomic_unchecked_t fscache_n_relinquishes;
52356 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52357 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52358 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52359
52360 -extern atomic_t fscache_n_cookie_index;
52361 -extern atomic_t fscache_n_cookie_data;
52362 -extern atomic_t fscache_n_cookie_special;
52363 +extern atomic_unchecked_t fscache_n_cookie_index;
52364 +extern atomic_unchecked_t fscache_n_cookie_data;
52365 +extern atomic_unchecked_t fscache_n_cookie_special;
52366
52367 -extern atomic_t fscache_n_object_alloc;
52368 -extern atomic_t fscache_n_object_no_alloc;
52369 -extern atomic_t fscache_n_object_lookups;
52370 -extern atomic_t fscache_n_object_lookups_negative;
52371 -extern atomic_t fscache_n_object_lookups_positive;
52372 -extern atomic_t fscache_n_object_lookups_timed_out;
52373 -extern atomic_t fscache_n_object_created;
52374 -extern atomic_t fscache_n_object_avail;
52375 -extern atomic_t fscache_n_object_dead;
52376 +extern atomic_unchecked_t fscache_n_object_alloc;
52377 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52378 +extern atomic_unchecked_t fscache_n_object_lookups;
52379 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52380 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52381 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52382 +extern atomic_unchecked_t fscache_n_object_created;
52383 +extern atomic_unchecked_t fscache_n_object_avail;
52384 +extern atomic_unchecked_t fscache_n_object_dead;
52385
52386 -extern atomic_t fscache_n_checkaux_none;
52387 -extern atomic_t fscache_n_checkaux_okay;
52388 -extern atomic_t fscache_n_checkaux_update;
52389 -extern atomic_t fscache_n_checkaux_obsolete;
52390 +extern atomic_unchecked_t fscache_n_checkaux_none;
52391 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52392 +extern atomic_unchecked_t fscache_n_checkaux_update;
52393 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52394
52395 extern atomic_t fscache_n_cop_alloc_object;
52396 extern atomic_t fscache_n_cop_lookup_object;
52397 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52398 atomic_inc(stat);
52399 }
52400
52401 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52402 +{
52403 + atomic_inc_unchecked(stat);
52404 +}
52405 +
52406 static inline void fscache_stat_d(atomic_t *stat)
52407 {
52408 atomic_dec(stat);
52409 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52410
52411 #define __fscache_stat(stat) (NULL)
52412 #define fscache_stat(stat) do {} while (0)
52413 +#define fscache_stat_unchecked(stat) do {} while (0)
52414 #define fscache_stat_d(stat) do {} while (0)
52415 #endif
52416
52417 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52418 index 50d41c1..10ee117 100644
52419 --- a/fs/fscache/object.c
52420 +++ b/fs/fscache/object.c
52421 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52422 /* Invalidate an object on disk */
52423 case FSCACHE_OBJECT_INVALIDATING:
52424 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52425 - fscache_stat(&fscache_n_invalidates_run);
52426 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52427 fscache_stat(&fscache_n_cop_invalidate_object);
52428 fscache_invalidate_object(object);
52429 fscache_stat_d(&fscache_n_cop_invalidate_object);
52430 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52431 /* update the object metadata on disk */
52432 case FSCACHE_OBJECT_UPDATING:
52433 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52434 - fscache_stat(&fscache_n_updates_run);
52435 + fscache_stat_unchecked(&fscache_n_updates_run);
52436 fscache_stat(&fscache_n_cop_update_object);
52437 object->cache->ops->update_object(object);
52438 fscache_stat_d(&fscache_n_cop_update_object);
52439 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52440 spin_lock(&object->lock);
52441 object->state = FSCACHE_OBJECT_DEAD;
52442 spin_unlock(&object->lock);
52443 - fscache_stat(&fscache_n_object_dead);
52444 + fscache_stat_unchecked(&fscache_n_object_dead);
52445 goto terminal_transit;
52446
52447 /* handle the parent cache of this object being withdrawn from
52448 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52449 spin_lock(&object->lock);
52450 object->state = FSCACHE_OBJECT_DEAD;
52451 spin_unlock(&object->lock);
52452 - fscache_stat(&fscache_n_object_dead);
52453 + fscache_stat_unchecked(&fscache_n_object_dead);
52454 goto terminal_transit;
52455
52456 /* complain about the object being woken up once it is
52457 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52458 parent->cookie->def->name, cookie->def->name,
52459 object->cache->tag->name);
52460
52461 - fscache_stat(&fscache_n_object_lookups);
52462 + fscache_stat_unchecked(&fscache_n_object_lookups);
52463 fscache_stat(&fscache_n_cop_lookup_object);
52464 ret = object->cache->ops->lookup_object(object);
52465 fscache_stat_d(&fscache_n_cop_lookup_object);
52466 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52467 if (ret == -ETIMEDOUT) {
52468 /* probably stuck behind another object, so move this one to
52469 * the back of the queue */
52470 - fscache_stat(&fscache_n_object_lookups_timed_out);
52471 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52472 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52473 }
52474
52475 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52476
52477 spin_lock(&object->lock);
52478 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52479 - fscache_stat(&fscache_n_object_lookups_negative);
52480 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52481
52482 /* transit here to allow write requests to begin stacking up
52483 * and read requests to begin returning ENODATA */
52484 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52485 * result, in which case there may be data available */
52486 spin_lock(&object->lock);
52487 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52488 - fscache_stat(&fscache_n_object_lookups_positive);
52489 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52490
52491 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52492
52493 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52494 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52495 } else {
52496 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52497 - fscache_stat(&fscache_n_object_created);
52498 + fscache_stat_unchecked(&fscache_n_object_created);
52499
52500 object->state = FSCACHE_OBJECT_AVAILABLE;
52501 spin_unlock(&object->lock);
52502 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52503 fscache_enqueue_dependents(object);
52504
52505 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52506 - fscache_stat(&fscache_n_object_avail);
52507 + fscache_stat_unchecked(&fscache_n_object_avail);
52508
52509 _leave("");
52510 }
52511 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52512 enum fscache_checkaux result;
52513
52514 if (!object->cookie->def->check_aux) {
52515 - fscache_stat(&fscache_n_checkaux_none);
52516 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52517 return FSCACHE_CHECKAUX_OKAY;
52518 }
52519
52520 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52521 switch (result) {
52522 /* entry okay as is */
52523 case FSCACHE_CHECKAUX_OKAY:
52524 - fscache_stat(&fscache_n_checkaux_okay);
52525 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52526 break;
52527
52528 /* entry requires update */
52529 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52530 - fscache_stat(&fscache_n_checkaux_update);
52531 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52532 break;
52533
52534 /* entry requires deletion */
52535 case FSCACHE_CHECKAUX_OBSOLETE:
52536 - fscache_stat(&fscache_n_checkaux_obsolete);
52537 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52538 break;
52539
52540 default:
52541 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52542 index 762a9ec..2023284 100644
52543 --- a/fs/fscache/operation.c
52544 +++ b/fs/fscache/operation.c
52545 @@ -17,7 +17,7 @@
52546 #include <linux/slab.h>
52547 #include "internal.h"
52548
52549 -atomic_t fscache_op_debug_id;
52550 +atomic_unchecked_t fscache_op_debug_id;
52551 EXPORT_SYMBOL(fscache_op_debug_id);
52552
52553 /**
52554 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52555 ASSERTCMP(atomic_read(&op->usage), >, 0);
52556 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52557
52558 - fscache_stat(&fscache_n_op_enqueue);
52559 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52560 switch (op->flags & FSCACHE_OP_TYPE) {
52561 case FSCACHE_OP_ASYNC:
52562 _debug("queue async");
52563 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52564 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52565 if (op->processor)
52566 fscache_enqueue_operation(op);
52567 - fscache_stat(&fscache_n_op_run);
52568 + fscache_stat_unchecked(&fscache_n_op_run);
52569 }
52570
52571 /*
52572 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52573 if (object->n_in_progress > 0) {
52574 atomic_inc(&op->usage);
52575 list_add_tail(&op->pend_link, &object->pending_ops);
52576 - fscache_stat(&fscache_n_op_pend);
52577 + fscache_stat_unchecked(&fscache_n_op_pend);
52578 } else if (!list_empty(&object->pending_ops)) {
52579 atomic_inc(&op->usage);
52580 list_add_tail(&op->pend_link, &object->pending_ops);
52581 - fscache_stat(&fscache_n_op_pend);
52582 + fscache_stat_unchecked(&fscache_n_op_pend);
52583 fscache_start_operations(object);
52584 } else {
52585 ASSERTCMP(object->n_in_progress, ==, 0);
52586 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52587 object->n_exclusive++; /* reads and writes must wait */
52588 atomic_inc(&op->usage);
52589 list_add_tail(&op->pend_link, &object->pending_ops);
52590 - fscache_stat(&fscache_n_op_pend);
52591 + fscache_stat_unchecked(&fscache_n_op_pend);
52592 ret = 0;
52593 } else {
52594 /* If we're in any other state, there must have been an I/O
52595 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52596 if (object->n_exclusive > 0) {
52597 atomic_inc(&op->usage);
52598 list_add_tail(&op->pend_link, &object->pending_ops);
52599 - fscache_stat(&fscache_n_op_pend);
52600 + fscache_stat_unchecked(&fscache_n_op_pend);
52601 } else if (!list_empty(&object->pending_ops)) {
52602 atomic_inc(&op->usage);
52603 list_add_tail(&op->pend_link, &object->pending_ops);
52604 - fscache_stat(&fscache_n_op_pend);
52605 + fscache_stat_unchecked(&fscache_n_op_pend);
52606 fscache_start_operations(object);
52607 } else {
52608 ASSERTCMP(object->n_exclusive, ==, 0);
52609 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52610 object->n_ops++;
52611 atomic_inc(&op->usage);
52612 list_add_tail(&op->pend_link, &object->pending_ops);
52613 - fscache_stat(&fscache_n_op_pend);
52614 + fscache_stat_unchecked(&fscache_n_op_pend);
52615 ret = 0;
52616 } else if (object->state == FSCACHE_OBJECT_DYING ||
52617 object->state == FSCACHE_OBJECT_LC_DYING ||
52618 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52619 - fscache_stat(&fscache_n_op_rejected);
52620 + fscache_stat_unchecked(&fscache_n_op_rejected);
52621 op->state = FSCACHE_OP_ST_CANCELLED;
52622 ret = -ENOBUFS;
52623 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52624 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52625 ret = -EBUSY;
52626 if (op->state == FSCACHE_OP_ST_PENDING) {
52627 ASSERT(!list_empty(&op->pend_link));
52628 - fscache_stat(&fscache_n_op_cancelled);
52629 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52630 list_del_init(&op->pend_link);
52631 if (do_cancel)
52632 do_cancel(op);
52633 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52634 while (!list_empty(&object->pending_ops)) {
52635 op = list_entry(object->pending_ops.next,
52636 struct fscache_operation, pend_link);
52637 - fscache_stat(&fscache_n_op_cancelled);
52638 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52639 list_del_init(&op->pend_link);
52640
52641 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52642 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52643 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52644 op->state = FSCACHE_OP_ST_DEAD;
52645
52646 - fscache_stat(&fscache_n_op_release);
52647 + fscache_stat_unchecked(&fscache_n_op_release);
52648
52649 if (op->release) {
52650 op->release(op);
52651 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52652 * lock, and defer it otherwise */
52653 if (!spin_trylock(&object->lock)) {
52654 _debug("defer put");
52655 - fscache_stat(&fscache_n_op_deferred_release);
52656 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52657
52658 cache = object->cache;
52659 spin_lock(&cache->op_gc_list_lock);
52660 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52661
52662 _debug("GC DEFERRED REL OBJ%x OP%x",
52663 object->debug_id, op->debug_id);
52664 - fscache_stat(&fscache_n_op_gc);
52665 + fscache_stat_unchecked(&fscache_n_op_gc);
52666
52667 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52668 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52669 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52670 index ff000e5..c44ec6d 100644
52671 --- a/fs/fscache/page.c
52672 +++ b/fs/fscache/page.c
52673 @@ -61,7 +61,7 @@ try_again:
52674 val = radix_tree_lookup(&cookie->stores, page->index);
52675 if (!val) {
52676 rcu_read_unlock();
52677 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52678 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52679 __fscache_uncache_page(cookie, page);
52680 return true;
52681 }
52682 @@ -91,11 +91,11 @@ try_again:
52683 spin_unlock(&cookie->stores_lock);
52684
52685 if (xpage) {
52686 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52687 - fscache_stat(&fscache_n_store_radix_deletes);
52688 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52689 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52690 ASSERTCMP(xpage, ==, page);
52691 } else {
52692 - fscache_stat(&fscache_n_store_vmscan_gone);
52693 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52694 }
52695
52696 wake_up_bit(&cookie->flags, 0);
52697 @@ -110,11 +110,11 @@ page_busy:
52698 * sleeping on memory allocation, so we may need to impose a timeout
52699 * too. */
52700 if (!(gfp & __GFP_WAIT)) {
52701 - fscache_stat(&fscache_n_store_vmscan_busy);
52702 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52703 return false;
52704 }
52705
52706 - fscache_stat(&fscache_n_store_vmscan_wait);
52707 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52708 __fscache_wait_on_page_write(cookie, page);
52709 gfp &= ~__GFP_WAIT;
52710 goto try_again;
52711 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52712 FSCACHE_COOKIE_STORING_TAG);
52713 if (!radix_tree_tag_get(&cookie->stores, page->index,
52714 FSCACHE_COOKIE_PENDING_TAG)) {
52715 - fscache_stat(&fscache_n_store_radix_deletes);
52716 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52717 xpage = radix_tree_delete(&cookie->stores, page->index);
52718 }
52719 spin_unlock(&cookie->stores_lock);
52720 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52721
52722 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52723
52724 - fscache_stat(&fscache_n_attr_changed_calls);
52725 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52726
52727 if (fscache_object_is_active(object)) {
52728 fscache_stat(&fscache_n_cop_attr_changed);
52729 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52730
52731 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52732
52733 - fscache_stat(&fscache_n_attr_changed);
52734 + fscache_stat_unchecked(&fscache_n_attr_changed);
52735
52736 op = kzalloc(sizeof(*op), GFP_KERNEL);
52737 if (!op) {
52738 - fscache_stat(&fscache_n_attr_changed_nomem);
52739 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52740 _leave(" = -ENOMEM");
52741 return -ENOMEM;
52742 }
52743 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52744 if (fscache_submit_exclusive_op(object, op) < 0)
52745 goto nobufs;
52746 spin_unlock(&cookie->lock);
52747 - fscache_stat(&fscache_n_attr_changed_ok);
52748 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52749 fscache_put_operation(op);
52750 _leave(" = 0");
52751 return 0;
52752 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52753 nobufs:
52754 spin_unlock(&cookie->lock);
52755 kfree(op);
52756 - fscache_stat(&fscache_n_attr_changed_nobufs);
52757 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52758 _leave(" = %d", -ENOBUFS);
52759 return -ENOBUFS;
52760 }
52761 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52762 /* allocate a retrieval operation and attempt to submit it */
52763 op = kzalloc(sizeof(*op), GFP_NOIO);
52764 if (!op) {
52765 - fscache_stat(&fscache_n_retrievals_nomem);
52766 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52767 return NULL;
52768 }
52769
52770 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52771 return 0;
52772 }
52773
52774 - fscache_stat(&fscache_n_retrievals_wait);
52775 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52776
52777 jif = jiffies;
52778 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52779 fscache_wait_bit_interruptible,
52780 TASK_INTERRUPTIBLE) != 0) {
52781 - fscache_stat(&fscache_n_retrievals_intr);
52782 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52783 _leave(" = -ERESTARTSYS");
52784 return -ERESTARTSYS;
52785 }
52786 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52787 */
52788 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52789 struct fscache_retrieval *op,
52790 - atomic_t *stat_op_waits,
52791 - atomic_t *stat_object_dead)
52792 + atomic_unchecked_t *stat_op_waits,
52793 + atomic_unchecked_t *stat_object_dead)
52794 {
52795 int ret;
52796
52797 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52798 goto check_if_dead;
52799
52800 _debug(">>> WT");
52801 - fscache_stat(stat_op_waits);
52802 + fscache_stat_unchecked(stat_op_waits);
52803 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52804 fscache_wait_bit_interruptible,
52805 TASK_INTERRUPTIBLE) != 0) {
52806 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52807
52808 check_if_dead:
52809 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52810 - fscache_stat(stat_object_dead);
52811 + fscache_stat_unchecked(stat_object_dead);
52812 _leave(" = -ENOBUFS [cancelled]");
52813 return -ENOBUFS;
52814 }
52815 if (unlikely(fscache_object_is_dead(object))) {
52816 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52817 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52818 - fscache_stat(stat_object_dead);
52819 + fscache_stat_unchecked(stat_object_dead);
52820 return -ENOBUFS;
52821 }
52822 return 0;
52823 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52824
52825 _enter("%p,%p,,,", cookie, page);
52826
52827 - fscache_stat(&fscache_n_retrievals);
52828 + fscache_stat_unchecked(&fscache_n_retrievals);
52829
52830 if (hlist_empty(&cookie->backing_objects))
52831 goto nobufs;
52832 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52833 goto nobufs_unlock_dec;
52834 spin_unlock(&cookie->lock);
52835
52836 - fscache_stat(&fscache_n_retrieval_ops);
52837 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52838
52839 /* pin the netfs read context in case we need to do the actual netfs
52840 * read because we've encountered a cache read failure */
52841 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52842
52843 error:
52844 if (ret == -ENOMEM)
52845 - fscache_stat(&fscache_n_retrievals_nomem);
52846 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52847 else if (ret == -ERESTARTSYS)
52848 - fscache_stat(&fscache_n_retrievals_intr);
52849 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52850 else if (ret == -ENODATA)
52851 - fscache_stat(&fscache_n_retrievals_nodata);
52852 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52853 else if (ret < 0)
52854 - fscache_stat(&fscache_n_retrievals_nobufs);
52855 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52856 else
52857 - fscache_stat(&fscache_n_retrievals_ok);
52858 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52859
52860 fscache_put_retrieval(op);
52861 _leave(" = %d", ret);
52862 @@ -467,7 +467,7 @@ nobufs_unlock:
52863 spin_unlock(&cookie->lock);
52864 kfree(op);
52865 nobufs:
52866 - fscache_stat(&fscache_n_retrievals_nobufs);
52867 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52868 _leave(" = -ENOBUFS");
52869 return -ENOBUFS;
52870 }
52871 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52872
52873 _enter("%p,,%d,,,", cookie, *nr_pages);
52874
52875 - fscache_stat(&fscache_n_retrievals);
52876 + fscache_stat_unchecked(&fscache_n_retrievals);
52877
52878 if (hlist_empty(&cookie->backing_objects))
52879 goto nobufs;
52880 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52881 goto nobufs_unlock_dec;
52882 spin_unlock(&cookie->lock);
52883
52884 - fscache_stat(&fscache_n_retrieval_ops);
52885 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52886
52887 /* pin the netfs read context in case we need to do the actual netfs
52888 * read because we've encountered a cache read failure */
52889 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52890
52891 error:
52892 if (ret == -ENOMEM)
52893 - fscache_stat(&fscache_n_retrievals_nomem);
52894 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52895 else if (ret == -ERESTARTSYS)
52896 - fscache_stat(&fscache_n_retrievals_intr);
52897 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52898 else if (ret == -ENODATA)
52899 - fscache_stat(&fscache_n_retrievals_nodata);
52900 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52901 else if (ret < 0)
52902 - fscache_stat(&fscache_n_retrievals_nobufs);
52903 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52904 else
52905 - fscache_stat(&fscache_n_retrievals_ok);
52906 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52907
52908 fscache_put_retrieval(op);
52909 _leave(" = %d", ret);
52910 @@ -591,7 +591,7 @@ nobufs_unlock:
52911 spin_unlock(&cookie->lock);
52912 kfree(op);
52913 nobufs:
52914 - fscache_stat(&fscache_n_retrievals_nobufs);
52915 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52916 _leave(" = -ENOBUFS");
52917 return -ENOBUFS;
52918 }
52919 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52920
52921 _enter("%p,%p,,,", cookie, page);
52922
52923 - fscache_stat(&fscache_n_allocs);
52924 + fscache_stat_unchecked(&fscache_n_allocs);
52925
52926 if (hlist_empty(&cookie->backing_objects))
52927 goto nobufs;
52928 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52929 goto nobufs_unlock;
52930 spin_unlock(&cookie->lock);
52931
52932 - fscache_stat(&fscache_n_alloc_ops);
52933 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52934
52935 ret = fscache_wait_for_retrieval_activation(
52936 object, op,
52937 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52938
52939 error:
52940 if (ret == -ERESTARTSYS)
52941 - fscache_stat(&fscache_n_allocs_intr);
52942 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52943 else if (ret < 0)
52944 - fscache_stat(&fscache_n_allocs_nobufs);
52945 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52946 else
52947 - fscache_stat(&fscache_n_allocs_ok);
52948 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52949
52950 fscache_put_retrieval(op);
52951 _leave(" = %d", ret);
52952 @@ -677,7 +677,7 @@ nobufs_unlock:
52953 spin_unlock(&cookie->lock);
52954 kfree(op);
52955 nobufs:
52956 - fscache_stat(&fscache_n_allocs_nobufs);
52957 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52958 _leave(" = -ENOBUFS");
52959 return -ENOBUFS;
52960 }
52961 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52962
52963 spin_lock(&cookie->stores_lock);
52964
52965 - fscache_stat(&fscache_n_store_calls);
52966 + fscache_stat_unchecked(&fscache_n_store_calls);
52967
52968 /* find a page to store */
52969 page = NULL;
52970 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52971 page = results[0];
52972 _debug("gang %d [%lx]", n, page->index);
52973 if (page->index > op->store_limit) {
52974 - fscache_stat(&fscache_n_store_pages_over_limit);
52975 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52976 goto superseded;
52977 }
52978
52979 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52980 spin_unlock(&cookie->stores_lock);
52981 spin_unlock(&object->lock);
52982
52983 - fscache_stat(&fscache_n_store_pages);
52984 + fscache_stat_unchecked(&fscache_n_store_pages);
52985 fscache_stat(&fscache_n_cop_write_page);
52986 ret = object->cache->ops->write_page(op, page);
52987 fscache_stat_d(&fscache_n_cop_write_page);
52988 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52989 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52990 ASSERT(PageFsCache(page));
52991
52992 - fscache_stat(&fscache_n_stores);
52993 + fscache_stat_unchecked(&fscache_n_stores);
52994
52995 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52996 _leave(" = -ENOBUFS [invalidating]");
52997 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52998 spin_unlock(&cookie->stores_lock);
52999 spin_unlock(&object->lock);
53000
53001 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
53002 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
53003 op->store_limit = object->store_limit;
53004
53005 if (fscache_submit_op(object, &op->op) < 0)
53006 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53007
53008 spin_unlock(&cookie->lock);
53009 radix_tree_preload_end();
53010 - fscache_stat(&fscache_n_store_ops);
53011 - fscache_stat(&fscache_n_stores_ok);
53012 + fscache_stat_unchecked(&fscache_n_store_ops);
53013 + fscache_stat_unchecked(&fscache_n_stores_ok);
53014
53015 /* the work queue now carries its own ref on the object */
53016 fscache_put_operation(&op->op);
53017 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
53018 return 0;
53019
53020 already_queued:
53021 - fscache_stat(&fscache_n_stores_again);
53022 + fscache_stat_unchecked(&fscache_n_stores_again);
53023 already_pending:
53024 spin_unlock(&cookie->stores_lock);
53025 spin_unlock(&object->lock);
53026 spin_unlock(&cookie->lock);
53027 radix_tree_preload_end();
53028 kfree(op);
53029 - fscache_stat(&fscache_n_stores_ok);
53030 + fscache_stat_unchecked(&fscache_n_stores_ok);
53031 _leave(" = 0");
53032 return 0;
53033
53034 @@ -959,14 +959,14 @@ nobufs:
53035 spin_unlock(&cookie->lock);
53036 radix_tree_preload_end();
53037 kfree(op);
53038 - fscache_stat(&fscache_n_stores_nobufs);
53039 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
53040 _leave(" = -ENOBUFS");
53041 return -ENOBUFS;
53042
53043 nomem_free:
53044 kfree(op);
53045 nomem:
53046 - fscache_stat(&fscache_n_stores_oom);
53047 + fscache_stat_unchecked(&fscache_n_stores_oom);
53048 _leave(" = -ENOMEM");
53049 return -ENOMEM;
53050 }
53051 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
53052 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
53053 ASSERTCMP(page, !=, NULL);
53054
53055 - fscache_stat(&fscache_n_uncaches);
53056 + fscache_stat_unchecked(&fscache_n_uncaches);
53057
53058 /* cache withdrawal may beat us to it */
53059 if (!PageFsCache(page))
53060 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
53061 struct fscache_cookie *cookie = op->op.object->cookie;
53062
53063 #ifdef CONFIG_FSCACHE_STATS
53064 - atomic_inc(&fscache_n_marks);
53065 + atomic_inc_unchecked(&fscache_n_marks);
53066 #endif
53067
53068 _debug("- mark %p{%lx}", page, page->index);
53069 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
53070 index 40d13c7..ddf52b9 100644
53071 --- a/fs/fscache/stats.c
53072 +++ b/fs/fscache/stats.c
53073 @@ -18,99 +18,99 @@
53074 /*
53075 * operation counters
53076 */
53077 -atomic_t fscache_n_op_pend;
53078 -atomic_t fscache_n_op_run;
53079 -atomic_t fscache_n_op_enqueue;
53080 -atomic_t fscache_n_op_requeue;
53081 -atomic_t fscache_n_op_deferred_release;
53082 -atomic_t fscache_n_op_release;
53083 -atomic_t fscache_n_op_gc;
53084 -atomic_t fscache_n_op_cancelled;
53085 -atomic_t fscache_n_op_rejected;
53086 +atomic_unchecked_t fscache_n_op_pend;
53087 +atomic_unchecked_t fscache_n_op_run;
53088 +atomic_unchecked_t fscache_n_op_enqueue;
53089 +atomic_unchecked_t fscache_n_op_requeue;
53090 +atomic_unchecked_t fscache_n_op_deferred_release;
53091 +atomic_unchecked_t fscache_n_op_release;
53092 +atomic_unchecked_t fscache_n_op_gc;
53093 +atomic_unchecked_t fscache_n_op_cancelled;
53094 +atomic_unchecked_t fscache_n_op_rejected;
53095
53096 -atomic_t fscache_n_attr_changed;
53097 -atomic_t fscache_n_attr_changed_ok;
53098 -atomic_t fscache_n_attr_changed_nobufs;
53099 -atomic_t fscache_n_attr_changed_nomem;
53100 -atomic_t fscache_n_attr_changed_calls;
53101 +atomic_unchecked_t fscache_n_attr_changed;
53102 +atomic_unchecked_t fscache_n_attr_changed_ok;
53103 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53104 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53105 +atomic_unchecked_t fscache_n_attr_changed_calls;
53106
53107 -atomic_t fscache_n_allocs;
53108 -atomic_t fscache_n_allocs_ok;
53109 -atomic_t fscache_n_allocs_wait;
53110 -atomic_t fscache_n_allocs_nobufs;
53111 -atomic_t fscache_n_allocs_intr;
53112 -atomic_t fscache_n_allocs_object_dead;
53113 -atomic_t fscache_n_alloc_ops;
53114 -atomic_t fscache_n_alloc_op_waits;
53115 +atomic_unchecked_t fscache_n_allocs;
53116 +atomic_unchecked_t fscache_n_allocs_ok;
53117 +atomic_unchecked_t fscache_n_allocs_wait;
53118 +atomic_unchecked_t fscache_n_allocs_nobufs;
53119 +atomic_unchecked_t fscache_n_allocs_intr;
53120 +atomic_unchecked_t fscache_n_allocs_object_dead;
53121 +atomic_unchecked_t fscache_n_alloc_ops;
53122 +atomic_unchecked_t fscache_n_alloc_op_waits;
53123
53124 -atomic_t fscache_n_retrievals;
53125 -atomic_t fscache_n_retrievals_ok;
53126 -atomic_t fscache_n_retrievals_wait;
53127 -atomic_t fscache_n_retrievals_nodata;
53128 -atomic_t fscache_n_retrievals_nobufs;
53129 -atomic_t fscache_n_retrievals_intr;
53130 -atomic_t fscache_n_retrievals_nomem;
53131 -atomic_t fscache_n_retrievals_object_dead;
53132 -atomic_t fscache_n_retrieval_ops;
53133 -atomic_t fscache_n_retrieval_op_waits;
53134 +atomic_unchecked_t fscache_n_retrievals;
53135 +atomic_unchecked_t fscache_n_retrievals_ok;
53136 +atomic_unchecked_t fscache_n_retrievals_wait;
53137 +atomic_unchecked_t fscache_n_retrievals_nodata;
53138 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53139 +atomic_unchecked_t fscache_n_retrievals_intr;
53140 +atomic_unchecked_t fscache_n_retrievals_nomem;
53141 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53142 +atomic_unchecked_t fscache_n_retrieval_ops;
53143 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53144
53145 -atomic_t fscache_n_stores;
53146 -atomic_t fscache_n_stores_ok;
53147 -atomic_t fscache_n_stores_again;
53148 -atomic_t fscache_n_stores_nobufs;
53149 -atomic_t fscache_n_stores_oom;
53150 -atomic_t fscache_n_store_ops;
53151 -atomic_t fscache_n_store_calls;
53152 -atomic_t fscache_n_store_pages;
53153 -atomic_t fscache_n_store_radix_deletes;
53154 -atomic_t fscache_n_store_pages_over_limit;
53155 +atomic_unchecked_t fscache_n_stores;
53156 +atomic_unchecked_t fscache_n_stores_ok;
53157 +atomic_unchecked_t fscache_n_stores_again;
53158 +atomic_unchecked_t fscache_n_stores_nobufs;
53159 +atomic_unchecked_t fscache_n_stores_oom;
53160 +atomic_unchecked_t fscache_n_store_ops;
53161 +atomic_unchecked_t fscache_n_store_calls;
53162 +atomic_unchecked_t fscache_n_store_pages;
53163 +atomic_unchecked_t fscache_n_store_radix_deletes;
53164 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53165
53166 -atomic_t fscache_n_store_vmscan_not_storing;
53167 -atomic_t fscache_n_store_vmscan_gone;
53168 -atomic_t fscache_n_store_vmscan_busy;
53169 -atomic_t fscache_n_store_vmscan_cancelled;
53170 -atomic_t fscache_n_store_vmscan_wait;
53171 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53172 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53173 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53174 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53175 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53176
53177 -atomic_t fscache_n_marks;
53178 -atomic_t fscache_n_uncaches;
53179 +atomic_unchecked_t fscache_n_marks;
53180 +atomic_unchecked_t fscache_n_uncaches;
53181
53182 -atomic_t fscache_n_acquires;
53183 -atomic_t fscache_n_acquires_null;
53184 -atomic_t fscache_n_acquires_no_cache;
53185 -atomic_t fscache_n_acquires_ok;
53186 -atomic_t fscache_n_acquires_nobufs;
53187 -atomic_t fscache_n_acquires_oom;
53188 +atomic_unchecked_t fscache_n_acquires;
53189 +atomic_unchecked_t fscache_n_acquires_null;
53190 +atomic_unchecked_t fscache_n_acquires_no_cache;
53191 +atomic_unchecked_t fscache_n_acquires_ok;
53192 +atomic_unchecked_t fscache_n_acquires_nobufs;
53193 +atomic_unchecked_t fscache_n_acquires_oom;
53194
53195 -atomic_t fscache_n_invalidates;
53196 -atomic_t fscache_n_invalidates_run;
53197 +atomic_unchecked_t fscache_n_invalidates;
53198 +atomic_unchecked_t fscache_n_invalidates_run;
53199
53200 -atomic_t fscache_n_updates;
53201 -atomic_t fscache_n_updates_null;
53202 -atomic_t fscache_n_updates_run;
53203 +atomic_unchecked_t fscache_n_updates;
53204 +atomic_unchecked_t fscache_n_updates_null;
53205 +atomic_unchecked_t fscache_n_updates_run;
53206
53207 -atomic_t fscache_n_relinquishes;
53208 -atomic_t fscache_n_relinquishes_null;
53209 -atomic_t fscache_n_relinquishes_waitcrt;
53210 -atomic_t fscache_n_relinquishes_retire;
53211 +atomic_unchecked_t fscache_n_relinquishes;
53212 +atomic_unchecked_t fscache_n_relinquishes_null;
53213 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53214 +atomic_unchecked_t fscache_n_relinquishes_retire;
53215
53216 -atomic_t fscache_n_cookie_index;
53217 -atomic_t fscache_n_cookie_data;
53218 -atomic_t fscache_n_cookie_special;
53219 +atomic_unchecked_t fscache_n_cookie_index;
53220 +atomic_unchecked_t fscache_n_cookie_data;
53221 +atomic_unchecked_t fscache_n_cookie_special;
53222
53223 -atomic_t fscache_n_object_alloc;
53224 -atomic_t fscache_n_object_no_alloc;
53225 -atomic_t fscache_n_object_lookups;
53226 -atomic_t fscache_n_object_lookups_negative;
53227 -atomic_t fscache_n_object_lookups_positive;
53228 -atomic_t fscache_n_object_lookups_timed_out;
53229 -atomic_t fscache_n_object_created;
53230 -atomic_t fscache_n_object_avail;
53231 -atomic_t fscache_n_object_dead;
53232 +atomic_unchecked_t fscache_n_object_alloc;
53233 +atomic_unchecked_t fscache_n_object_no_alloc;
53234 +atomic_unchecked_t fscache_n_object_lookups;
53235 +atomic_unchecked_t fscache_n_object_lookups_negative;
53236 +atomic_unchecked_t fscache_n_object_lookups_positive;
53237 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53238 +atomic_unchecked_t fscache_n_object_created;
53239 +atomic_unchecked_t fscache_n_object_avail;
53240 +atomic_unchecked_t fscache_n_object_dead;
53241
53242 -atomic_t fscache_n_checkaux_none;
53243 -atomic_t fscache_n_checkaux_okay;
53244 -atomic_t fscache_n_checkaux_update;
53245 -atomic_t fscache_n_checkaux_obsolete;
53246 +atomic_unchecked_t fscache_n_checkaux_none;
53247 +atomic_unchecked_t fscache_n_checkaux_okay;
53248 +atomic_unchecked_t fscache_n_checkaux_update;
53249 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53250
53251 atomic_t fscache_n_cop_alloc_object;
53252 atomic_t fscache_n_cop_lookup_object;
53253 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53254 seq_puts(m, "FS-Cache statistics\n");
53255
53256 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53257 - atomic_read(&fscache_n_cookie_index),
53258 - atomic_read(&fscache_n_cookie_data),
53259 - atomic_read(&fscache_n_cookie_special));
53260 + atomic_read_unchecked(&fscache_n_cookie_index),
53261 + atomic_read_unchecked(&fscache_n_cookie_data),
53262 + atomic_read_unchecked(&fscache_n_cookie_special));
53263
53264 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53265 - atomic_read(&fscache_n_object_alloc),
53266 - atomic_read(&fscache_n_object_no_alloc),
53267 - atomic_read(&fscache_n_object_avail),
53268 - atomic_read(&fscache_n_object_dead));
53269 + atomic_read_unchecked(&fscache_n_object_alloc),
53270 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53271 + atomic_read_unchecked(&fscache_n_object_avail),
53272 + atomic_read_unchecked(&fscache_n_object_dead));
53273 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53274 - atomic_read(&fscache_n_checkaux_none),
53275 - atomic_read(&fscache_n_checkaux_okay),
53276 - atomic_read(&fscache_n_checkaux_update),
53277 - atomic_read(&fscache_n_checkaux_obsolete));
53278 + atomic_read_unchecked(&fscache_n_checkaux_none),
53279 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53280 + atomic_read_unchecked(&fscache_n_checkaux_update),
53281 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53282
53283 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53284 - atomic_read(&fscache_n_marks),
53285 - atomic_read(&fscache_n_uncaches));
53286 + atomic_read_unchecked(&fscache_n_marks),
53287 + atomic_read_unchecked(&fscache_n_uncaches));
53288
53289 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53290 " oom=%u\n",
53291 - atomic_read(&fscache_n_acquires),
53292 - atomic_read(&fscache_n_acquires_null),
53293 - atomic_read(&fscache_n_acquires_no_cache),
53294 - atomic_read(&fscache_n_acquires_ok),
53295 - atomic_read(&fscache_n_acquires_nobufs),
53296 - atomic_read(&fscache_n_acquires_oom));
53297 + atomic_read_unchecked(&fscache_n_acquires),
53298 + atomic_read_unchecked(&fscache_n_acquires_null),
53299 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53300 + atomic_read_unchecked(&fscache_n_acquires_ok),
53301 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53302 + atomic_read_unchecked(&fscache_n_acquires_oom));
53303
53304 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53305 - atomic_read(&fscache_n_object_lookups),
53306 - atomic_read(&fscache_n_object_lookups_negative),
53307 - atomic_read(&fscache_n_object_lookups_positive),
53308 - atomic_read(&fscache_n_object_created),
53309 - atomic_read(&fscache_n_object_lookups_timed_out));
53310 + atomic_read_unchecked(&fscache_n_object_lookups),
53311 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53312 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53313 + atomic_read_unchecked(&fscache_n_object_created),
53314 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53315
53316 seq_printf(m, "Invals : n=%u run=%u\n",
53317 - atomic_read(&fscache_n_invalidates),
53318 - atomic_read(&fscache_n_invalidates_run));
53319 + atomic_read_unchecked(&fscache_n_invalidates),
53320 + atomic_read_unchecked(&fscache_n_invalidates_run));
53321
53322 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53323 - atomic_read(&fscache_n_updates),
53324 - atomic_read(&fscache_n_updates_null),
53325 - atomic_read(&fscache_n_updates_run));
53326 + atomic_read_unchecked(&fscache_n_updates),
53327 + atomic_read_unchecked(&fscache_n_updates_null),
53328 + atomic_read_unchecked(&fscache_n_updates_run));
53329
53330 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53331 - atomic_read(&fscache_n_relinquishes),
53332 - atomic_read(&fscache_n_relinquishes_null),
53333 - atomic_read(&fscache_n_relinquishes_waitcrt),
53334 - atomic_read(&fscache_n_relinquishes_retire));
53335 + atomic_read_unchecked(&fscache_n_relinquishes),
53336 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53337 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53338 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53339
53340 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53341 - atomic_read(&fscache_n_attr_changed),
53342 - atomic_read(&fscache_n_attr_changed_ok),
53343 - atomic_read(&fscache_n_attr_changed_nobufs),
53344 - atomic_read(&fscache_n_attr_changed_nomem),
53345 - atomic_read(&fscache_n_attr_changed_calls));
53346 + atomic_read_unchecked(&fscache_n_attr_changed),
53347 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53348 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53349 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53350 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53351
53352 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53353 - atomic_read(&fscache_n_allocs),
53354 - atomic_read(&fscache_n_allocs_ok),
53355 - atomic_read(&fscache_n_allocs_wait),
53356 - atomic_read(&fscache_n_allocs_nobufs),
53357 - atomic_read(&fscache_n_allocs_intr));
53358 + atomic_read_unchecked(&fscache_n_allocs),
53359 + atomic_read_unchecked(&fscache_n_allocs_ok),
53360 + atomic_read_unchecked(&fscache_n_allocs_wait),
53361 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53362 + atomic_read_unchecked(&fscache_n_allocs_intr));
53363 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53364 - atomic_read(&fscache_n_alloc_ops),
53365 - atomic_read(&fscache_n_alloc_op_waits),
53366 - atomic_read(&fscache_n_allocs_object_dead));
53367 + atomic_read_unchecked(&fscache_n_alloc_ops),
53368 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53369 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53370
53371 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53372 " int=%u oom=%u\n",
53373 - atomic_read(&fscache_n_retrievals),
53374 - atomic_read(&fscache_n_retrievals_ok),
53375 - atomic_read(&fscache_n_retrievals_wait),
53376 - atomic_read(&fscache_n_retrievals_nodata),
53377 - atomic_read(&fscache_n_retrievals_nobufs),
53378 - atomic_read(&fscache_n_retrievals_intr),
53379 - atomic_read(&fscache_n_retrievals_nomem));
53380 + atomic_read_unchecked(&fscache_n_retrievals),
53381 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53382 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53383 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53384 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53385 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53386 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53387 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53388 - atomic_read(&fscache_n_retrieval_ops),
53389 - atomic_read(&fscache_n_retrieval_op_waits),
53390 - atomic_read(&fscache_n_retrievals_object_dead));
53391 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53392 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53393 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53394
53395 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53396 - atomic_read(&fscache_n_stores),
53397 - atomic_read(&fscache_n_stores_ok),
53398 - atomic_read(&fscache_n_stores_again),
53399 - atomic_read(&fscache_n_stores_nobufs),
53400 - atomic_read(&fscache_n_stores_oom));
53401 + atomic_read_unchecked(&fscache_n_stores),
53402 + atomic_read_unchecked(&fscache_n_stores_ok),
53403 + atomic_read_unchecked(&fscache_n_stores_again),
53404 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53405 + atomic_read_unchecked(&fscache_n_stores_oom));
53406 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53407 - atomic_read(&fscache_n_store_ops),
53408 - atomic_read(&fscache_n_store_calls),
53409 - atomic_read(&fscache_n_store_pages),
53410 - atomic_read(&fscache_n_store_radix_deletes),
53411 - atomic_read(&fscache_n_store_pages_over_limit));
53412 + atomic_read_unchecked(&fscache_n_store_ops),
53413 + atomic_read_unchecked(&fscache_n_store_calls),
53414 + atomic_read_unchecked(&fscache_n_store_pages),
53415 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53416 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53417
53418 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53419 - atomic_read(&fscache_n_store_vmscan_not_storing),
53420 - atomic_read(&fscache_n_store_vmscan_gone),
53421 - atomic_read(&fscache_n_store_vmscan_busy),
53422 - atomic_read(&fscache_n_store_vmscan_cancelled),
53423 - atomic_read(&fscache_n_store_vmscan_wait));
53424 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53425 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53426 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53427 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53428 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53429
53430 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53431 - atomic_read(&fscache_n_op_pend),
53432 - atomic_read(&fscache_n_op_run),
53433 - atomic_read(&fscache_n_op_enqueue),
53434 - atomic_read(&fscache_n_op_cancelled),
53435 - atomic_read(&fscache_n_op_rejected));
53436 + atomic_read_unchecked(&fscache_n_op_pend),
53437 + atomic_read_unchecked(&fscache_n_op_run),
53438 + atomic_read_unchecked(&fscache_n_op_enqueue),
53439 + atomic_read_unchecked(&fscache_n_op_cancelled),
53440 + atomic_read_unchecked(&fscache_n_op_rejected));
53441 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53442 - atomic_read(&fscache_n_op_deferred_release),
53443 - atomic_read(&fscache_n_op_release),
53444 - atomic_read(&fscache_n_op_gc));
53445 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53446 + atomic_read_unchecked(&fscache_n_op_release),
53447 + atomic_read_unchecked(&fscache_n_op_gc));
53448
53449 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53450 atomic_read(&fscache_n_cop_alloc_object),
53451 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53452 index e397b67..b0d8709 100644
53453 --- a/fs/fuse/cuse.c
53454 +++ b/fs/fuse/cuse.c
53455 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53456 INIT_LIST_HEAD(&cuse_conntbl[i]);
53457
53458 /* inherit and extend fuse_dev_operations */
53459 - cuse_channel_fops = fuse_dev_operations;
53460 - cuse_channel_fops.owner = THIS_MODULE;
53461 - cuse_channel_fops.open = cuse_channel_open;
53462 - cuse_channel_fops.release = cuse_channel_release;
53463 + pax_open_kernel();
53464 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53465 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53466 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53467 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53468 + pax_close_kernel();
53469
53470 cuse_class = class_create(THIS_MODULE, "cuse");
53471 if (IS_ERR(cuse_class))
53472 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53473 index e83351a..41e3c9c 100644
53474 --- a/fs/fuse/dev.c
53475 +++ b/fs/fuse/dev.c
53476 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53477 ret = 0;
53478 pipe_lock(pipe);
53479
53480 - if (!pipe->readers) {
53481 + if (!atomic_read(&pipe->readers)) {
53482 send_sig(SIGPIPE, current, 0);
53483 if (!ret)
53484 ret = -EPIPE;
53485 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53486 index 315e1f8..91f890c 100644
53487 --- a/fs/fuse/dir.c
53488 +++ b/fs/fuse/dir.c
53489 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53490 return link;
53491 }
53492
53493 -static void free_link(char *link)
53494 +static void free_link(const char *link)
53495 {
53496 if (!IS_ERR(link))
53497 free_page((unsigned long) link);
53498 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53499 index 2b6f569..fcb4d1f 100644
53500 --- a/fs/gfs2/inode.c
53501 +++ b/fs/gfs2/inode.c
53502 @@ -1499,7 +1499,7 @@ out:
53503
53504 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53505 {
53506 - char *s = nd_get_link(nd);
53507 + const char *s = nd_get_link(nd);
53508 if (!IS_ERR(s))
53509 kfree(s);
53510 }
53511 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53512 index ccee8cc..144b5d7 100644
53513 --- a/fs/hugetlbfs/inode.c
53514 +++ b/fs/hugetlbfs/inode.c
53515 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53516 struct mm_struct *mm = current->mm;
53517 struct vm_area_struct *vma;
53518 struct hstate *h = hstate_file(file);
53519 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53520 struct vm_unmapped_area_info info;
53521
53522 if (len & ~huge_page_mask(h))
53523 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53524 return addr;
53525 }
53526
53527 +#ifdef CONFIG_PAX_RANDMMAP
53528 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53529 +#endif
53530 +
53531 if (addr) {
53532 addr = ALIGN(addr, huge_page_size(h));
53533 vma = find_vma(mm, addr);
53534 - if (TASK_SIZE - len >= addr &&
53535 - (!vma || addr + len <= vma->vm_start))
53536 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53537 return addr;
53538 }
53539
53540 info.flags = 0;
53541 info.length = len;
53542 info.low_limit = TASK_UNMAPPED_BASE;
53543 +
53544 +#ifdef CONFIG_PAX_RANDMMAP
53545 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53546 + info.low_limit += mm->delta_mmap;
53547 +#endif
53548 +
53549 info.high_limit = TASK_SIZE;
53550 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53551 info.align_offset = 0;
53552 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53553 .kill_sb = kill_litter_super,
53554 };
53555
53556 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53557 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53558
53559 static int can_do_hugetlb_shm(void)
53560 {
53561 diff --git a/fs/inode.c b/fs/inode.c
53562 index b98540e..6a439ea 100644
53563 --- a/fs/inode.c
53564 +++ b/fs/inode.c
53565 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53566
53567 #ifdef CONFIG_SMP
53568 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53569 - static atomic_t shared_last_ino;
53570 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53571 + static atomic_unchecked_t shared_last_ino;
53572 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53573
53574 res = next - LAST_INO_BATCH;
53575 }
53576 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53577 index 4a6cf28..d3a29d3 100644
53578 --- a/fs/jffs2/erase.c
53579 +++ b/fs/jffs2/erase.c
53580 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53581 struct jffs2_unknown_node marker = {
53582 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53583 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53584 - .totlen = cpu_to_je32(c->cleanmarker_size)
53585 + .totlen = cpu_to_je32(c->cleanmarker_size),
53586 + .hdr_crc = cpu_to_je32(0)
53587 };
53588
53589 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53590 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53591 index a6597d6..41b30ec 100644
53592 --- a/fs/jffs2/wbuf.c
53593 +++ b/fs/jffs2/wbuf.c
53594 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53595 {
53596 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53597 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53598 - .totlen = constant_cpu_to_je32(8)
53599 + .totlen = constant_cpu_to_je32(8),
53600 + .hdr_crc = constant_cpu_to_je32(0)
53601 };
53602
53603 /*
53604 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53605 index 1a543be..a4e1363 100644
53606 --- a/fs/jfs/super.c
53607 +++ b/fs/jfs/super.c
53608 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53609 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53610 int *flag)
53611 {
53612 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53613 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53614 char *p;
53615 struct jfs_sb_info *sbi = JFS_SBI(sb);
53616
53617 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53618 /* Don't do anything ;-) */
53619 break;
53620 case Opt_iocharset:
53621 - if (nls_map && nls_map != (void *) -1)
53622 + if (nls_map && nls_map != (const void *) -1)
53623 unload_nls(nls_map);
53624 if (!strcmp(args[0].from, "none"))
53625 nls_map = NULL;
53626 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53627
53628 jfs_inode_cachep =
53629 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53630 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53631 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53632 init_once);
53633 if (jfs_inode_cachep == NULL)
53634 return -ENOMEM;
53635 diff --git a/fs/libfs.c b/fs/libfs.c
53636 index 916da8c..1588998 100644
53637 --- a/fs/libfs.c
53638 +++ b/fs/libfs.c
53639 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53640
53641 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53642 struct dentry *next;
53643 + char d_name[sizeof(next->d_iname)];
53644 + const unsigned char *name;
53645 +
53646 next = list_entry(p, struct dentry, d_u.d_child);
53647 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53648 if (!simple_positive(next)) {
53649 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53650
53651 spin_unlock(&next->d_lock);
53652 spin_unlock(&dentry->d_lock);
53653 - if (filldir(dirent, next->d_name.name,
53654 + name = next->d_name.name;
53655 + if (name == next->d_iname) {
53656 + memcpy(d_name, name, next->d_name.len);
53657 + name = d_name;
53658 + }
53659 + if (filldir(dirent, name,
53660 next->d_name.len, filp->f_pos,
53661 next->d_inode->i_ino,
53662 dt_type(next->d_inode)) < 0)
53663 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53664 index 54f9e6c..9ed908c 100644
53665 --- a/fs/lockd/clntproc.c
53666 +++ b/fs/lockd/clntproc.c
53667 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53668 /*
53669 * Cookie counter for NLM requests
53670 */
53671 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53672 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53673
53674 void nlmclnt_next_cookie(struct nlm_cookie *c)
53675 {
53676 - u32 cookie = atomic_inc_return(&nlm_cookie);
53677 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53678
53679 memcpy(c->data, &cookie, 4);
53680 c->len=4;
53681 diff --git a/fs/locks.c b/fs/locks.c
53682 index a94e331..060bce3 100644
53683 --- a/fs/locks.c
53684 +++ b/fs/locks.c
53685 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53686 return;
53687
53688 if (filp->f_op && filp->f_op->flock) {
53689 - struct file_lock fl = {
53690 + struct file_lock flock = {
53691 .fl_pid = current->tgid,
53692 .fl_file = filp,
53693 .fl_flags = FL_FLOCK,
53694 .fl_type = F_UNLCK,
53695 .fl_end = OFFSET_MAX,
53696 };
53697 - filp->f_op->flock(filp, F_SETLKW, &fl);
53698 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53699 - fl.fl_ops->fl_release_private(&fl);
53700 + filp->f_op->flock(filp, F_SETLKW, &flock);
53701 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53702 + flock.fl_ops->fl_release_private(&flock);
53703 }
53704
53705 lock_flocks();
53706 diff --git a/fs/namei.c b/fs/namei.c
53707 index ec97aef..e67718d 100644
53708 --- a/fs/namei.c
53709 +++ b/fs/namei.c
53710 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53711 if (ret != -EACCES)
53712 return ret;
53713
53714 +#ifdef CONFIG_GRKERNSEC
53715 + /* we'll block if we have to log due to a denied capability use */
53716 + if (mask & MAY_NOT_BLOCK)
53717 + return -ECHILD;
53718 +#endif
53719 +
53720 if (S_ISDIR(inode->i_mode)) {
53721 /* DACs are overridable for directories */
53722 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53723 - return 0;
53724 if (!(mask & MAY_WRITE))
53725 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53726 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53727 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53728 return 0;
53729 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53730 + return 0;
53731 return -EACCES;
53732 }
53733 /*
53734 + * Searching includes executable on directories, else just read.
53735 + */
53736 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53737 + if (mask == MAY_READ)
53738 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53739 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53740 + return 0;
53741 +
53742 + /*
53743 * Read/write DACs are always overridable.
53744 * Executable DACs are overridable when there is
53745 * at least one exec bit set.
53746 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53747 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53748 return 0;
53749
53750 - /*
53751 - * Searching includes executable on directories, else just read.
53752 - */
53753 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53754 - if (mask == MAY_READ)
53755 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53756 - return 0;
53757 -
53758 return -EACCES;
53759 }
53760
53761 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53762 {
53763 struct dentry *dentry = link->dentry;
53764 int error;
53765 - char *s;
53766 + const char *s;
53767
53768 BUG_ON(nd->flags & LOOKUP_RCU);
53769
53770 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53771 if (error)
53772 goto out_put_nd_path;
53773
53774 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53775 + dentry->d_inode, dentry, nd->path.mnt)) {
53776 + error = -EACCES;
53777 + goto out_put_nd_path;
53778 + }
53779 +
53780 nd->last_type = LAST_BIND;
53781 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53782 error = PTR_ERR(*p);
53783 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53784 break;
53785 res = walk_component(nd, path, &nd->last,
53786 nd->last_type, LOOKUP_FOLLOW);
53787 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53788 + res = -EACCES;
53789 put_link(nd, &link, cookie);
53790 } while (res > 0);
53791
53792 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53793 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53794 {
53795 unsigned long a, b, adata, bdata, mask, hash, len;
53796 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53797 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53798
53799 hash = a = 0;
53800 len = -sizeof(unsigned long);
53801 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53802 if (err)
53803 break;
53804 err = lookup_last(nd, &path);
53805 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53806 + err = -EACCES;
53807 put_link(nd, &link, cookie);
53808 }
53809 }
53810 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53811 if (!err)
53812 err = complete_walk(nd);
53813
53814 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53815 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53816 + path_put(&nd->path);
53817 + err = -ENOENT;
53818 + }
53819 + }
53820 +
53821 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53822 if (!nd->inode->i_op->lookup) {
53823 path_put(&nd->path);
53824 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53825 retval = path_lookupat(dfd, name->name,
53826 flags | LOOKUP_REVAL, nd);
53827
53828 - if (likely(!retval))
53829 + if (likely(!retval)) {
53830 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53831 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53832 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53833 + path_put(&nd->path);
53834 + return -ENOENT;
53835 + }
53836 + }
53837 + }
53838 return retval;
53839 }
53840
53841 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53842 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53843 return -EPERM;
53844
53845 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53846 + return -EPERM;
53847 + if (gr_handle_rawio(inode))
53848 + return -EPERM;
53849 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53850 + return -EACCES;
53851 +
53852 return 0;
53853 }
53854
53855 @@ -2611,7 +2650,7 @@ looked_up:
53856 * cleared otherwise prior to returning.
53857 */
53858 static int lookup_open(struct nameidata *nd, struct path *path,
53859 - struct file *file,
53860 + struct path *link, struct file *file,
53861 const struct open_flags *op,
53862 bool got_write, int *opened)
53863 {
53864 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53865 /* Negative dentry, just create the file */
53866 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53867 umode_t mode = op->mode;
53868 +
53869 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53870 + error = -EACCES;
53871 + goto out_dput;
53872 + }
53873 +
53874 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53875 + error = -EACCES;
53876 + goto out_dput;
53877 + }
53878 +
53879 if (!IS_POSIXACL(dir->d_inode))
53880 mode &= ~current_umask();
53881 /*
53882 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53883 nd->flags & LOOKUP_EXCL);
53884 if (error)
53885 goto out_dput;
53886 + else
53887 + gr_handle_create(dentry, nd->path.mnt);
53888 }
53889 out_no_open:
53890 path->dentry = dentry;
53891 @@ -2681,7 +2733,7 @@ out_dput:
53892 /*
53893 * Handle the last step of open()
53894 */
53895 -static int do_last(struct nameidata *nd, struct path *path,
53896 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53897 struct file *file, const struct open_flags *op,
53898 int *opened, struct filename *name)
53899 {
53900 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53901 error = complete_walk(nd);
53902 if (error)
53903 return error;
53904 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53905 + error = -ENOENT;
53906 + goto out;
53907 + }
53908 audit_inode(name, nd->path.dentry, 0);
53909 if (open_flag & O_CREAT) {
53910 error = -EISDIR;
53911 goto out;
53912 }
53913 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53914 + error = -EACCES;
53915 + goto out;
53916 + }
53917 goto finish_open;
53918 case LAST_BIND:
53919 error = complete_walk(nd);
53920 if (error)
53921 return error;
53922 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53923 + error = -ENOENT;
53924 + goto out;
53925 + }
53926 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53927 + error = -EACCES;
53928 + goto out;
53929 + }
53930 audit_inode(name, dir, 0);
53931 goto finish_open;
53932 }
53933 @@ -2768,7 +2836,7 @@ retry_lookup:
53934 */
53935 }
53936 mutex_lock(&dir->d_inode->i_mutex);
53937 - error = lookup_open(nd, path, file, op, got_write, opened);
53938 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53939 mutex_unlock(&dir->d_inode->i_mutex);
53940
53941 if (error <= 0) {
53942 @@ -2792,11 +2860,28 @@ retry_lookup:
53943 goto finish_open_created;
53944 }
53945
53946 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53947 + error = -ENOENT;
53948 + goto exit_dput;
53949 + }
53950 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53951 + error = -EACCES;
53952 + goto exit_dput;
53953 + }
53954 +
53955 /*
53956 * create/update audit record if it already exists.
53957 */
53958 - if (path->dentry->d_inode)
53959 + if (path->dentry->d_inode) {
53960 + /* only check if O_CREAT is specified, all other checks need to go
53961 + into may_open */
53962 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53963 + error = -EACCES;
53964 + goto exit_dput;
53965 + }
53966 +
53967 audit_inode(name, path->dentry, 0);
53968 + }
53969
53970 /*
53971 * If atomic_open() acquired write access it is dropped now due to
53972 @@ -2837,6 +2922,11 @@ finish_lookup:
53973 }
53974 }
53975 BUG_ON(inode != path->dentry->d_inode);
53976 + /* if we're resolving a symlink to another symlink */
53977 + if (link && gr_handle_symlink_owner(link, inode)) {
53978 + error = -EACCES;
53979 + goto out;
53980 + }
53981 return 1;
53982 }
53983
53984 @@ -2846,7 +2936,6 @@ finish_lookup:
53985 save_parent.dentry = nd->path.dentry;
53986 save_parent.mnt = mntget(path->mnt);
53987 nd->path.dentry = path->dentry;
53988 -
53989 }
53990 nd->inode = inode;
53991 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53992 @@ -2855,6 +2944,16 @@ finish_lookup:
53993 path_put(&save_parent);
53994 return error;
53995 }
53996 +
53997 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53998 + error = -ENOENT;
53999 + goto out;
54000 + }
54001 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
54002 + error = -EACCES;
54003 + goto out;
54004 + }
54005 +
54006 error = -EISDIR;
54007 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
54008 goto out;
54009 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54010 if (unlikely(error))
54011 goto out;
54012
54013 - error = do_last(nd, &path, file, op, &opened, pathname);
54014 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
54015 while (unlikely(error > 0)) { /* trailing symlink */
54016 struct path link = path;
54017 void *cookie;
54018 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
54019 error = follow_link(&link, nd, &cookie);
54020 if (unlikely(error))
54021 break;
54022 - error = do_last(nd, &path, file, op, &opened, pathname);
54023 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
54024 put_link(nd, &link, cookie);
54025 }
54026 out:
54027 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
54028 goto unlock;
54029
54030 error = -EEXIST;
54031 - if (dentry->d_inode)
54032 + if (dentry->d_inode) {
54033 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
54034 + error = -ENOENT;
54035 + }
54036 goto fail;
54037 + }
54038 /*
54039 * Special case - lookup gave negative, but... we had foo/bar/
54040 * From the vfs_mknod() POV we just have a negative dentry -
54041 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
54042 }
54043 EXPORT_SYMBOL(user_path_create);
54044
54045 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
54046 +{
54047 + struct filename *tmp = getname(pathname);
54048 + struct dentry *res;
54049 + if (IS_ERR(tmp))
54050 + return ERR_CAST(tmp);
54051 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
54052 + if (IS_ERR(res))
54053 + putname(tmp);
54054 + else
54055 + *to = tmp;
54056 + return res;
54057 +}
54058 +
54059 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
54060 {
54061 int error = may_create(dir, dentry);
54062 @@ -3186,6 +3303,17 @@ retry:
54063
54064 if (!IS_POSIXACL(path.dentry->d_inode))
54065 mode &= ~current_umask();
54066 +
54067 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
54068 + error = -EPERM;
54069 + goto out;
54070 + }
54071 +
54072 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54073 + error = -EACCES;
54074 + goto out;
54075 + }
54076 +
54077 error = security_path_mknod(&path, dentry, mode, dev);
54078 if (error)
54079 goto out;
54080 @@ -3202,6 +3330,8 @@ retry:
54081 break;
54082 }
54083 out:
54084 + if (!error)
54085 + gr_handle_create(dentry, path.mnt);
54086 done_path_create(&path, dentry);
54087 if (retry_estale(error, lookup_flags)) {
54088 lookup_flags |= LOOKUP_REVAL;
54089 @@ -3254,9 +3384,16 @@ retry:
54090
54091 if (!IS_POSIXACL(path.dentry->d_inode))
54092 mode &= ~current_umask();
54093 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54094 + error = -EACCES;
54095 + goto out;
54096 + }
54097 error = security_path_mkdir(&path, dentry, mode);
54098 if (!error)
54099 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54100 + if (!error)
54101 + gr_handle_create(dentry, path.mnt);
54102 +out:
54103 done_path_create(&path, dentry);
54104 if (retry_estale(error, lookup_flags)) {
54105 lookup_flags |= LOOKUP_REVAL;
54106 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54107 struct filename *name;
54108 struct dentry *dentry;
54109 struct nameidata nd;
54110 + ino_t saved_ino = 0;
54111 + dev_t saved_dev = 0;
54112 unsigned int lookup_flags = 0;
54113 retry:
54114 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54115 @@ -3369,10 +3508,21 @@ retry:
54116 error = -ENOENT;
54117 goto exit3;
54118 }
54119 +
54120 + saved_ino = dentry->d_inode->i_ino;
54121 + saved_dev = gr_get_dev_from_dentry(dentry);
54122 +
54123 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54124 + error = -EACCES;
54125 + goto exit3;
54126 + }
54127 +
54128 error = security_path_rmdir(&nd.path, dentry);
54129 if (error)
54130 goto exit3;
54131 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54132 + if (!error && (saved_dev || saved_ino))
54133 + gr_handle_delete(saved_ino, saved_dev);
54134 exit3:
54135 dput(dentry);
54136 exit2:
54137 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54138 struct dentry *dentry;
54139 struct nameidata nd;
54140 struct inode *inode = NULL;
54141 + ino_t saved_ino = 0;
54142 + dev_t saved_dev = 0;
54143 unsigned int lookup_flags = 0;
54144 retry:
54145 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54146 @@ -3464,10 +3616,22 @@ retry:
54147 if (!inode)
54148 goto slashes;
54149 ihold(inode);
54150 +
54151 + if (inode->i_nlink <= 1) {
54152 + saved_ino = inode->i_ino;
54153 + saved_dev = gr_get_dev_from_dentry(dentry);
54154 + }
54155 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54156 + error = -EACCES;
54157 + goto exit2;
54158 + }
54159 +
54160 error = security_path_unlink(&nd.path, dentry);
54161 if (error)
54162 goto exit2;
54163 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54164 + if (!error && (saved_ino || saved_dev))
54165 + gr_handle_delete(saved_ino, saved_dev);
54166 exit2:
54167 dput(dentry);
54168 }
54169 @@ -3545,9 +3709,17 @@ retry:
54170 if (IS_ERR(dentry))
54171 goto out_putname;
54172
54173 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54174 + error = -EACCES;
54175 + goto out;
54176 + }
54177 +
54178 error = security_path_symlink(&path, dentry, from->name);
54179 if (!error)
54180 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54181 + if (!error)
54182 + gr_handle_create(dentry, path.mnt);
54183 +out:
54184 done_path_create(&path, dentry);
54185 if (retry_estale(error, lookup_flags)) {
54186 lookup_flags |= LOOKUP_REVAL;
54187 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54188 {
54189 struct dentry *new_dentry;
54190 struct path old_path, new_path;
54191 + struct filename *to = NULL;
54192 int how = 0;
54193 int error;
54194
54195 @@ -3644,7 +3817,7 @@ retry:
54196 if (error)
54197 return error;
54198
54199 - new_dentry = user_path_create(newdfd, newname, &new_path,
54200 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54201 (how & LOOKUP_REVAL));
54202 error = PTR_ERR(new_dentry);
54203 if (IS_ERR(new_dentry))
54204 @@ -3656,11 +3829,28 @@ retry:
54205 error = may_linkat(&old_path);
54206 if (unlikely(error))
54207 goto out_dput;
54208 +
54209 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54210 + old_path.dentry->d_inode,
54211 + old_path.dentry->d_inode->i_mode, to)) {
54212 + error = -EACCES;
54213 + goto out_dput;
54214 + }
54215 +
54216 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54217 + old_path.dentry, old_path.mnt, to)) {
54218 + error = -EACCES;
54219 + goto out_dput;
54220 + }
54221 +
54222 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54223 if (error)
54224 goto out_dput;
54225 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54226 + if (!error)
54227 + gr_handle_create(new_dentry, new_path.mnt);
54228 out_dput:
54229 + putname(to);
54230 done_path_create(&new_path, new_dentry);
54231 if (retry_estale(error, how)) {
54232 how |= LOOKUP_REVAL;
54233 @@ -3906,12 +4096,21 @@ retry:
54234 if (new_dentry == trap)
54235 goto exit5;
54236
54237 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54238 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54239 + to);
54240 + if (error)
54241 + goto exit5;
54242 +
54243 error = security_path_rename(&oldnd.path, old_dentry,
54244 &newnd.path, new_dentry);
54245 if (error)
54246 goto exit5;
54247 error = vfs_rename(old_dir->d_inode, old_dentry,
54248 new_dir->d_inode, new_dentry);
54249 + if (!error)
54250 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54251 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54252 exit5:
54253 dput(new_dentry);
54254 exit4:
54255 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54256
54257 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54258 {
54259 + char tmpbuf[64];
54260 + const char *newlink;
54261 int len;
54262
54263 len = PTR_ERR(link);
54264 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54265 len = strlen(link);
54266 if (len > (unsigned) buflen)
54267 len = buflen;
54268 - if (copy_to_user(buffer, link, len))
54269 +
54270 + if (len < sizeof(tmpbuf)) {
54271 + memcpy(tmpbuf, link, len);
54272 + newlink = tmpbuf;
54273 + } else
54274 + newlink = link;
54275 +
54276 + if (copy_to_user(buffer, newlink, len))
54277 len = -EFAULT;
54278 out:
54279 return len;
54280 diff --git a/fs/namespace.c b/fs/namespace.c
54281 index 5dd7709..6f64e9c 100644
54282 --- a/fs/namespace.c
54283 +++ b/fs/namespace.c
54284 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54285 if (!(sb->s_flags & MS_RDONLY))
54286 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54287 up_write(&sb->s_umount);
54288 +
54289 + gr_log_remount(mnt->mnt_devname, retval);
54290 +
54291 return retval;
54292 }
54293
54294 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54295 br_write_unlock(&vfsmount_lock);
54296 up_write(&namespace_sem);
54297 release_mounts(&umount_list);
54298 +
54299 + gr_log_unmount(mnt->mnt_devname, retval);
54300 +
54301 return retval;
54302 }
54303
54304 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54305
54306 if (IS_ERR(mnt)) {
54307 err = PTR_ERR(mnt);
54308 - goto out;
54309 + goto out2;
54310 }
54311
54312 err = graft_tree(mnt, path);
54313 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54314 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54315 MS_STRICTATIME);
54316
54317 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54318 + retval = -EPERM;
54319 + goto dput_out;
54320 + }
54321 +
54322 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54323 + retval = -EPERM;
54324 + goto dput_out;
54325 + }
54326 +
54327 if (flags & MS_REMOUNT)
54328 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54329 data_page);
54330 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54331 dev_name, data_page);
54332 dput_out:
54333 path_put(&path);
54334 +
54335 + gr_log_mount(dev_name, dir_name, retval);
54336 +
54337 return retval;
54338 }
54339
54340 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54341 if (error)
54342 goto out2;
54343
54344 + if (gr_handle_chroot_pivot()) {
54345 + error = -EPERM;
54346 + goto out2;
54347 + }
54348 +
54349 get_fs_root(current->fs, &root);
54350 error = lock_mount(&old);
54351 if (error)
54352 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54353 !nsown_capable(CAP_SYS_ADMIN))
54354 return -EPERM;
54355
54356 - if (fs->users != 1)
54357 + if (atomic_read(&fs->users) != 1)
54358 return -EINVAL;
54359
54360 get_mnt_ns(mnt_ns);
54361 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54362 index 59461c9..b17c57e 100644
54363 --- a/fs/nfs/callback_xdr.c
54364 +++ b/fs/nfs/callback_xdr.c
54365 @@ -51,7 +51,7 @@ struct callback_op {
54366 callback_decode_arg_t decode_args;
54367 callback_encode_res_t encode_res;
54368 long res_maxsize;
54369 -};
54370 +} __do_const;
54371
54372 static struct callback_op callback_ops[];
54373
54374 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54375 index ebeb94c..ff35337 100644
54376 --- a/fs/nfs/inode.c
54377 +++ b/fs/nfs/inode.c
54378 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54379 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54380 }
54381
54382 -static atomic_long_t nfs_attr_generation_counter;
54383 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54384
54385 static unsigned long nfs_read_attr_generation_counter(void)
54386 {
54387 - return atomic_long_read(&nfs_attr_generation_counter);
54388 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54389 }
54390
54391 unsigned long nfs_inc_attr_generation_counter(void)
54392 {
54393 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54394 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54395 }
54396
54397 void nfs_fattr_init(struct nfs_fattr *fattr)
54398 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54399 index ec668e1..831ae05 100644
54400 --- a/fs/nfsd/nfs4proc.c
54401 +++ b/fs/nfsd/nfs4proc.c
54402 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54403 nfsd4op_rsize op_rsize_bop;
54404 stateid_getter op_get_currentstateid;
54405 stateid_setter op_set_currentstateid;
54406 -};
54407 +} __do_const;
54408
54409 static struct nfsd4_operation nfsd4_ops[];
54410
54411 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54412 index cd5e6c1..4183d56 100644
54413 --- a/fs/nfsd/nfs4xdr.c
54414 +++ b/fs/nfsd/nfs4xdr.c
54415 @@ -1450,7 +1450,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54416
54417 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54418
54419 -static nfsd4_dec nfsd4_dec_ops[] = {
54420 +static const nfsd4_dec nfsd4_dec_ops[] = {
54421 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54422 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54423 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54424 @@ -1490,7 +1490,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54425 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54426 };
54427
54428 -static nfsd4_dec nfsd41_dec_ops[] = {
54429 +static const nfsd4_dec nfsd41_dec_ops[] = {
54430 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54431 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54432 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54433 @@ -1552,7 +1552,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54434 };
54435
54436 struct nfsd4_minorversion_ops {
54437 - nfsd4_dec *decoders;
54438 + const nfsd4_dec *decoders;
54439 int nops;
54440 };
54441
54442 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54443 index 2cbac34..6dc3889 100644
54444 --- a/fs/nfsd/nfscache.c
54445 +++ b/fs/nfsd/nfscache.c
54446 @@ -264,8 +264,10 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54447 if (!(rp = rqstp->rq_cacherep) || cache_disabled)
54448 return;
54449
54450 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54451 - len >>= 2;
54452 + if (statp) {
54453 + len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54454 + len >>= 2;
54455 + }
54456
54457 /* Don't cache excessive amounts of data and XDR failures */
54458 if (!statp || len > (256 >> 2)) {
54459 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54460 index 69c6413..c0408d2 100644
54461 --- a/fs/nfsd/vfs.c
54462 +++ b/fs/nfsd/vfs.c
54463 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54464 } else {
54465 oldfs = get_fs();
54466 set_fs(KERNEL_DS);
54467 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54468 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54469 set_fs(oldfs);
54470 }
54471
54472 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54473
54474 /* Write the data. */
54475 oldfs = get_fs(); set_fs(KERNEL_DS);
54476 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54477 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54478 set_fs(oldfs);
54479 if (host_err < 0)
54480 goto out_nfserr;
54481 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54482 */
54483
54484 oldfs = get_fs(); set_fs(KERNEL_DS);
54485 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54486 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54487 set_fs(oldfs);
54488
54489 if (host_err < 0)
54490 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54491 index fea6bd5..8ee9d81 100644
54492 --- a/fs/nls/nls_base.c
54493 +++ b/fs/nls/nls_base.c
54494 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54495
54496 int register_nls(struct nls_table * nls)
54497 {
54498 - struct nls_table ** tmp = &tables;
54499 + struct nls_table *tmp = tables;
54500
54501 if (nls->next)
54502 return -EBUSY;
54503
54504 spin_lock(&nls_lock);
54505 - while (*tmp) {
54506 - if (nls == *tmp) {
54507 + while (tmp) {
54508 + if (nls == tmp) {
54509 spin_unlock(&nls_lock);
54510 return -EBUSY;
54511 }
54512 - tmp = &(*tmp)->next;
54513 + tmp = tmp->next;
54514 }
54515 - nls->next = tables;
54516 + pax_open_kernel();
54517 + *(struct nls_table **)&nls->next = tables;
54518 + pax_close_kernel();
54519 tables = nls;
54520 spin_unlock(&nls_lock);
54521 return 0;
54522 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54523
54524 int unregister_nls(struct nls_table * nls)
54525 {
54526 - struct nls_table ** tmp = &tables;
54527 + struct nls_table * const * tmp = &tables;
54528
54529 spin_lock(&nls_lock);
54530 while (*tmp) {
54531 if (nls == *tmp) {
54532 - *tmp = nls->next;
54533 + pax_open_kernel();
54534 + *(struct nls_table **)tmp = nls->next;
54535 + pax_close_kernel();
54536 spin_unlock(&nls_lock);
54537 return 0;
54538 }
54539 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54540 index 7424929..35f6be5 100644
54541 --- a/fs/nls/nls_euc-jp.c
54542 +++ b/fs/nls/nls_euc-jp.c
54543 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54544 p_nls = load_nls("cp932");
54545
54546 if (p_nls) {
54547 - table.charset2upper = p_nls->charset2upper;
54548 - table.charset2lower = p_nls->charset2lower;
54549 + pax_open_kernel();
54550 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54551 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54552 + pax_close_kernel();
54553 return register_nls(&table);
54554 }
54555
54556 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54557 index e7bc1d7..06bd4bb 100644
54558 --- a/fs/nls/nls_koi8-ru.c
54559 +++ b/fs/nls/nls_koi8-ru.c
54560 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54561 p_nls = load_nls("koi8-u");
54562
54563 if (p_nls) {
54564 - table.charset2upper = p_nls->charset2upper;
54565 - table.charset2lower = p_nls->charset2lower;
54566 + pax_open_kernel();
54567 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54568 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54569 + pax_close_kernel();
54570 return register_nls(&table);
54571 }
54572
54573 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54574 index 9ff4a5e..deb1f0f 100644
54575 --- a/fs/notify/fanotify/fanotify_user.c
54576 +++ b/fs/notify/fanotify/fanotify_user.c
54577 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54578
54579 fd = fanotify_event_metadata.fd;
54580 ret = -EFAULT;
54581 - if (copy_to_user(buf, &fanotify_event_metadata,
54582 - fanotify_event_metadata.event_len))
54583 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54584 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54585 goto out_close_fd;
54586
54587 ret = prepare_for_access_response(group, event, fd);
54588 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54589 index 7b51b05..5ea5ef6 100644
54590 --- a/fs/notify/notification.c
54591 +++ b/fs/notify/notification.c
54592 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54593 * get set to 0 so it will never get 'freed'
54594 */
54595 static struct fsnotify_event *q_overflow_event;
54596 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54597 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54598
54599 /**
54600 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54601 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54602 */
54603 u32 fsnotify_get_cookie(void)
54604 {
54605 - return atomic_inc_return(&fsnotify_sync_cookie);
54606 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54607 }
54608 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54609
54610 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54611 index 99e3610..02c1068 100644
54612 --- a/fs/ntfs/dir.c
54613 +++ b/fs/ntfs/dir.c
54614 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54615 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54616 ~(s64)(ndir->itype.index.block_size - 1)));
54617 /* Bounds checks. */
54618 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54619 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54620 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54621 "inode 0x%lx or driver bug.", vdir->i_ino);
54622 goto err_out;
54623 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54624 index 5b2d4f0..c6de396 100644
54625 --- a/fs/ntfs/file.c
54626 +++ b/fs/ntfs/file.c
54627 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54628 #endif /* NTFS_RW */
54629 };
54630
54631 -const struct file_operations ntfs_empty_file_ops = {};
54632 +const struct file_operations ntfs_empty_file_ops __read_only;
54633
54634 -const struct inode_operations ntfs_empty_inode_ops = {};
54635 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54636 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54637 index a9f78c7..ed8a381 100644
54638 --- a/fs/ocfs2/localalloc.c
54639 +++ b/fs/ocfs2/localalloc.c
54640 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54641 goto bail;
54642 }
54643
54644 - atomic_inc(&osb->alloc_stats.moves);
54645 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54646
54647 bail:
54648 if (handle)
54649 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54650 index d355e6e..578d905 100644
54651 --- a/fs/ocfs2/ocfs2.h
54652 +++ b/fs/ocfs2/ocfs2.h
54653 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54654
54655 struct ocfs2_alloc_stats
54656 {
54657 - atomic_t moves;
54658 - atomic_t local_data;
54659 - atomic_t bitmap_data;
54660 - atomic_t bg_allocs;
54661 - atomic_t bg_extends;
54662 + atomic_unchecked_t moves;
54663 + atomic_unchecked_t local_data;
54664 + atomic_unchecked_t bitmap_data;
54665 + atomic_unchecked_t bg_allocs;
54666 + atomic_unchecked_t bg_extends;
54667 };
54668
54669 enum ocfs2_local_alloc_state
54670 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54671 index b7e74b5..19c6536 100644
54672 --- a/fs/ocfs2/suballoc.c
54673 +++ b/fs/ocfs2/suballoc.c
54674 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54675 mlog_errno(status);
54676 goto bail;
54677 }
54678 - atomic_inc(&osb->alloc_stats.bg_extends);
54679 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54680
54681 /* You should never ask for this much metadata */
54682 BUG_ON(bits_wanted >
54683 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54684 mlog_errno(status);
54685 goto bail;
54686 }
54687 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54688 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54689
54690 *suballoc_loc = res.sr_bg_blkno;
54691 *suballoc_bit_start = res.sr_bit_offset;
54692 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54693 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54694 res->sr_bits);
54695
54696 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54697 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54698
54699 BUG_ON(res->sr_bits != 1);
54700
54701 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54702 mlog_errno(status);
54703 goto bail;
54704 }
54705 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54706 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54707
54708 BUG_ON(res.sr_bits != 1);
54709
54710 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54711 cluster_start,
54712 num_clusters);
54713 if (!status)
54714 - atomic_inc(&osb->alloc_stats.local_data);
54715 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54716 } else {
54717 if (min_clusters > (osb->bitmap_cpg - 1)) {
54718 /* The only paths asking for contiguousness
54719 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54720 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54721 res.sr_bg_blkno,
54722 res.sr_bit_offset);
54723 - atomic_inc(&osb->alloc_stats.bitmap_data);
54724 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54725 *num_clusters = res.sr_bits;
54726 }
54727 }
54728 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54729 index 0e91ec2..f4b3fc6 100644
54730 --- a/fs/ocfs2/super.c
54731 +++ b/fs/ocfs2/super.c
54732 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54733 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54734 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54735 "Stats",
54736 - atomic_read(&osb->alloc_stats.bitmap_data),
54737 - atomic_read(&osb->alloc_stats.local_data),
54738 - atomic_read(&osb->alloc_stats.bg_allocs),
54739 - atomic_read(&osb->alloc_stats.moves),
54740 - atomic_read(&osb->alloc_stats.bg_extends));
54741 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54742 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54743 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54744 + atomic_read_unchecked(&osb->alloc_stats.moves),
54745 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54746
54747 out += snprintf(buf + out, len - out,
54748 "%10s => State: %u Descriptor: %llu Size: %u bits "
54749 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54750 spin_lock_init(&osb->osb_xattr_lock);
54751 ocfs2_init_steal_slots(osb);
54752
54753 - atomic_set(&osb->alloc_stats.moves, 0);
54754 - atomic_set(&osb->alloc_stats.local_data, 0);
54755 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54756 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54757 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54758 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54759 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54760 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54761 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54762 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54763
54764 /* Copy the blockcheck stats from the superblock probe */
54765 osb->osb_ecc_stats = *stats;
54766 diff --git a/fs/open.c b/fs/open.c
54767 index 9b33c0c..2ffcca2 100644
54768 --- a/fs/open.c
54769 +++ b/fs/open.c
54770 @@ -31,6 +31,8 @@
54771 #include <linux/ima.h>
54772 #include <linux/dnotify.h>
54773
54774 +#define CREATE_TRACE_POINTS
54775 +#include <trace/events/fs.h>
54776 #include "internal.h"
54777
54778 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54779 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54780 error = locks_verify_truncate(inode, NULL, length);
54781 if (!error)
54782 error = security_path_truncate(path);
54783 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54784 + error = -EACCES;
54785 if (!error)
54786 error = do_truncate(path->dentry, length, 0, NULL);
54787
54788 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54789 error = locks_verify_truncate(inode, f.file, length);
54790 if (!error)
54791 error = security_path_truncate(&f.file->f_path);
54792 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54793 + error = -EACCES;
54794 if (!error)
54795 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54796 sb_end_write(inode->i_sb);
54797 @@ -373,6 +379,9 @@ retry:
54798 if (__mnt_is_readonly(path.mnt))
54799 res = -EROFS;
54800
54801 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54802 + res = -EACCES;
54803 +
54804 out_path_release:
54805 path_put(&path);
54806 if (retry_estale(res, lookup_flags)) {
54807 @@ -404,6 +413,8 @@ retry:
54808 if (error)
54809 goto dput_and_out;
54810
54811 + gr_log_chdir(path.dentry, path.mnt);
54812 +
54813 set_fs_pwd(current->fs, &path);
54814
54815 dput_and_out:
54816 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54817 goto out_putf;
54818
54819 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54820 +
54821 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54822 + error = -EPERM;
54823 +
54824 + if (!error)
54825 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54826 +
54827 if (!error)
54828 set_fs_pwd(current->fs, &f.file->f_path);
54829 out_putf:
54830 @@ -462,7 +480,13 @@ retry:
54831 if (error)
54832 goto dput_and_out;
54833
54834 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54835 + goto dput_and_out;
54836 +
54837 set_fs_root(current->fs, &path);
54838 +
54839 + gr_handle_chroot_chdir(&path);
54840 +
54841 error = 0;
54842 dput_and_out:
54843 path_put(&path);
54844 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54845 if (error)
54846 return error;
54847 mutex_lock(&inode->i_mutex);
54848 +
54849 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54850 + error = -EACCES;
54851 + goto out_unlock;
54852 + }
54853 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54854 + error = -EACCES;
54855 + goto out_unlock;
54856 + }
54857 +
54858 error = security_path_chmod(path, mode);
54859 if (error)
54860 goto out_unlock;
54861 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54862 uid = make_kuid(current_user_ns(), user);
54863 gid = make_kgid(current_user_ns(), group);
54864
54865 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54866 + return -EACCES;
54867 +
54868 newattrs.ia_valid = ATTR_CTIME;
54869 if (user != (uid_t) -1) {
54870 if (!uid_valid(uid))
54871 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54872 } else {
54873 fsnotify_open(f);
54874 fd_install(fd, f);
54875 + trace_do_sys_open(tmp->name, flags, mode);
54876 }
54877 }
54878 putname(tmp);
54879 diff --git a/fs/pipe.c b/fs/pipe.c
54880 index 8e2e73f..1ef1048 100644
54881 --- a/fs/pipe.c
54882 +++ b/fs/pipe.c
54883 @@ -438,9 +438,9 @@ redo:
54884 }
54885 if (bufs) /* More to do? */
54886 continue;
54887 - if (!pipe->writers)
54888 + if (!atomic_read(&pipe->writers))
54889 break;
54890 - if (!pipe->waiting_writers) {
54891 + if (!atomic_read(&pipe->waiting_writers)) {
54892 /* syscall merging: Usually we must not sleep
54893 * if O_NONBLOCK is set, or if we got some data.
54894 * But if a writer sleeps in kernel space, then
54895 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54896 mutex_lock(&inode->i_mutex);
54897 pipe = inode->i_pipe;
54898
54899 - if (!pipe->readers) {
54900 + if (!atomic_read(&pipe->readers)) {
54901 send_sig(SIGPIPE, current, 0);
54902 ret = -EPIPE;
54903 goto out;
54904 @@ -553,7 +553,7 @@ redo1:
54905 for (;;) {
54906 int bufs;
54907
54908 - if (!pipe->readers) {
54909 + if (!atomic_read(&pipe->readers)) {
54910 send_sig(SIGPIPE, current, 0);
54911 if (!ret)
54912 ret = -EPIPE;
54913 @@ -644,9 +644,9 @@ redo2:
54914 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54915 do_wakeup = 0;
54916 }
54917 - pipe->waiting_writers++;
54918 + atomic_inc(&pipe->waiting_writers);
54919 pipe_wait(pipe);
54920 - pipe->waiting_writers--;
54921 + atomic_dec(&pipe->waiting_writers);
54922 }
54923 out:
54924 mutex_unlock(&inode->i_mutex);
54925 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54926 mask = 0;
54927 if (filp->f_mode & FMODE_READ) {
54928 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54929 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54930 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54931 mask |= POLLHUP;
54932 }
54933
54934 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54935 * Most Unices do not set POLLERR for FIFOs but on Linux they
54936 * behave exactly like pipes for poll().
54937 */
54938 - if (!pipe->readers)
54939 + if (!atomic_read(&pipe->readers))
54940 mask |= POLLERR;
54941 }
54942
54943 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54944
54945 mutex_lock(&inode->i_mutex);
54946 pipe = inode->i_pipe;
54947 - pipe->readers -= decr;
54948 - pipe->writers -= decw;
54949 + atomic_sub(decr, &pipe->readers);
54950 + atomic_sub(decw, &pipe->writers);
54951
54952 - if (!pipe->readers && !pipe->writers) {
54953 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54954 free_pipe_info(inode);
54955 } else {
54956 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54957 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54958
54959 if (inode->i_pipe) {
54960 ret = 0;
54961 - inode->i_pipe->readers++;
54962 + atomic_inc(&inode->i_pipe->readers);
54963 }
54964
54965 mutex_unlock(&inode->i_mutex);
54966 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54967
54968 if (inode->i_pipe) {
54969 ret = 0;
54970 - inode->i_pipe->writers++;
54971 + atomic_inc(&inode->i_pipe->writers);
54972 }
54973
54974 mutex_unlock(&inode->i_mutex);
54975 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54976 if (inode->i_pipe) {
54977 ret = 0;
54978 if (filp->f_mode & FMODE_READ)
54979 - inode->i_pipe->readers++;
54980 + atomic_inc(&inode->i_pipe->readers);
54981 if (filp->f_mode & FMODE_WRITE)
54982 - inode->i_pipe->writers++;
54983 + atomic_inc(&inode->i_pipe->writers);
54984 }
54985
54986 mutex_unlock(&inode->i_mutex);
54987 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54988 inode->i_pipe = NULL;
54989 }
54990
54991 -static struct vfsmount *pipe_mnt __read_mostly;
54992 +struct vfsmount *pipe_mnt __read_mostly;
54993
54994 /*
54995 * pipefs_dname() is called from d_path().
54996 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54997 goto fail_iput;
54998 inode->i_pipe = pipe;
54999
55000 - pipe->readers = pipe->writers = 1;
55001 + atomic_set(&pipe->readers, 1);
55002 + atomic_set(&pipe->writers, 1);
55003 inode->i_fop = &rdwr_pipefifo_fops;
55004
55005 /*
55006 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
55007 index 15af622..0e9f4467 100644
55008 --- a/fs/proc/Kconfig
55009 +++ b/fs/proc/Kconfig
55010 @@ -30,12 +30,12 @@ config PROC_FS
55011
55012 config PROC_KCORE
55013 bool "/proc/kcore support" if !ARM
55014 - depends on PROC_FS && MMU
55015 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
55016
55017 config PROC_VMCORE
55018 bool "/proc/vmcore support"
55019 - depends on PROC_FS && CRASH_DUMP
55020 - default y
55021 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
55022 + default n
55023 help
55024 Exports the dump image of crashed kernel in ELF format.
55025
55026 @@ -59,8 +59,8 @@ config PROC_SYSCTL
55027 limited in memory.
55028
55029 config PROC_PAGE_MONITOR
55030 - default y
55031 - depends on PROC_FS && MMU
55032 + default n
55033 + depends on PROC_FS && MMU && !GRKERNSEC
55034 bool "Enable /proc page monitoring" if EXPERT
55035 help
55036 Various /proc files exist to monitor process memory utilization:
55037 diff --git a/fs/proc/array.c b/fs/proc/array.c
55038 index be3c22f..0df1564 100644
55039 --- a/fs/proc/array.c
55040 +++ b/fs/proc/array.c
55041 @@ -60,6 +60,7 @@
55042 #include <linux/tty.h>
55043 #include <linux/string.h>
55044 #include <linux/mman.h>
55045 +#include <linux/grsecurity.h>
55046 #include <linux/proc_fs.h>
55047 #include <linux/ioport.h>
55048 #include <linux/uaccess.h>
55049 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
55050 seq_putc(m, '\n');
55051 }
55052
55053 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55054 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
55055 +{
55056 + if (p->mm)
55057 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
55058 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
55059 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
55060 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
55061 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
55062 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
55063 + else
55064 + seq_printf(m, "PaX:\t-----\n");
55065 +}
55066 +#endif
55067 +
55068 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55069 struct pid *pid, struct task_struct *task)
55070 {
55071 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55072 task_cpus_allowed(m, task);
55073 cpuset_task_status_allowed(m, task);
55074 task_context_switch_counts(m, task);
55075 +
55076 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
55077 + task_pax(m, task);
55078 +#endif
55079 +
55080 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
55081 + task_grsec_rbac(m, task);
55082 +#endif
55083 +
55084 return 0;
55085 }
55086
55087 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55088 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55089 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55090 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55091 +#endif
55092 +
55093 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55094 struct pid *pid, struct task_struct *task, int whole)
55095 {
55096 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55097 char tcomm[sizeof(task->comm)];
55098 unsigned long flags;
55099
55100 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55101 + if (current->exec_id != m->exec_id) {
55102 + gr_log_badprocpid("stat");
55103 + return 0;
55104 + }
55105 +#endif
55106 +
55107 state = *get_task_state(task);
55108 vsize = eip = esp = 0;
55109 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55110 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55111 gtime = task->gtime;
55112 }
55113
55114 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55115 + if (PAX_RAND_FLAGS(mm)) {
55116 + eip = 0;
55117 + esp = 0;
55118 + wchan = 0;
55119 + }
55120 +#endif
55121 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55122 + wchan = 0;
55123 + eip =0;
55124 + esp =0;
55125 +#endif
55126 +
55127 /* scale priority and nice values from timeslices to -20..20 */
55128 /* to make it look like a "normal" Unix priority/nice value */
55129 priority = task_prio(task);
55130 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55131 seq_put_decimal_ull(m, ' ', vsize);
55132 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55133 seq_put_decimal_ull(m, ' ', rsslim);
55134 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55135 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55136 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55137 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55138 +#else
55139 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55140 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55141 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55142 +#endif
55143 seq_put_decimal_ull(m, ' ', esp);
55144 seq_put_decimal_ull(m, ' ', eip);
55145 /* The signal information here is obsolete.
55146 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55147 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55148 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55149
55150 - if (mm && permitted) {
55151 + if (mm && permitted
55152 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55153 + && !PAX_RAND_FLAGS(mm)
55154 +#endif
55155 + ) {
55156 seq_put_decimal_ull(m, ' ', mm->start_data);
55157 seq_put_decimal_ull(m, ' ', mm->end_data);
55158 seq_put_decimal_ull(m, ' ', mm->start_brk);
55159 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55160 struct pid *pid, struct task_struct *task)
55161 {
55162 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55163 - struct mm_struct *mm = get_task_mm(task);
55164 + struct mm_struct *mm;
55165
55166 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55167 + if (current->exec_id != m->exec_id) {
55168 + gr_log_badprocpid("statm");
55169 + return 0;
55170 + }
55171 +#endif
55172 + mm = get_task_mm(task);
55173 if (mm) {
55174 size = task_statm(mm, &shared, &text, &data, &resident);
55175 mmput(mm);
55176 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55177 return 0;
55178 }
55179
55180 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55181 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55182 +{
55183 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55184 +}
55185 +#endif
55186 +
55187 #ifdef CONFIG_CHECKPOINT_RESTORE
55188 static struct pid *
55189 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55190 diff --git a/fs/proc/base.c b/fs/proc/base.c
55191 index 9b43ff77..0fa9564 100644
55192 --- a/fs/proc/base.c
55193 +++ b/fs/proc/base.c
55194 @@ -111,6 +111,14 @@ struct pid_entry {
55195 union proc_op op;
55196 };
55197
55198 +struct getdents_callback {
55199 + struct linux_dirent __user * current_dir;
55200 + struct linux_dirent __user * previous;
55201 + struct file * file;
55202 + int count;
55203 + int error;
55204 +};
55205 +
55206 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55207 .name = (NAME), \
55208 .len = sizeof(NAME) - 1, \
55209 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55210 if (!mm->arg_end)
55211 goto out_mm; /* Shh! No looking before we're done */
55212
55213 + if (gr_acl_handle_procpidmem(task))
55214 + goto out_mm;
55215 +
55216 len = mm->arg_end - mm->arg_start;
55217
55218 if (len > PAGE_SIZE)
55219 @@ -235,12 +246,28 @@ out:
55220 return res;
55221 }
55222
55223 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55224 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55225 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55226 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55227 +#endif
55228 +
55229 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55230 {
55231 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55232 int res = PTR_ERR(mm);
55233 if (mm && !IS_ERR(mm)) {
55234 unsigned int nwords = 0;
55235 +
55236 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55237 + /* allow if we're currently ptracing this task */
55238 + if (PAX_RAND_FLAGS(mm) &&
55239 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55240 + mmput(mm);
55241 + return 0;
55242 + }
55243 +#endif
55244 +
55245 do {
55246 nwords += 2;
55247 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55248 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55249 }
55250
55251
55252 -#ifdef CONFIG_KALLSYMS
55253 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55254 /*
55255 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55256 * Returns the resolved symbol. If that fails, simply return the address.
55257 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55258 mutex_unlock(&task->signal->cred_guard_mutex);
55259 }
55260
55261 -#ifdef CONFIG_STACKTRACE
55262 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55263
55264 #define MAX_STACK_TRACE_DEPTH 64
55265
55266 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55267 return count;
55268 }
55269
55270 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55271 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55272 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55273 {
55274 long nr;
55275 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55276 /************************************************************************/
55277
55278 /* permission checks */
55279 -static int proc_fd_access_allowed(struct inode *inode)
55280 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55281 {
55282 struct task_struct *task;
55283 int allowed = 0;
55284 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55285 */
55286 task = get_proc_task(inode);
55287 if (task) {
55288 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55289 + if (log)
55290 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55291 + else
55292 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55293 put_task_struct(task);
55294 }
55295 return allowed;
55296 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55297 struct task_struct *task,
55298 int hide_pid_min)
55299 {
55300 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55301 + return false;
55302 +
55303 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55304 + rcu_read_lock();
55305 + {
55306 + const struct cred *tmpcred = current_cred();
55307 + const struct cred *cred = __task_cred(task);
55308 +
55309 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55310 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55311 + || in_group_p(grsec_proc_gid)
55312 +#endif
55313 + ) {
55314 + rcu_read_unlock();
55315 + return true;
55316 + }
55317 + }
55318 + rcu_read_unlock();
55319 +
55320 + if (!pid->hide_pid)
55321 + return false;
55322 +#endif
55323 +
55324 if (pid->hide_pid < hide_pid_min)
55325 return true;
55326 if (in_group_p(pid->pid_gid))
55327 return true;
55328 +
55329 return ptrace_may_access(task, PTRACE_MODE_READ);
55330 }
55331
55332 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55333 put_task_struct(task);
55334
55335 if (!has_perms) {
55336 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55337 + {
55338 +#else
55339 if (pid->hide_pid == 2) {
55340 +#endif
55341 /*
55342 * Let's make getdents(), stat(), and open()
55343 * consistent with each other. If a process
55344 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55345 if (!task)
55346 return -ESRCH;
55347
55348 + if (gr_acl_handle_procpidmem(task)) {
55349 + put_task_struct(task);
55350 + return -EPERM;
55351 + }
55352 +
55353 mm = mm_access(task, mode);
55354 put_task_struct(task);
55355
55356 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55357
55358 file->private_data = mm;
55359
55360 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55361 + file->f_version = current->exec_id;
55362 +#endif
55363 +
55364 return 0;
55365 }
55366
55367 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55368 ssize_t copied;
55369 char *page;
55370
55371 +#ifdef CONFIG_GRKERNSEC
55372 + if (write)
55373 + return -EPERM;
55374 +#endif
55375 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55376 + if (file->f_version != current->exec_id) {
55377 + gr_log_badprocpid("mem");
55378 + return 0;
55379 + }
55380 +#endif
55381 +
55382 if (!mm)
55383 return 0;
55384
55385 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55386 goto free;
55387
55388 while (count > 0) {
55389 - int this_len = min_t(int, count, PAGE_SIZE);
55390 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55391
55392 if (write && copy_from_user(page, buf, this_len)) {
55393 copied = -EFAULT;
55394 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55395 if (!mm)
55396 return 0;
55397
55398 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55399 + if (file->f_version != current->exec_id) {
55400 + gr_log_badprocpid("environ");
55401 + return 0;
55402 + }
55403 +#endif
55404 +
55405 page = (char *)__get_free_page(GFP_TEMPORARY);
55406 if (!page)
55407 return -ENOMEM;
55408 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55409 goto free;
55410 while (count > 0) {
55411 size_t this_len, max_len;
55412 - int retval;
55413 + ssize_t retval;
55414
55415 if (src >= (mm->env_end - mm->env_start))
55416 break;
55417 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55418 int error = -EACCES;
55419
55420 /* Are we allowed to snoop on the tasks file descriptors? */
55421 - if (!proc_fd_access_allowed(inode))
55422 + if (!proc_fd_access_allowed(inode, 0))
55423 goto out;
55424
55425 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55426 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55427 struct path path;
55428
55429 /* Are we allowed to snoop on the tasks file descriptors? */
55430 - if (!proc_fd_access_allowed(inode))
55431 - goto out;
55432 + /* logging this is needed for learning on chromium to work properly,
55433 + but we don't want to flood the logs from 'ps' which does a readlink
55434 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55435 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55436 + */
55437 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55438 + if (!proc_fd_access_allowed(inode,0))
55439 + goto out;
55440 + } else {
55441 + if (!proc_fd_access_allowed(inode,1))
55442 + goto out;
55443 + }
55444
55445 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55446 if (error)
55447 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55448 rcu_read_lock();
55449 cred = __task_cred(task);
55450 inode->i_uid = cred->euid;
55451 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55452 + inode->i_gid = grsec_proc_gid;
55453 +#else
55454 inode->i_gid = cred->egid;
55455 +#endif
55456 rcu_read_unlock();
55457 }
55458 security_task_to_inode(task, inode);
55459 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55460 return -ENOENT;
55461 }
55462 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55463 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55464 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55465 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55466 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55467 +#endif
55468 task_dumpable(task)) {
55469 cred = __task_cred(task);
55470 stat->uid = cred->euid;
55471 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55472 + stat->gid = grsec_proc_gid;
55473 +#else
55474 stat->gid = cred->egid;
55475 +#endif
55476 }
55477 }
55478 rcu_read_unlock();
55479 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55480
55481 if (task) {
55482 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55483 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55484 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55485 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55486 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55487 +#endif
55488 task_dumpable(task)) {
55489 rcu_read_lock();
55490 cred = __task_cred(task);
55491 inode->i_uid = cred->euid;
55492 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55493 + inode->i_gid = grsec_proc_gid;
55494 +#else
55495 inode->i_gid = cred->egid;
55496 +#endif
55497 rcu_read_unlock();
55498 } else {
55499 inode->i_uid = GLOBAL_ROOT_UID;
55500 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55501 if (!task)
55502 goto out_no_task;
55503
55504 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55505 + goto out;
55506 +
55507 /*
55508 * Yes, it does not scale. And it should not. Don't add
55509 * new entries into /proc/<tgid>/ without very good reasons.
55510 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55511 if (!task)
55512 goto out_no_task;
55513
55514 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55515 + goto out;
55516 +
55517 ret = 0;
55518 i = filp->f_pos;
55519 switch (i) {
55520 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55521 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55522 #endif
55523 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55524 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55525 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55526 INF("syscall", S_IRUGO, proc_pid_syscall),
55527 #endif
55528 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55529 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55530 #ifdef CONFIG_SECURITY
55531 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55532 #endif
55533 -#ifdef CONFIG_KALLSYMS
55534 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55535 INF("wchan", S_IRUGO, proc_pid_wchan),
55536 #endif
55537 -#ifdef CONFIG_STACKTRACE
55538 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55539 ONE("stack", S_IRUGO, proc_pid_stack),
55540 #endif
55541 #ifdef CONFIG_SCHEDSTATS
55542 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55543 #ifdef CONFIG_HARDWALL
55544 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55545 #endif
55546 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55547 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55548 +#endif
55549 #ifdef CONFIG_USER_NS
55550 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55551 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55552 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55553 if (!inode)
55554 goto out;
55555
55556 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55557 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55558 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55559 + inode->i_gid = grsec_proc_gid;
55560 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55561 +#else
55562 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55563 +#endif
55564 inode->i_op = &proc_tgid_base_inode_operations;
55565 inode->i_fop = &proc_tgid_base_operations;
55566 inode->i_flags|=S_IMMUTABLE;
55567 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55568 if (!task)
55569 goto out;
55570
55571 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55572 + goto out_put_task;
55573 +
55574 result = proc_pid_instantiate(dir, dentry, task, NULL);
55575 +out_put_task:
55576 put_task_struct(task);
55577 out:
55578 return result;
55579 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55580 static int fake_filldir(void *buf, const char *name, int namelen,
55581 loff_t offset, u64 ino, unsigned d_type)
55582 {
55583 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55584 + __buf->error = -EINVAL;
55585 return 0;
55586 }
55587
55588 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55589 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55590 #endif
55591 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55592 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55593 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55594 INF("syscall", S_IRUGO, proc_pid_syscall),
55595 #endif
55596 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55597 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55598 #ifdef CONFIG_SECURITY
55599 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55600 #endif
55601 -#ifdef CONFIG_KALLSYMS
55602 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55603 INF("wchan", S_IRUGO, proc_pid_wchan),
55604 #endif
55605 -#ifdef CONFIG_STACKTRACE
55606 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55607 ONE("stack", S_IRUGO, proc_pid_stack),
55608 #endif
55609 #ifdef CONFIG_SCHEDSTATS
55610 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55611 index 82676e3..5f8518a 100644
55612 --- a/fs/proc/cmdline.c
55613 +++ b/fs/proc/cmdline.c
55614 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55615
55616 static int __init proc_cmdline_init(void)
55617 {
55618 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55619 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55620 +#else
55621 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55622 +#endif
55623 return 0;
55624 }
55625 module_init(proc_cmdline_init);
55626 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55627 index b143471..bb105e5 100644
55628 --- a/fs/proc/devices.c
55629 +++ b/fs/proc/devices.c
55630 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55631
55632 static int __init proc_devices_init(void)
55633 {
55634 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55635 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55636 +#else
55637 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55638 +#endif
55639 return 0;
55640 }
55641 module_init(proc_devices_init);
55642 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55643 index d7a4a28..0201742 100644
55644 --- a/fs/proc/fd.c
55645 +++ b/fs/proc/fd.c
55646 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55647 if (!task)
55648 return -ENOENT;
55649
55650 - files = get_files_struct(task);
55651 + if (!gr_acl_handle_procpidmem(task))
55652 + files = get_files_struct(task);
55653 put_task_struct(task);
55654
55655 if (files) {
55656 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55657 */
55658 int proc_fd_permission(struct inode *inode, int mask)
55659 {
55660 + struct task_struct *task;
55661 int rv = generic_permission(inode, mask);
55662 - if (rv == 0)
55663 - return 0;
55664 +
55665 if (task_pid(current) == proc_pid(inode))
55666 rv = 0;
55667 +
55668 + task = get_proc_task(inode);
55669 + if (task == NULL)
55670 + return rv;
55671 +
55672 + if (gr_acl_handle_procpidmem(task))
55673 + rv = -EACCES;
55674 +
55675 + put_task_struct(task);
55676 +
55677 return rv;
55678 }
55679
55680 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55681 index 0ac1e1b..0497e58 100644
55682 --- a/fs/proc/inode.c
55683 +++ b/fs/proc/inode.c
55684 @@ -21,11 +21,17 @@
55685 #include <linux/seq_file.h>
55686 #include <linux/slab.h>
55687 #include <linux/mount.h>
55688 +#include <linux/grsecurity.h>
55689
55690 #include <asm/uaccess.h>
55691
55692 #include "internal.h"
55693
55694 +#ifdef CONFIG_PROC_SYSCTL
55695 +extern const struct inode_operations proc_sys_inode_operations;
55696 +extern const struct inode_operations proc_sys_dir_operations;
55697 +#endif
55698 +
55699 static void proc_evict_inode(struct inode *inode)
55700 {
55701 struct proc_dir_entry *de;
55702 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55703 ns = PROC_I(inode)->ns;
55704 if (ns_ops && ns)
55705 ns_ops->put(ns);
55706 +
55707 +#ifdef CONFIG_PROC_SYSCTL
55708 + if (inode->i_op == &proc_sys_inode_operations ||
55709 + inode->i_op == &proc_sys_dir_operations)
55710 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55711 +#endif
55712 +
55713 }
55714
55715 static struct kmem_cache * proc_inode_cachep;
55716 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55717 if (de->mode) {
55718 inode->i_mode = de->mode;
55719 inode->i_uid = de->uid;
55720 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55721 + inode->i_gid = grsec_proc_gid;
55722 +#else
55723 inode->i_gid = de->gid;
55724 +#endif
55725 }
55726 if (de->size)
55727 inode->i_size = de->size;
55728 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55729 index 252544c..04395b9 100644
55730 --- a/fs/proc/internal.h
55731 +++ b/fs/proc/internal.h
55732 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55733 struct pid *pid, struct task_struct *task);
55734 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55735 struct pid *pid, struct task_struct *task);
55736 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55737 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55738 +#endif
55739 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55740
55741 extern const struct file_operations proc_tid_children_operations;
55742 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55743 index e96d4f1..8b116ed 100644
55744 --- a/fs/proc/kcore.c
55745 +++ b/fs/proc/kcore.c
55746 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55747 * the addresses in the elf_phdr on our list.
55748 */
55749 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55750 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55751 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55752 + if (tsz > buflen)
55753 tsz = buflen;
55754 -
55755 +
55756 while (buflen) {
55757 struct kcore_list *m;
55758
55759 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55760 kfree(elf_buf);
55761 } else {
55762 if (kern_addr_valid(start)) {
55763 - unsigned long n;
55764 + char *elf_buf;
55765 + mm_segment_t oldfs;
55766
55767 - n = copy_to_user(buffer, (char *)start, tsz);
55768 - /*
55769 - * We cannot distinguish between fault on source
55770 - * and fault on destination. When this happens
55771 - * we clear too and hope it will trigger the
55772 - * EFAULT again.
55773 - */
55774 - if (n) {
55775 - if (clear_user(buffer + tsz - n,
55776 - n))
55777 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55778 + if (!elf_buf)
55779 + return -ENOMEM;
55780 + oldfs = get_fs();
55781 + set_fs(KERNEL_DS);
55782 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55783 + set_fs(oldfs);
55784 + if (copy_to_user(buffer, elf_buf, tsz)) {
55785 + kfree(elf_buf);
55786 return -EFAULT;
55787 + }
55788 }
55789 + set_fs(oldfs);
55790 + kfree(elf_buf);
55791 } else {
55792 if (clear_user(buffer, tsz))
55793 return -EFAULT;
55794 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55795
55796 static int open_kcore(struct inode *inode, struct file *filp)
55797 {
55798 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55799 + return -EPERM;
55800 +#endif
55801 if (!capable(CAP_SYS_RAWIO))
55802 return -EPERM;
55803 if (kcore_need_update)
55804 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55805 index 80e4645..53e5fcf 100644
55806 --- a/fs/proc/meminfo.c
55807 +++ b/fs/proc/meminfo.c
55808 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55809 vmi.used >> 10,
55810 vmi.largest_chunk >> 10
55811 #ifdef CONFIG_MEMORY_FAILURE
55812 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55813 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55814 #endif
55815 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55816 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55817 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55818 index b1822dd..df622cb 100644
55819 --- a/fs/proc/nommu.c
55820 +++ b/fs/proc/nommu.c
55821 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55822 if (len < 1)
55823 len = 1;
55824 seq_printf(m, "%*c", len, ' ');
55825 - seq_path(m, &file->f_path, "");
55826 + seq_path(m, &file->f_path, "\n\\");
55827 }
55828
55829 seq_putc(m, '\n');
55830 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55831 index fe72cd0..21b52ff 100644
55832 --- a/fs/proc/proc_net.c
55833 +++ b/fs/proc/proc_net.c
55834 @@ -23,6 +23,7 @@
55835 #include <linux/nsproxy.h>
55836 #include <net/net_namespace.h>
55837 #include <linux/seq_file.h>
55838 +#include <linux/grsecurity.h>
55839
55840 #include "internal.h"
55841
55842 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55843 struct task_struct *task;
55844 struct nsproxy *ns;
55845 struct net *net = NULL;
55846 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55847 + const struct cred *cred = current_cred();
55848 +#endif
55849 +
55850 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55851 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55852 + return net;
55853 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55854 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55855 + return net;
55856 +#endif
55857
55858 rcu_read_lock();
55859 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55860 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55861 index 1827d88..43b0279 100644
55862 --- a/fs/proc/proc_sysctl.c
55863 +++ b/fs/proc/proc_sysctl.c
55864 @@ -12,11 +12,15 @@
55865 #include <linux/module.h>
55866 #include "internal.h"
55867
55868 +extern int gr_handle_chroot_sysctl(const int op);
55869 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55870 + const int op);
55871 +
55872 static const struct dentry_operations proc_sys_dentry_operations;
55873 static const struct file_operations proc_sys_file_operations;
55874 -static const struct inode_operations proc_sys_inode_operations;
55875 +const struct inode_operations proc_sys_inode_operations;
55876 static const struct file_operations proc_sys_dir_file_operations;
55877 -static const struct inode_operations proc_sys_dir_operations;
55878 +const struct inode_operations proc_sys_dir_operations;
55879
55880 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55881 {
55882 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55883
55884 err = NULL;
55885 d_set_d_op(dentry, &proc_sys_dentry_operations);
55886 +
55887 + gr_handle_proc_create(dentry, inode);
55888 +
55889 d_add(dentry, inode);
55890
55891 out:
55892 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55893 struct inode *inode = filp->f_path.dentry->d_inode;
55894 struct ctl_table_header *head = grab_header(inode);
55895 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55896 + int op = write ? MAY_WRITE : MAY_READ;
55897 ssize_t error;
55898 size_t res;
55899
55900 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55901 * and won't be until we finish.
55902 */
55903 error = -EPERM;
55904 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55905 + if (sysctl_perm(head, table, op))
55906 goto out;
55907
55908 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55909 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55910 if (!table->proc_handler)
55911 goto out;
55912
55913 +#ifdef CONFIG_GRKERNSEC
55914 + error = -EPERM;
55915 + if (gr_handle_chroot_sysctl(op))
55916 + goto out;
55917 + dget(filp->f_path.dentry);
55918 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55919 + dput(filp->f_path.dentry);
55920 + goto out;
55921 + }
55922 + dput(filp->f_path.dentry);
55923 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55924 + goto out;
55925 + if (write && !capable(CAP_SYS_ADMIN))
55926 + goto out;
55927 +#endif
55928 +
55929 /* careful: calling conventions are nasty here */
55930 res = count;
55931 error = table->proc_handler(table, write, buf, &res, ppos);
55932 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55933 return -ENOMEM;
55934 } else {
55935 d_set_d_op(child, &proc_sys_dentry_operations);
55936 +
55937 + gr_handle_proc_create(child, inode);
55938 +
55939 d_add(child, inode);
55940 }
55941 } else {
55942 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55943 if ((*pos)++ < file->f_pos)
55944 return 0;
55945
55946 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55947 + return 0;
55948 +
55949 if (unlikely(S_ISLNK(table->mode)))
55950 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55951 else
55952 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55953 if (IS_ERR(head))
55954 return PTR_ERR(head);
55955
55956 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55957 + return -ENOENT;
55958 +
55959 generic_fillattr(inode, stat);
55960 if (table)
55961 stat->mode = (stat->mode & S_IFMT) | table->mode;
55962 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55963 .llseek = generic_file_llseek,
55964 };
55965
55966 -static const struct inode_operations proc_sys_inode_operations = {
55967 +const struct inode_operations proc_sys_inode_operations = {
55968 .permission = proc_sys_permission,
55969 .setattr = proc_sys_setattr,
55970 .getattr = proc_sys_getattr,
55971 };
55972
55973 -static const struct inode_operations proc_sys_dir_operations = {
55974 +const struct inode_operations proc_sys_dir_operations = {
55975 .lookup = proc_sys_lookup,
55976 .permission = proc_sys_permission,
55977 .setattr = proc_sys_setattr,
55978 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55979 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55980 const char *name, int namelen)
55981 {
55982 - struct ctl_table *table;
55983 + ctl_table_no_const *table;
55984 struct ctl_dir *new;
55985 struct ctl_node *node;
55986 char *new_name;
55987 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55988 return NULL;
55989
55990 node = (struct ctl_node *)(new + 1);
55991 - table = (struct ctl_table *)(node + 1);
55992 + table = (ctl_table_no_const *)(node + 1);
55993 new_name = (char *)(table + 2);
55994 memcpy(new_name, name, namelen);
55995 new_name[namelen] = '\0';
55996 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55997 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55998 struct ctl_table_root *link_root)
55999 {
56000 - struct ctl_table *link_table, *entry, *link;
56001 + ctl_table_no_const *link_table, *link;
56002 + struct ctl_table *entry;
56003 struct ctl_table_header *links;
56004 struct ctl_node *node;
56005 char *link_name;
56006 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
56007 return NULL;
56008
56009 node = (struct ctl_node *)(links + 1);
56010 - link_table = (struct ctl_table *)(node + nr_entries);
56011 + link_table = (ctl_table_no_const *)(node + nr_entries);
56012 link_name = (char *)&link_table[nr_entries + 1];
56013
56014 for (link = link_table, entry = table; entry->procname; link++, entry++) {
56015 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56016 struct ctl_table_header ***subheader, struct ctl_table_set *set,
56017 struct ctl_table *table)
56018 {
56019 - struct ctl_table *ctl_table_arg = NULL;
56020 - struct ctl_table *entry, *files;
56021 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
56022 + struct ctl_table *entry;
56023 int nr_files = 0;
56024 int nr_dirs = 0;
56025 int err = -ENOMEM;
56026 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56027 nr_files++;
56028 }
56029
56030 - files = table;
56031 /* If there are mixed files and directories we need a new table */
56032 if (nr_dirs && nr_files) {
56033 - struct ctl_table *new;
56034 + ctl_table_no_const *new;
56035 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
56036 GFP_KERNEL);
56037 if (!files)
56038 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
56039 /* Register everything except a directory full of subdirectories */
56040 if (nr_files || !nr_dirs) {
56041 struct ctl_table_header *header;
56042 - header = __register_sysctl_table(set, path, files);
56043 + header = __register_sysctl_table(set, path, files ? files : table);
56044 if (!header) {
56045 kfree(ctl_table_arg);
56046 goto out;
56047 diff --git a/fs/proc/root.c b/fs/proc/root.c
56048 index 9c7fab1..ed1c8e0 100644
56049 --- a/fs/proc/root.c
56050 +++ b/fs/proc/root.c
56051 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
56052 #ifdef CONFIG_PROC_DEVICETREE
56053 proc_device_tree_init();
56054 #endif
56055 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
56056 +#ifdef CONFIG_GRKERNSEC_PROC_USER
56057 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
56058 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
56059 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
56060 +#endif
56061 +#else
56062 proc_mkdir("bus", NULL);
56063 +#endif
56064 proc_sys_init();
56065 }
56066
56067 diff --git a/fs/proc/self.c b/fs/proc/self.c
56068 index aa5cc3b..c91a5d0 100644
56069 --- a/fs/proc/self.c
56070 +++ b/fs/proc/self.c
56071 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
56072 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
56073 void *cookie)
56074 {
56075 - char *s = nd_get_link(nd);
56076 + const char *s = nd_get_link(nd);
56077 if (!IS_ERR(s))
56078 kfree(s);
56079 }
56080 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
56081 index ca5ce7f..02c1cf0 100644
56082 --- a/fs/proc/task_mmu.c
56083 +++ b/fs/proc/task_mmu.c
56084 @@ -11,12 +11,19 @@
56085 #include <linux/rmap.h>
56086 #include <linux/swap.h>
56087 #include <linux/swapops.h>
56088 +#include <linux/grsecurity.h>
56089
56090 #include <asm/elf.h>
56091 #include <asm/uaccess.h>
56092 #include <asm/tlbflush.h>
56093 #include "internal.h"
56094
56095 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56096 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56097 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56098 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56099 +#endif
56100 +
56101 void task_mem(struct seq_file *m, struct mm_struct *mm)
56102 {
56103 unsigned long data, text, lib, swap;
56104 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56105 "VmExe:\t%8lu kB\n"
56106 "VmLib:\t%8lu kB\n"
56107 "VmPTE:\t%8lu kB\n"
56108 - "VmSwap:\t%8lu kB\n",
56109 - hiwater_vm << (PAGE_SHIFT-10),
56110 + "VmSwap:\t%8lu kB\n"
56111 +
56112 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56113 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56114 +#endif
56115 +
56116 + ,hiwater_vm << (PAGE_SHIFT-10),
56117 total_vm << (PAGE_SHIFT-10),
56118 mm->locked_vm << (PAGE_SHIFT-10),
56119 mm->pinned_vm << (PAGE_SHIFT-10),
56120 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56121 data << (PAGE_SHIFT-10),
56122 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56123 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56124 - swap << (PAGE_SHIFT-10));
56125 + swap << (PAGE_SHIFT-10)
56126 +
56127 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56128 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56129 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56130 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56131 +#else
56132 + , mm->context.user_cs_base
56133 + , mm->context.user_cs_limit
56134 +#endif
56135 +#endif
56136 +
56137 + );
56138 }
56139
56140 unsigned long task_vsize(struct mm_struct *mm)
56141 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56142 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56143 }
56144
56145 - /* We don't show the stack guard page in /proc/maps */
56146 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56147 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56148 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56149 +#else
56150 start = vma->vm_start;
56151 - if (stack_guard_page_start(vma, start))
56152 - start += PAGE_SIZE;
56153 end = vma->vm_end;
56154 - if (stack_guard_page_end(vma, end))
56155 - end -= PAGE_SIZE;
56156 +#endif
56157
56158 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56159 start,
56160 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56161 flags & VM_WRITE ? 'w' : '-',
56162 flags & VM_EXEC ? 'x' : '-',
56163 flags & VM_MAYSHARE ? 's' : 'p',
56164 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56165 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56166 +#else
56167 pgoff,
56168 +#endif
56169 MAJOR(dev), MINOR(dev), ino, &len);
56170
56171 /*
56172 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56173 */
56174 if (file) {
56175 pad_len_spaces(m, len);
56176 - seq_path(m, &file->f_path, "\n");
56177 + seq_path(m, &file->f_path, "\n\\");
56178 goto done;
56179 }
56180
56181 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56182 * Thread stack in /proc/PID/task/TID/maps or
56183 * the main process stack.
56184 */
56185 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56186 - vma->vm_end >= mm->start_stack)) {
56187 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56188 + (vma->vm_start <= mm->start_stack &&
56189 + vma->vm_end >= mm->start_stack)) {
56190 name = "[stack]";
56191 } else {
56192 /* Thread stack in /proc/PID/maps */
56193 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56194 struct proc_maps_private *priv = m->private;
56195 struct task_struct *task = priv->task;
56196
56197 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56198 + if (current->exec_id != m->exec_id) {
56199 + gr_log_badprocpid("maps");
56200 + return 0;
56201 + }
56202 +#endif
56203 +
56204 show_map_vma(m, vma, is_pid);
56205
56206 if (m->count < m->size) /* vma is copied successfully */
56207 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56208 .private = &mss,
56209 };
56210
56211 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56212 + if (current->exec_id != m->exec_id) {
56213 + gr_log_badprocpid("smaps");
56214 + return 0;
56215 + }
56216 +#endif
56217 memset(&mss, 0, sizeof mss);
56218 - mss.vma = vma;
56219 - /* mmap_sem is held in m_start */
56220 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56221 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56222 -
56223 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56224 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56225 +#endif
56226 + mss.vma = vma;
56227 + /* mmap_sem is held in m_start */
56228 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56229 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56230 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56231 + }
56232 +#endif
56233 show_map_vma(m, vma, is_pid);
56234
56235 seq_printf(m,
56236 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56237 "KernelPageSize: %8lu kB\n"
56238 "MMUPageSize: %8lu kB\n"
56239 "Locked: %8lu kB\n",
56240 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56241 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56242 +#else
56243 (vma->vm_end - vma->vm_start) >> 10,
56244 +#endif
56245 mss.resident >> 10,
56246 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56247 mss.shared_clean >> 10,
56248 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56249 int n;
56250 char buffer[50];
56251
56252 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56253 + if (current->exec_id != m->exec_id) {
56254 + gr_log_badprocpid("numa_maps");
56255 + return 0;
56256 + }
56257 +#endif
56258 +
56259 if (!mm)
56260 return 0;
56261
56262 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56263 mpol_to_str(buffer, sizeof(buffer), pol);
56264 mpol_cond_put(pol);
56265
56266 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56267 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56268 +#else
56269 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56270 +#endif
56271
56272 if (file) {
56273 seq_printf(m, " file=");
56274 - seq_path(m, &file->f_path, "\n\t= ");
56275 + seq_path(m, &file->f_path, "\n\t\\= ");
56276 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56277 seq_printf(m, " heap");
56278 } else {
56279 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56280 index 1ccfa53..0848f95 100644
56281 --- a/fs/proc/task_nommu.c
56282 +++ b/fs/proc/task_nommu.c
56283 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56284 else
56285 bytes += kobjsize(mm);
56286
56287 - if (current->fs && current->fs->users > 1)
56288 + if (current->fs && atomic_read(&current->fs->users) > 1)
56289 sbytes += kobjsize(current->fs);
56290 else
56291 bytes += kobjsize(current->fs);
56292 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56293
56294 if (file) {
56295 pad_len_spaces(m, len);
56296 - seq_path(m, &file->f_path, "");
56297 + seq_path(m, &file->f_path, "\n\\");
56298 } else if (mm) {
56299 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56300
56301 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56302 index b00fcc9..e0c6381 100644
56303 --- a/fs/qnx6/qnx6.h
56304 +++ b/fs/qnx6/qnx6.h
56305 @@ -74,7 +74,7 @@ enum {
56306 BYTESEX_BE,
56307 };
56308
56309 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56310 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56311 {
56312 if (sbi->s_bytesex == BYTESEX_LE)
56313 return le64_to_cpu((__force __le64)n);
56314 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56315 return (__force __fs64)cpu_to_be64(n);
56316 }
56317
56318 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56319 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56320 {
56321 if (sbi->s_bytesex == BYTESEX_LE)
56322 return le32_to_cpu((__force __le32)n);
56323 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56324 index 16e8abb..2dcf914 100644
56325 --- a/fs/quota/netlink.c
56326 +++ b/fs/quota/netlink.c
56327 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56328 void quota_send_warning(struct kqid qid, dev_t dev,
56329 const char warntype)
56330 {
56331 - static atomic_t seq;
56332 + static atomic_unchecked_t seq;
56333 struct sk_buff *skb;
56334 void *msg_head;
56335 int ret;
56336 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56337 "VFS: Not enough memory to send quota warning.\n");
56338 return;
56339 }
56340 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56341 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56342 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56343 if (!msg_head) {
56344 printk(KERN_ERR
56345 diff --git a/fs/readdir.c b/fs/readdir.c
56346 index 5e69ef5..e5d9099 100644
56347 --- a/fs/readdir.c
56348 +++ b/fs/readdir.c
56349 @@ -17,6 +17,7 @@
56350 #include <linux/security.h>
56351 #include <linux/syscalls.h>
56352 #include <linux/unistd.h>
56353 +#include <linux/namei.h>
56354
56355 #include <asm/uaccess.h>
56356
56357 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56358
56359 struct readdir_callback {
56360 struct old_linux_dirent __user * dirent;
56361 + struct file * file;
56362 int result;
56363 };
56364
56365 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56366 buf->result = -EOVERFLOW;
56367 return -EOVERFLOW;
56368 }
56369 +
56370 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56371 + return 0;
56372 +
56373 buf->result++;
56374 dirent = buf->dirent;
56375 if (!access_ok(VERIFY_WRITE, dirent,
56376 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56377
56378 buf.result = 0;
56379 buf.dirent = dirent;
56380 + buf.file = f.file;
56381
56382 error = vfs_readdir(f.file, fillonedir, &buf);
56383 if (buf.result)
56384 @@ -139,6 +146,7 @@ struct linux_dirent {
56385 struct getdents_callback {
56386 struct linux_dirent __user * current_dir;
56387 struct linux_dirent __user * previous;
56388 + struct file * file;
56389 int count;
56390 int error;
56391 };
56392 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56393 buf->error = -EOVERFLOW;
56394 return -EOVERFLOW;
56395 }
56396 +
56397 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56398 + return 0;
56399 +
56400 dirent = buf->previous;
56401 if (dirent) {
56402 if (__put_user(offset, &dirent->d_off))
56403 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56404 buf.previous = NULL;
56405 buf.count = count;
56406 buf.error = 0;
56407 + buf.file = f.file;
56408
56409 error = vfs_readdir(f.file, filldir, &buf);
56410 if (error >= 0)
56411 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56412 struct getdents_callback64 {
56413 struct linux_dirent64 __user * current_dir;
56414 struct linux_dirent64 __user * previous;
56415 + struct file *file;
56416 int count;
56417 int error;
56418 };
56419 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56420 buf->error = -EINVAL; /* only used if we fail.. */
56421 if (reclen > buf->count)
56422 return -EINVAL;
56423 +
56424 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56425 + return 0;
56426 +
56427 dirent = buf->previous;
56428 if (dirent) {
56429 if (__put_user(offset, &dirent->d_off))
56430 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56431
56432 buf.current_dir = dirent;
56433 buf.previous = NULL;
56434 + buf.file = f.file;
56435 buf.count = count;
56436 buf.error = 0;
56437
56438 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56439 error = buf.error;
56440 lastdirent = buf.previous;
56441 if (lastdirent) {
56442 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56443 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56444 if (__put_user(d_off, &lastdirent->d_off))
56445 error = -EFAULT;
56446 else
56447 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56448 index 2b7882b..1c5ef48 100644
56449 --- a/fs/reiserfs/do_balan.c
56450 +++ b/fs/reiserfs/do_balan.c
56451 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56452 return;
56453 }
56454
56455 - atomic_inc(&(fs_generation(tb->tb_sb)));
56456 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56457 do_balance_starts(tb);
56458
56459 /* balance leaf returns 0 except if combining L R and S into
56460 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56461 index e60e870..f40ac16 100644
56462 --- a/fs/reiserfs/procfs.c
56463 +++ b/fs/reiserfs/procfs.c
56464 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56465 "SMALL_TAILS " : "NO_TAILS ",
56466 replay_only(sb) ? "REPLAY_ONLY " : "",
56467 convert_reiserfs(sb) ? "CONV " : "",
56468 - atomic_read(&r->s_generation_counter),
56469 + atomic_read_unchecked(&r->s_generation_counter),
56470 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56471 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56472 SF(s_good_search_by_key_reada), SF(s_bmaps),
56473 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56474 index 157e474..65a6114 100644
56475 --- a/fs/reiserfs/reiserfs.h
56476 +++ b/fs/reiserfs/reiserfs.h
56477 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56478 /* Comment? -Hans */
56479 wait_queue_head_t s_wait;
56480 /* To be obsoleted soon by per buffer seals.. -Hans */
56481 - atomic_t s_generation_counter; // increased by one every time the
56482 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56483 // tree gets re-balanced
56484 unsigned long s_properties; /* File system properties. Currently holds
56485 on-disk FS format */
56486 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56487 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56488
56489 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56490 -#define get_generation(s) atomic_read (&fs_generation(s))
56491 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56492 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56493 #define __fs_changed(gen,s) (gen != get_generation (s))
56494 #define fs_changed(gen,s) \
56495 diff --git a/fs/select.c b/fs/select.c
56496 index 2ef72d9..f213b17 100644
56497 --- a/fs/select.c
56498 +++ b/fs/select.c
56499 @@ -20,6 +20,7 @@
56500 #include <linux/export.h>
56501 #include <linux/slab.h>
56502 #include <linux/poll.h>
56503 +#include <linux/security.h>
56504 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56505 #include <linux/file.h>
56506 #include <linux/fdtable.h>
56507 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56508 struct poll_list *walk = head;
56509 unsigned long todo = nfds;
56510
56511 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56512 if (nfds > rlimit(RLIMIT_NOFILE))
56513 return -EINVAL;
56514
56515 diff --git a/fs/seq_file.c b/fs/seq_file.c
56516 index f2bc3df..239d4f6 100644
56517 --- a/fs/seq_file.c
56518 +++ b/fs/seq_file.c
56519 @@ -10,6 +10,7 @@
56520 #include <linux/seq_file.h>
56521 #include <linux/slab.h>
56522 #include <linux/cred.h>
56523 +#include <linux/sched.h>
56524
56525 #include <asm/uaccess.h>
56526 #include <asm/page.h>
56527 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56528 #ifdef CONFIG_USER_NS
56529 p->user_ns = file->f_cred->user_ns;
56530 #endif
56531 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56532 + p->exec_id = current->exec_id;
56533 +#endif
56534
56535 /*
56536 * Wrappers around seq_open(e.g. swaps_open) need to be
56537 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56538 return 0;
56539 }
56540 if (!m->buf) {
56541 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56542 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56543 if (!m->buf)
56544 return -ENOMEM;
56545 }
56546 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56547 Eoverflow:
56548 m->op->stop(m, p);
56549 kfree(m->buf);
56550 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56551 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56552 return !m->buf ? -ENOMEM : -EAGAIN;
56553 }
56554
56555 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56556
56557 /* grab buffer if we didn't have one */
56558 if (!m->buf) {
56559 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56560 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56561 if (!m->buf)
56562 goto Enomem;
56563 }
56564 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56565 goto Fill;
56566 m->op->stop(m, p);
56567 kfree(m->buf);
56568 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56569 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56570 if (!m->buf)
56571 goto Enomem;
56572 m->count = 0;
56573 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56574 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56575 void *data)
56576 {
56577 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56578 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56579 int res = -ENOMEM;
56580
56581 if (op) {
56582 diff --git a/fs/splice.c b/fs/splice.c
56583 index 6909d89..5b2e8f9 100644
56584 --- a/fs/splice.c
56585 +++ b/fs/splice.c
56586 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56587 pipe_lock(pipe);
56588
56589 for (;;) {
56590 - if (!pipe->readers) {
56591 + if (!atomic_read(&pipe->readers)) {
56592 send_sig(SIGPIPE, current, 0);
56593 if (!ret)
56594 ret = -EPIPE;
56595 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56596 do_wakeup = 0;
56597 }
56598
56599 - pipe->waiting_writers++;
56600 + atomic_inc(&pipe->waiting_writers);
56601 pipe_wait(pipe);
56602 - pipe->waiting_writers--;
56603 + atomic_dec(&pipe->waiting_writers);
56604 }
56605
56606 pipe_unlock(pipe);
56607 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56608 old_fs = get_fs();
56609 set_fs(get_ds());
56610 /* The cast to a user pointer is valid due to the set_fs() */
56611 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56612 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56613 set_fs(old_fs);
56614
56615 return res;
56616 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56617 old_fs = get_fs();
56618 set_fs(get_ds());
56619 /* The cast to a user pointer is valid due to the set_fs() */
56620 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56621 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56622 set_fs(old_fs);
56623
56624 return res;
56625 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56626 goto err;
56627
56628 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56629 - vec[i].iov_base = (void __user *) page_address(page);
56630 + vec[i].iov_base = (void __force_user *) page_address(page);
56631 vec[i].iov_len = this_len;
56632 spd.pages[i] = page;
56633 spd.nr_pages++;
56634 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56635 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56636 {
56637 while (!pipe->nrbufs) {
56638 - if (!pipe->writers)
56639 + if (!atomic_read(&pipe->writers))
56640 return 0;
56641
56642 - if (!pipe->waiting_writers && sd->num_spliced)
56643 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56644 return 0;
56645
56646 if (sd->flags & SPLICE_F_NONBLOCK)
56647 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56648 * out of the pipe right after the splice_to_pipe(). So set
56649 * PIPE_READERS appropriately.
56650 */
56651 - pipe->readers = 1;
56652 + atomic_set(&pipe->readers, 1);
56653
56654 current->splice_pipe = pipe;
56655 }
56656 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56657 ret = -ERESTARTSYS;
56658 break;
56659 }
56660 - if (!pipe->writers)
56661 + if (!atomic_read(&pipe->writers))
56662 break;
56663 - if (!pipe->waiting_writers) {
56664 + if (!atomic_read(&pipe->waiting_writers)) {
56665 if (flags & SPLICE_F_NONBLOCK) {
56666 ret = -EAGAIN;
56667 break;
56668 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56669 pipe_lock(pipe);
56670
56671 while (pipe->nrbufs >= pipe->buffers) {
56672 - if (!pipe->readers) {
56673 + if (!atomic_read(&pipe->readers)) {
56674 send_sig(SIGPIPE, current, 0);
56675 ret = -EPIPE;
56676 break;
56677 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56678 ret = -ERESTARTSYS;
56679 break;
56680 }
56681 - pipe->waiting_writers++;
56682 + atomic_inc(&pipe->waiting_writers);
56683 pipe_wait(pipe);
56684 - pipe->waiting_writers--;
56685 + atomic_dec(&pipe->waiting_writers);
56686 }
56687
56688 pipe_unlock(pipe);
56689 @@ -1823,14 +1823,14 @@ retry:
56690 pipe_double_lock(ipipe, opipe);
56691
56692 do {
56693 - if (!opipe->readers) {
56694 + if (!atomic_read(&opipe->readers)) {
56695 send_sig(SIGPIPE, current, 0);
56696 if (!ret)
56697 ret = -EPIPE;
56698 break;
56699 }
56700
56701 - if (!ipipe->nrbufs && !ipipe->writers)
56702 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56703 break;
56704
56705 /*
56706 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56707 pipe_double_lock(ipipe, opipe);
56708
56709 do {
56710 - if (!opipe->readers) {
56711 + if (!atomic_read(&opipe->readers)) {
56712 send_sig(SIGPIPE, current, 0);
56713 if (!ret)
56714 ret = -EPIPE;
56715 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56716 * return EAGAIN if we have the potential of some data in the
56717 * future, otherwise just return 0
56718 */
56719 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56720 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56721 ret = -EAGAIN;
56722
56723 pipe_unlock(ipipe);
56724 diff --git a/fs/stat.c b/fs/stat.c
56725 index 14f4545..9b7f55b 100644
56726 --- a/fs/stat.c
56727 +++ b/fs/stat.c
56728 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56729 stat->gid = inode->i_gid;
56730 stat->rdev = inode->i_rdev;
56731 stat->size = i_size_read(inode);
56732 - stat->atime = inode->i_atime;
56733 - stat->mtime = inode->i_mtime;
56734 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56735 + stat->atime = inode->i_ctime;
56736 + stat->mtime = inode->i_ctime;
56737 + } else {
56738 + stat->atime = inode->i_atime;
56739 + stat->mtime = inode->i_mtime;
56740 + }
56741 stat->ctime = inode->i_ctime;
56742 stat->blksize = (1 << inode->i_blkbits);
56743 stat->blocks = inode->i_blocks;
56744 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56745 if (retval)
56746 return retval;
56747
56748 - if (inode->i_op->getattr)
56749 - return inode->i_op->getattr(mnt, dentry, stat);
56750 + if (inode->i_op->getattr) {
56751 + retval = inode->i_op->getattr(mnt, dentry, stat);
56752 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56753 + stat->atime = stat->ctime;
56754 + stat->mtime = stat->ctime;
56755 + }
56756 + return retval;
56757 + }
56758
56759 generic_fillattr(inode, stat);
56760 return 0;
56761 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56762 index 614b2b5..4d321e6 100644
56763 --- a/fs/sysfs/bin.c
56764 +++ b/fs/sysfs/bin.c
56765 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56766 return ret;
56767 }
56768
56769 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56770 - void *buf, int len, int write)
56771 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56772 + void *buf, size_t len, int write)
56773 {
56774 struct file *file = vma->vm_file;
56775 struct bin_buffer *bb = file->private_data;
56776 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56777 - int ret;
56778 + ssize_t ret;
56779
56780 if (!bb->vm_ops)
56781 return -EINVAL;
56782 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56783 index d924812..97a74e3 100644
56784 --- a/fs/sysfs/dir.c
56785 +++ b/fs/sysfs/dir.c
56786 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56787 *
56788 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56789 */
56790 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56791 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56792 {
56793 unsigned long hash = init_name_hash();
56794 unsigned int len = strlen(name);
56795 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56796 struct sysfs_dirent *sd;
56797 int rc;
56798
56799 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56800 + const char *parent_name = parent_sd->s_name;
56801 +
56802 + mode = S_IFDIR | S_IRWXU;
56803 +
56804 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56805 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56806 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56807 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56808 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56809 +#endif
56810 +
56811 /* allocate */
56812 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56813 if (!sd)
56814 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56815 index 602f56d..6853db8 100644
56816 --- a/fs/sysfs/file.c
56817 +++ b/fs/sysfs/file.c
56818 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56819
56820 struct sysfs_open_dirent {
56821 atomic_t refcnt;
56822 - atomic_t event;
56823 + atomic_unchecked_t event;
56824 wait_queue_head_t poll;
56825 struct list_head buffers; /* goes through sysfs_buffer.list */
56826 };
56827 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56828 if (!sysfs_get_active(attr_sd))
56829 return -ENODEV;
56830
56831 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56832 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56833 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56834
56835 sysfs_put_active(attr_sd);
56836 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56837 return -ENOMEM;
56838
56839 atomic_set(&new_od->refcnt, 0);
56840 - atomic_set(&new_od->event, 1);
56841 + atomic_set_unchecked(&new_od->event, 1);
56842 init_waitqueue_head(&new_od->poll);
56843 INIT_LIST_HEAD(&new_od->buffers);
56844 goto retry;
56845 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56846
56847 sysfs_put_active(attr_sd);
56848
56849 - if (buffer->event != atomic_read(&od->event))
56850 + if (buffer->event != atomic_read_unchecked(&od->event))
56851 goto trigger;
56852
56853 return DEFAULT_POLLMASK;
56854 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56855
56856 od = sd->s_attr.open;
56857 if (od) {
56858 - atomic_inc(&od->event);
56859 + atomic_inc_unchecked(&od->event);
56860 wake_up_interruptible(&od->poll);
56861 }
56862
56863 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56864 index 3c9eb56..9dea5be 100644
56865 --- a/fs/sysfs/symlink.c
56866 +++ b/fs/sysfs/symlink.c
56867 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56868
56869 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56870 {
56871 - char *page = nd_get_link(nd);
56872 + const char *page = nd_get_link(nd);
56873 if (!IS_ERR(page))
56874 free_page((unsigned long)page);
56875 }
56876 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56877 index 69d4889..a810bd4 100644
56878 --- a/fs/sysv/sysv.h
56879 +++ b/fs/sysv/sysv.h
56880 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56881 #endif
56882 }
56883
56884 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56885 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56886 {
56887 if (sbi->s_bytesex == BYTESEX_PDP)
56888 return PDP_swab((__force __u32)n);
56889 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56890 index e18b988..f1d4ad0f 100644
56891 --- a/fs/ubifs/io.c
56892 +++ b/fs/ubifs/io.c
56893 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56894 return err;
56895 }
56896
56897 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56898 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56899 {
56900 int err;
56901
56902 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56903 index c175b4d..8f36a16 100644
56904 --- a/fs/udf/misc.c
56905 +++ b/fs/udf/misc.c
56906 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56907
56908 u8 udf_tag_checksum(const struct tag *t)
56909 {
56910 - u8 *data = (u8 *)t;
56911 + const u8 *data = (const u8 *)t;
56912 u8 checksum = 0;
56913 int i;
56914 for (i = 0; i < sizeof(struct tag); ++i)
56915 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56916 index 8d974c4..b82f6ec 100644
56917 --- a/fs/ufs/swab.h
56918 +++ b/fs/ufs/swab.h
56919 @@ -22,7 +22,7 @@ enum {
56920 BYTESEX_BE
56921 };
56922
56923 -static inline u64
56924 +static inline u64 __intentional_overflow(-1)
56925 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56926 {
56927 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56928 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56929 return (__force __fs64)cpu_to_be64(n);
56930 }
56931
56932 -static inline u32
56933 +static inline u32 __intentional_overflow(-1)
56934 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56935 {
56936 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56937 diff --git a/fs/utimes.c b/fs/utimes.c
56938 index f4fb7ec..3fe03c0 100644
56939 --- a/fs/utimes.c
56940 +++ b/fs/utimes.c
56941 @@ -1,6 +1,7 @@
56942 #include <linux/compiler.h>
56943 #include <linux/file.h>
56944 #include <linux/fs.h>
56945 +#include <linux/security.h>
56946 #include <linux/linkage.h>
56947 #include <linux/mount.h>
56948 #include <linux/namei.h>
56949 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56950 goto mnt_drop_write_and_out;
56951 }
56952 }
56953 +
56954 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56955 + error = -EACCES;
56956 + goto mnt_drop_write_and_out;
56957 + }
56958 +
56959 mutex_lock(&inode->i_mutex);
56960 error = notify_change(path->dentry, &newattrs);
56961 mutex_unlock(&inode->i_mutex);
56962 diff --git a/fs/xattr.c b/fs/xattr.c
56963 index 3377dff..4feded6 100644
56964 --- a/fs/xattr.c
56965 +++ b/fs/xattr.c
56966 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56967 * Extended attribute SET operations
56968 */
56969 static long
56970 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56971 +setxattr(struct path *path, const char __user *name, const void __user *value,
56972 size_t size, int flags)
56973 {
56974 int error;
56975 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56976 posix_acl_fix_xattr_from_user(kvalue, size);
56977 }
56978
56979 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56980 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56981 + error = -EACCES;
56982 + goto out;
56983 + }
56984 +
56985 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56986 out:
56987 if (vvalue)
56988 vfree(vvalue);
56989 @@ -377,7 +382,7 @@ retry:
56990 return error;
56991 error = mnt_want_write(path.mnt);
56992 if (!error) {
56993 - error = setxattr(path.dentry, name, value, size, flags);
56994 + error = setxattr(&path, name, value, size, flags);
56995 mnt_drop_write(path.mnt);
56996 }
56997 path_put(&path);
56998 @@ -401,7 +406,7 @@ retry:
56999 return error;
57000 error = mnt_want_write(path.mnt);
57001 if (!error) {
57002 - error = setxattr(path.dentry, name, value, size, flags);
57003 + error = setxattr(&path, name, value, size, flags);
57004 mnt_drop_write(path.mnt);
57005 }
57006 path_put(&path);
57007 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
57008 const void __user *,value, size_t, size, int, flags)
57009 {
57010 struct fd f = fdget(fd);
57011 - struct dentry *dentry;
57012 int error = -EBADF;
57013
57014 if (!f.file)
57015 return error;
57016 - dentry = f.file->f_path.dentry;
57017 - audit_inode(NULL, dentry, 0);
57018 + audit_inode(NULL, f.file->f_path.dentry, 0);
57019 error = mnt_want_write_file(f.file);
57020 if (!error) {
57021 - error = setxattr(dentry, name, value, size, flags);
57022 + error = setxattr(&f.file->f_path, name, value, size, flags);
57023 mnt_drop_write_file(f.file);
57024 }
57025 fdput(f);
57026 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57027 index 9fbea87..6b19972 100644
57028 --- a/fs/xattr_acl.c
57029 +++ b/fs/xattr_acl.c
57030 @@ -76,8 +76,8 @@ struct posix_acl *
57031 posix_acl_from_xattr(struct user_namespace *user_ns,
57032 const void *value, size_t size)
57033 {
57034 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57035 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57036 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57037 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57038 int count;
57039 struct posix_acl *acl;
57040 struct posix_acl_entry *acl_e;
57041 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57042 index 572a858..12a9b0d 100644
57043 --- a/fs/xfs/xfs_bmap.c
57044 +++ b/fs/xfs/xfs_bmap.c
57045 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
57046 int nmap,
57047 int ret_nmap);
57048 #else
57049 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57050 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
57051 #endif /* DEBUG */
57052
57053 STATIC int
57054 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57055 index 1b9fc3e..e1bdde0 100644
57056 --- a/fs/xfs/xfs_dir2_sf.c
57057 +++ b/fs/xfs/xfs_dir2_sf.c
57058 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57059 }
57060
57061 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57062 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57063 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57064 + char name[sfep->namelen];
57065 + memcpy(name, sfep->name, sfep->namelen);
57066 + if (filldir(dirent, name, sfep->namelen,
57067 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57068 + *offset = off & 0x7fffffff;
57069 + return 0;
57070 + }
57071 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57072 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57073 *offset = off & 0x7fffffff;
57074 return 0;
57075 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57076 index c1c3ef8..0952438 100644
57077 --- a/fs/xfs/xfs_ioctl.c
57078 +++ b/fs/xfs/xfs_ioctl.c
57079 @@ -127,7 +127,7 @@ xfs_find_handle(
57080 }
57081
57082 error = -EFAULT;
57083 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57084 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57085 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57086 goto out_put;
57087
57088 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57089 index d82efaa..0904a8e 100644
57090 --- a/fs/xfs/xfs_iops.c
57091 +++ b/fs/xfs/xfs_iops.c
57092 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57093 struct nameidata *nd,
57094 void *p)
57095 {
57096 - char *s = nd_get_link(nd);
57097 + const char *s = nd_get_link(nd);
57098
57099 if (!IS_ERR(s))
57100 kfree(s);
57101 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57102 new file mode 100644
57103 index 0000000..829d8fb
57104 --- /dev/null
57105 +++ b/grsecurity/Kconfig
57106 @@ -0,0 +1,1031 @@
57107 +#
57108 +# grecurity configuration
57109 +#
57110 +menu "Memory Protections"
57111 +depends on GRKERNSEC
57112 +
57113 +config GRKERNSEC_KMEM
57114 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57115 + default y if GRKERNSEC_CONFIG_AUTO
57116 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57117 + help
57118 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57119 + be written to or read from to modify or leak the contents of the running
57120 + kernel. /dev/port will also not be allowed to be opened and support
57121 + for /dev/cpu/*/msr will be removed. If you have module
57122 + support disabled, enabling this will close up five ways that are
57123 + currently used to insert malicious code into the running kernel.
57124 +
57125 + Even with all these features enabled, we still highly recommend that
57126 + you use the RBAC system, as it is still possible for an attacker to
57127 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57128 +
57129 + If you are not using XFree86, you may be able to stop this additional
57130 + case by enabling the 'Disable privileged I/O' option. Though nothing
57131 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57132 + but only to video memory, which is the only writing we allow in this
57133 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57134 + not be allowed to mprotect it with PROT_WRITE later.
57135 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57136 + from working.
57137 +
57138 + It is highly recommended that you say Y here if you meet all the
57139 + conditions above.
57140 +
57141 +config GRKERNSEC_VM86
57142 + bool "Restrict VM86 mode"
57143 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57144 + depends on X86_32
57145 +
57146 + help
57147 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57148 + make use of a special execution mode on 32bit x86 processors called
57149 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57150 + video cards and will still work with this option enabled. The purpose
57151 + of the option is to prevent exploitation of emulation errors in
57152 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57153 + Nearly all users should be able to enable this option.
57154 +
57155 +config GRKERNSEC_IO
57156 + bool "Disable privileged I/O"
57157 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57158 + depends on X86
57159 + select RTC_CLASS
57160 + select RTC_INTF_DEV
57161 + select RTC_DRV_CMOS
57162 +
57163 + help
57164 + If you say Y here, all ioperm and iopl calls will return an error.
57165 + Ioperm and iopl can be used to modify the running kernel.
57166 + Unfortunately, some programs need this access to operate properly,
57167 + the most notable of which are XFree86 and hwclock. hwclock can be
57168 + remedied by having RTC support in the kernel, so real-time
57169 + clock support is enabled if this option is enabled, to ensure
57170 + that hwclock operates correctly. XFree86 still will not
57171 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57172 + IF YOU USE XFree86. If you use XFree86 and you still want to
57173 + protect your kernel against modification, use the RBAC system.
57174 +
57175 +config GRKERNSEC_JIT_HARDEN
57176 + bool "Harden BPF JIT against spray attacks"
57177 + default y if GRKERNSEC_CONFIG_AUTO
57178 + depends on BPF_JIT
57179 + help
57180 + If you say Y here, the native code generated by the kernel's Berkeley
57181 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57182 + attacks that attempt to fit attacker-beneficial instructions in
57183 + 32bit immediate fields of JIT-generated native instructions. The
57184 + attacker will generally aim to cause an unintended instruction sequence
57185 + of JIT-generated native code to execute by jumping into the middle of
57186 + a generated instruction. This feature effectively randomizes the 32bit
57187 + immediate constants present in the generated code to thwart such attacks.
57188 +
57189 + If you're using KERNEXEC, it's recommended that you enable this option
57190 + to supplement the hardening of the kernel.
57191 +
57192 +config GRKERNSEC_RAND_THREADSTACK
57193 + bool "Insert random gaps between thread stacks"
57194 + default y if GRKERNSEC_CONFIG_AUTO
57195 + depends on PAX_RANDMMAP && !PPC
57196 + help
57197 + If you say Y here, a random-sized gap will be enforced between allocated
57198 + thread stacks. Glibc's NPTL and other threading libraries that
57199 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57200 + The implementation currently provides 8 bits of entropy for the gap.
57201 +
57202 + Many distributions do not compile threaded remote services with the
57203 + -fstack-check argument to GCC, causing the variable-sized stack-based
57204 + allocator, alloca(), to not probe the stack on allocation. This
57205 + permits an unbounded alloca() to skip over any guard page and potentially
57206 + modify another thread's stack reliably. An enforced random gap
57207 + reduces the reliability of such an attack and increases the chance
57208 + that such a read/write to another thread's stack instead lands in
57209 + an unmapped area, causing a crash and triggering grsecurity's
57210 + anti-bruteforcing logic.
57211 +
57212 +config GRKERNSEC_PROC_MEMMAP
57213 + bool "Harden ASLR against information leaks and entropy reduction"
57214 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57215 + depends on PAX_NOEXEC || PAX_ASLR
57216 + help
57217 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57218 + give no information about the addresses of its mappings if
57219 + PaX features that rely on random addresses are enabled on the task.
57220 + In addition to sanitizing this information and disabling other
57221 + dangerous sources of information, this option causes reads of sensitive
57222 + /proc/<pid> entries where the file descriptor was opened in a different
57223 + task than the one performing the read. Such attempts are logged.
57224 + This option also limits argv/env strings for suid/sgid binaries
57225 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57226 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57227 + binaries to prevent alternative mmap layouts from being abused.
57228 +
57229 + If you use PaX it is essential that you say Y here as it closes up
57230 + several holes that make full ASLR useless locally.
57231 +
57232 +config GRKERNSEC_BRUTE
57233 + bool "Deter exploit bruteforcing"
57234 + default y if GRKERNSEC_CONFIG_AUTO
57235 + help
57236 + If you say Y here, attempts to bruteforce exploits against forking
57237 + daemons such as apache or sshd, as well as against suid/sgid binaries
57238 + will be deterred. When a child of a forking daemon is killed by PaX
57239 + or crashes due to an illegal instruction or other suspicious signal,
57240 + the parent process will be delayed 30 seconds upon every subsequent
57241 + fork until the administrator is able to assess the situation and
57242 + restart the daemon.
57243 + In the suid/sgid case, the attempt is logged, the user has all their
57244 + processes terminated, and they are prevented from executing any further
57245 + processes for 15 minutes.
57246 + It is recommended that you also enable signal logging in the auditing
57247 + section so that logs are generated when a process triggers a suspicious
57248 + signal.
57249 + If the sysctl option is enabled, a sysctl option with name
57250 + "deter_bruteforce" is created.
57251 +
57252 +
57253 +config GRKERNSEC_MODHARDEN
57254 + bool "Harden module auto-loading"
57255 + default y if GRKERNSEC_CONFIG_AUTO
57256 + depends on MODULES
57257 + help
57258 + If you say Y here, module auto-loading in response to use of some
57259 + feature implemented by an unloaded module will be restricted to
57260 + root users. Enabling this option helps defend against attacks
57261 + by unprivileged users who abuse the auto-loading behavior to
57262 + cause a vulnerable module to load that is then exploited.
57263 +
57264 + If this option prevents a legitimate use of auto-loading for a
57265 + non-root user, the administrator can execute modprobe manually
57266 + with the exact name of the module mentioned in the alert log.
57267 + Alternatively, the administrator can add the module to the list
57268 + of modules loaded at boot by modifying init scripts.
57269 +
57270 + Modification of init scripts will most likely be needed on
57271 + Ubuntu servers with encrypted home directory support enabled,
57272 + as the first non-root user logging in will cause the ecb(aes),
57273 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57274 +
57275 +config GRKERNSEC_HIDESYM
57276 + bool "Hide kernel symbols"
57277 + default y if GRKERNSEC_CONFIG_AUTO
57278 + select PAX_USERCOPY_SLABS
57279 + help
57280 + If you say Y here, getting information on loaded modules, and
57281 + displaying all kernel symbols through a syscall will be restricted
57282 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57283 + /proc/kallsyms will be restricted to the root user. The RBAC
57284 + system can hide that entry even from root.
57285 +
57286 + This option also prevents leaking of kernel addresses through
57287 + several /proc entries.
57288 +
57289 + Note that this option is only effective provided the following
57290 + conditions are met:
57291 + 1) The kernel using grsecurity is not precompiled by some distribution
57292 + 2) You have also enabled GRKERNSEC_DMESG
57293 + 3) You are using the RBAC system and hiding other files such as your
57294 + kernel image and System.map. Alternatively, enabling this option
57295 + causes the permissions on /boot, /lib/modules, and the kernel
57296 + source directory to change at compile time to prevent
57297 + reading by non-root users.
57298 + If the above conditions are met, this option will aid in providing a
57299 + useful protection against local kernel exploitation of overflows
57300 + and arbitrary read/write vulnerabilities.
57301 +
57302 +config GRKERNSEC_KERN_LOCKOUT
57303 + bool "Active kernel exploit response"
57304 + default y if GRKERNSEC_CONFIG_AUTO
57305 + depends on X86 || ARM || PPC || SPARC
57306 + help
57307 + If you say Y here, when a PaX alert is triggered due to suspicious
57308 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57309 + or an OOPS occurs due to bad memory accesses, instead of just
57310 + terminating the offending process (and potentially allowing
57311 + a subsequent exploit from the same user), we will take one of two
57312 + actions:
57313 + If the user was root, we will panic the system
57314 + If the user was non-root, we will log the attempt, terminate
57315 + all processes owned by the user, then prevent them from creating
57316 + any new processes until the system is restarted
57317 + This deters repeated kernel exploitation/bruteforcing attempts
57318 + and is useful for later forensics.
57319 +
57320 +endmenu
57321 +menu "Role Based Access Control Options"
57322 +depends on GRKERNSEC
57323 +
57324 +config GRKERNSEC_RBAC_DEBUG
57325 + bool
57326 +
57327 +config GRKERNSEC_NO_RBAC
57328 + bool "Disable RBAC system"
57329 + help
57330 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57331 + preventing the RBAC system from being enabled. You should only say Y
57332 + here if you have no intention of using the RBAC system, so as to prevent
57333 + an attacker with root access from misusing the RBAC system to hide files
57334 + and processes when loadable module support and /dev/[k]mem have been
57335 + locked down.
57336 +
57337 +config GRKERNSEC_ACL_HIDEKERN
57338 + bool "Hide kernel processes"
57339 + help
57340 + If you say Y here, all kernel threads will be hidden to all
57341 + processes but those whose subject has the "view hidden processes"
57342 + flag.
57343 +
57344 +config GRKERNSEC_ACL_MAXTRIES
57345 + int "Maximum tries before password lockout"
57346 + default 3
57347 + help
57348 + This option enforces the maximum number of times a user can attempt
57349 + to authorize themselves with the grsecurity RBAC system before being
57350 + denied the ability to attempt authorization again for a specified time.
57351 + The lower the number, the harder it will be to brute-force a password.
57352 +
57353 +config GRKERNSEC_ACL_TIMEOUT
57354 + int "Time to wait after max password tries, in seconds"
57355 + default 30
57356 + help
57357 + This option specifies the time the user must wait after attempting to
57358 + authorize to the RBAC system with the maximum number of invalid
57359 + passwords. The higher the number, the harder it will be to brute-force
57360 + a password.
57361 +
57362 +endmenu
57363 +menu "Filesystem Protections"
57364 +depends on GRKERNSEC
57365 +
57366 +config GRKERNSEC_PROC
57367 + bool "Proc restrictions"
57368 + default y if GRKERNSEC_CONFIG_AUTO
57369 + help
57370 + If you say Y here, the permissions of the /proc filesystem
57371 + will be altered to enhance system security and privacy. You MUST
57372 + choose either a user only restriction or a user and group restriction.
57373 + Depending upon the option you choose, you can either restrict users to
57374 + see only the processes they themselves run, or choose a group that can
57375 + view all processes and files normally restricted to root if you choose
57376 + the "restrict to user only" option. NOTE: If you're running identd or
57377 + ntpd as a non-root user, you will have to run it as the group you
57378 + specify here.
57379 +
57380 +config GRKERNSEC_PROC_USER
57381 + bool "Restrict /proc to user only"
57382 + depends on GRKERNSEC_PROC
57383 + help
57384 + If you say Y here, non-root users will only be able to view their own
57385 + processes, and restricts them from viewing network-related information,
57386 + and viewing kernel symbol and module information.
57387 +
57388 +config GRKERNSEC_PROC_USERGROUP
57389 + bool "Allow special group"
57390 + default y if GRKERNSEC_CONFIG_AUTO
57391 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57392 + help
57393 + If you say Y here, you will be able to select a group that will be
57394 + able to view all processes and network-related information. If you've
57395 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57396 + remain hidden. This option is useful if you want to run identd as
57397 + a non-root user. The group you select may also be chosen at boot time
57398 + via "grsec_proc_gid=" on the kernel commandline.
57399 +
57400 +config GRKERNSEC_PROC_GID
57401 + int "GID for special group"
57402 + depends on GRKERNSEC_PROC_USERGROUP
57403 + default 1001
57404 +
57405 +config GRKERNSEC_PROC_ADD
57406 + bool "Additional restrictions"
57407 + default y if GRKERNSEC_CONFIG_AUTO
57408 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57409 + help
57410 + If you say Y here, additional restrictions will be placed on
57411 + /proc that keep normal users from viewing device information and
57412 + slabinfo information that could be useful for exploits.
57413 +
57414 +config GRKERNSEC_LINK
57415 + bool "Linking restrictions"
57416 + default y if GRKERNSEC_CONFIG_AUTO
57417 + help
57418 + If you say Y here, /tmp race exploits will be prevented, since users
57419 + will no longer be able to follow symlinks owned by other users in
57420 + world-writable +t directories (e.g. /tmp), unless the owner of the
57421 + symlink is the owner of the directory. users will also not be
57422 + able to hardlink to files they do not own. If the sysctl option is
57423 + enabled, a sysctl option with name "linking_restrictions" is created.
57424 +
57425 +config GRKERNSEC_SYMLINKOWN
57426 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57427 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57428 + help
57429 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57430 + that prevents it from being used as a security feature. As Apache
57431 + verifies the symlink by performing a stat() against the target of
57432 + the symlink before it is followed, an attacker can setup a symlink
57433 + to point to a same-owned file, then replace the symlink with one
57434 + that targets another user's file just after Apache "validates" the
57435 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57436 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57437 + will be in place for the group you specify. If the sysctl option
57438 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57439 + created.
57440 +
57441 +config GRKERNSEC_SYMLINKOWN_GID
57442 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57443 + depends on GRKERNSEC_SYMLINKOWN
57444 + default 1006
57445 + help
57446 + Setting this GID determines what group kernel-enforced
57447 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57448 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57449 +
57450 +config GRKERNSEC_FIFO
57451 + bool "FIFO restrictions"
57452 + default y if GRKERNSEC_CONFIG_AUTO
57453 + help
57454 + If you say Y here, users will not be able to write to FIFOs they don't
57455 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57456 + the FIFO is the same owner of the directory it's held in. If the sysctl
57457 + option is enabled, a sysctl option with name "fifo_restrictions" is
57458 + created.
57459 +
57460 +config GRKERNSEC_SYSFS_RESTRICT
57461 + bool "Sysfs/debugfs restriction"
57462 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57463 + depends on SYSFS
57464 + help
57465 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57466 + any filesystem normally mounted under it (e.g. debugfs) will be
57467 + mostly accessible only by root. These filesystems generally provide access
57468 + to hardware and debug information that isn't appropriate for unprivileged
57469 + users of the system. Sysfs and debugfs have also become a large source
57470 + of new vulnerabilities, ranging from infoleaks to local compromise.
57471 + There has been very little oversight with an eye toward security involved
57472 + in adding new exporters of information to these filesystems, so their
57473 + use is discouraged.
57474 + For reasons of compatibility, a few directories have been whitelisted
57475 + for access by non-root users:
57476 + /sys/fs/selinux
57477 + /sys/fs/fuse
57478 + /sys/devices/system/cpu
57479 +
57480 +config GRKERNSEC_ROFS
57481 + bool "Runtime read-only mount protection"
57482 + help
57483 + If you say Y here, a sysctl option with name "romount_protect" will
57484 + be created. By setting this option to 1 at runtime, filesystems
57485 + will be protected in the following ways:
57486 + * No new writable mounts will be allowed
57487 + * Existing read-only mounts won't be able to be remounted read/write
57488 + * Write operations will be denied on all block devices
57489 + This option acts independently of grsec_lock: once it is set to 1,
57490 + it cannot be turned off. Therefore, please be mindful of the resulting
57491 + behavior if this option is enabled in an init script on a read-only
57492 + filesystem. This feature is mainly intended for secure embedded systems.
57493 +
57494 +config GRKERNSEC_DEVICE_SIDECHANNEL
57495 + bool "Eliminate stat/notify-based device sidechannels"
57496 + default y if GRKERNSEC_CONFIG_AUTO
57497 + help
57498 + If you say Y here, timing analyses on block or character
57499 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57500 + will be thwarted for unprivileged users. If a process without
57501 + CAP_MKNOD stats such a device, the last access and last modify times
57502 + will match the device's create time. No access or modify events
57503 + will be triggered through inotify/dnotify/fanotify for such devices.
57504 + This feature will prevent attacks that may at a minimum
57505 + allow an attacker to determine the administrator's password length.
57506 +
57507 +config GRKERNSEC_CHROOT
57508 + bool "Chroot jail restrictions"
57509 + default y if GRKERNSEC_CONFIG_AUTO
57510 + help
57511 + If you say Y here, you will be able to choose several options that will
57512 + make breaking out of a chrooted jail much more difficult. If you
57513 + encounter no software incompatibilities with the following options, it
57514 + is recommended that you enable each one.
57515 +
57516 +config GRKERNSEC_CHROOT_MOUNT
57517 + bool "Deny mounts"
57518 + default y if GRKERNSEC_CONFIG_AUTO
57519 + depends on GRKERNSEC_CHROOT
57520 + help
57521 + If you say Y here, processes inside a chroot will not be able to
57522 + mount or remount filesystems. If the sysctl option is enabled, a
57523 + sysctl option with name "chroot_deny_mount" is created.
57524 +
57525 +config GRKERNSEC_CHROOT_DOUBLE
57526 + bool "Deny double-chroots"
57527 + default y if GRKERNSEC_CONFIG_AUTO
57528 + depends on GRKERNSEC_CHROOT
57529 + help
57530 + If you say Y here, processes inside a chroot will not be able to chroot
57531 + again outside the chroot. This is a widely used method of breaking
57532 + out of a chroot jail and should not be allowed. If the sysctl
57533 + option is enabled, a sysctl option with name
57534 + "chroot_deny_chroot" is created.
57535 +
57536 +config GRKERNSEC_CHROOT_PIVOT
57537 + bool "Deny pivot_root in chroot"
57538 + default y if GRKERNSEC_CONFIG_AUTO
57539 + depends on GRKERNSEC_CHROOT
57540 + help
57541 + If you say Y here, processes inside a chroot will not be able to use
57542 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57543 + works similar to chroot in that it changes the root filesystem. This
57544 + function could be misused in a chrooted process to attempt to break out
57545 + of the chroot, and therefore should not be allowed. If the sysctl
57546 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57547 + created.
57548 +
57549 +config GRKERNSEC_CHROOT_CHDIR
57550 + bool "Enforce chdir(\"/\") on all chroots"
57551 + default y if GRKERNSEC_CONFIG_AUTO
57552 + depends on GRKERNSEC_CHROOT
57553 + help
57554 + If you say Y here, the current working directory of all newly-chrooted
57555 + applications will be set to the the root directory of the chroot.
57556 + The man page on chroot(2) states:
57557 + Note that this call does not change the current working
57558 + directory, so that `.' can be outside the tree rooted at
57559 + `/'. In particular, the super-user can escape from a
57560 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57561 +
57562 + It is recommended that you say Y here, since it's not known to break
57563 + any software. If the sysctl option is enabled, a sysctl option with
57564 + name "chroot_enforce_chdir" is created.
57565 +
57566 +config GRKERNSEC_CHROOT_CHMOD
57567 + bool "Deny (f)chmod +s"
57568 + default y if GRKERNSEC_CONFIG_AUTO
57569 + depends on GRKERNSEC_CHROOT
57570 + help
57571 + If you say Y here, processes inside a chroot will not be able to chmod
57572 + or fchmod files to make them have suid or sgid bits. This protects
57573 + against another published method of breaking a chroot. If the sysctl
57574 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57575 + created.
57576 +
57577 +config GRKERNSEC_CHROOT_FCHDIR
57578 + bool "Deny fchdir out of chroot"
57579 + default y if GRKERNSEC_CONFIG_AUTO
57580 + depends on GRKERNSEC_CHROOT
57581 + help
57582 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57583 + to a file descriptor of the chrooting process that points to a directory
57584 + outside the filesystem will be stopped. If the sysctl option
57585 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57586 +
57587 +config GRKERNSEC_CHROOT_MKNOD
57588 + bool "Deny mknod"
57589 + default y if GRKERNSEC_CONFIG_AUTO
57590 + depends on GRKERNSEC_CHROOT
57591 + help
57592 + If you say Y here, processes inside a chroot will not be allowed to
57593 + mknod. The problem with using mknod inside a chroot is that it
57594 + would allow an attacker to create a device entry that is the same
57595 + as one on the physical root of your system, which could range from
57596 + anything from the console device to a device for your harddrive (which
57597 + they could then use to wipe the drive or steal data). It is recommended
57598 + that you say Y here, unless you run into software incompatibilities.
57599 + If the sysctl option is enabled, a sysctl option with name
57600 + "chroot_deny_mknod" is created.
57601 +
57602 +config GRKERNSEC_CHROOT_SHMAT
57603 + bool "Deny shmat() out of chroot"
57604 + default y if GRKERNSEC_CONFIG_AUTO
57605 + depends on GRKERNSEC_CHROOT
57606 + help
57607 + If you say Y here, processes inside a chroot will not be able to attach
57608 + to shared memory segments that were created outside of the chroot jail.
57609 + It is recommended that you say Y here. If the sysctl option is enabled,
57610 + a sysctl option with name "chroot_deny_shmat" is created.
57611 +
57612 +config GRKERNSEC_CHROOT_UNIX
57613 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57614 + default y if GRKERNSEC_CONFIG_AUTO
57615 + depends on GRKERNSEC_CHROOT
57616 + help
57617 + If you say Y here, processes inside a chroot will not be able to
57618 + connect to abstract (meaning not belonging to a filesystem) Unix
57619 + domain sockets that were bound outside of a chroot. It is recommended
57620 + that you say Y here. If the sysctl option is enabled, a sysctl option
57621 + with name "chroot_deny_unix" is created.
57622 +
57623 +config GRKERNSEC_CHROOT_FINDTASK
57624 + bool "Protect outside processes"
57625 + default y if GRKERNSEC_CONFIG_AUTO
57626 + depends on GRKERNSEC_CHROOT
57627 + help
57628 + If you say Y here, processes inside a chroot will not be able to
57629 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57630 + getsid, or view any process outside of the chroot. If the sysctl
57631 + option is enabled, a sysctl option with name "chroot_findtask" is
57632 + created.
57633 +
57634 +config GRKERNSEC_CHROOT_NICE
57635 + bool "Restrict priority changes"
57636 + default y if GRKERNSEC_CONFIG_AUTO
57637 + depends on GRKERNSEC_CHROOT
57638 + help
57639 + If you say Y here, processes inside a chroot will not be able to raise
57640 + the priority of processes in the chroot, or alter the priority of
57641 + processes outside the chroot. This provides more security than simply
57642 + removing CAP_SYS_NICE from the process' capability set. If the
57643 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57644 + is created.
57645 +
57646 +config GRKERNSEC_CHROOT_SYSCTL
57647 + bool "Deny sysctl writes"
57648 + default y if GRKERNSEC_CONFIG_AUTO
57649 + depends on GRKERNSEC_CHROOT
57650 + help
57651 + If you say Y here, an attacker in a chroot will not be able to
57652 + write to sysctl entries, either by sysctl(2) or through a /proc
57653 + interface. It is strongly recommended that you say Y here. If the
57654 + sysctl option is enabled, a sysctl option with name
57655 + "chroot_deny_sysctl" is created.
57656 +
57657 +config GRKERNSEC_CHROOT_CAPS
57658 + bool "Capability restrictions"
57659 + default y if GRKERNSEC_CONFIG_AUTO
57660 + depends on GRKERNSEC_CHROOT
57661 + help
57662 + If you say Y here, the capabilities on all processes within a
57663 + chroot jail will be lowered to stop module insertion, raw i/o,
57664 + system and net admin tasks, rebooting the system, modifying immutable
57665 + files, modifying IPC owned by another, and changing the system time.
57666 + This is left an option because it can break some apps. Disable this
57667 + if your chrooted apps are having problems performing those kinds of
57668 + tasks. If the sysctl option is enabled, a sysctl option with
57669 + name "chroot_caps" is created.
57670 +
57671 +config GRKERNSEC_CHROOT_INITRD
57672 + bool "Exempt initrd tasks from restrictions"
57673 + default y if GRKERNSEC_CONFIG_AUTO
57674 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57675 + help
57676 + If you say Y here, tasks started prior to init will be exempted from
57677 + grsecurity's chroot restrictions. This option is mainly meant to
57678 + resolve Plymouth's performing privileged operations unnecessarily
57679 + in a chroot.
57680 +
57681 +endmenu
57682 +menu "Kernel Auditing"
57683 +depends on GRKERNSEC
57684 +
57685 +config GRKERNSEC_AUDIT_GROUP
57686 + bool "Single group for auditing"
57687 + help
57688 + If you say Y here, the exec and chdir logging features will only operate
57689 + on a group you specify. This option is recommended if you only want to
57690 + watch certain users instead of having a large amount of logs from the
57691 + entire system. If the sysctl option is enabled, a sysctl option with
57692 + name "audit_group" is created.
57693 +
57694 +config GRKERNSEC_AUDIT_GID
57695 + int "GID for auditing"
57696 + depends on GRKERNSEC_AUDIT_GROUP
57697 + default 1007
57698 +
57699 +config GRKERNSEC_EXECLOG
57700 + bool "Exec logging"
57701 + help
57702 + If you say Y here, all execve() calls will be logged (since the
57703 + other exec*() calls are frontends to execve(), all execution
57704 + will be logged). Useful for shell-servers that like to keep track
57705 + of their users. If the sysctl option is enabled, a sysctl option with
57706 + name "exec_logging" is created.
57707 + WARNING: This option when enabled will produce a LOT of logs, especially
57708 + on an active system.
57709 +
57710 +config GRKERNSEC_RESLOG
57711 + bool "Resource logging"
57712 + default y if GRKERNSEC_CONFIG_AUTO
57713 + help
57714 + If you say Y here, all attempts to overstep resource limits will
57715 + be logged with the resource name, the requested size, and the current
57716 + limit. It is highly recommended that you say Y here. If the sysctl
57717 + option is enabled, a sysctl option with name "resource_logging" is
57718 + created. If the RBAC system is enabled, the sysctl value is ignored.
57719 +
57720 +config GRKERNSEC_CHROOT_EXECLOG
57721 + bool "Log execs within chroot"
57722 + help
57723 + If you say Y here, all executions inside a chroot jail will be logged
57724 + to syslog. This can cause a large amount of logs if certain
57725 + applications (eg. djb's daemontools) are installed on the system, and
57726 + is therefore left as an option. If the sysctl option is enabled, a
57727 + sysctl option with name "chroot_execlog" is created.
57728 +
57729 +config GRKERNSEC_AUDIT_PTRACE
57730 + bool "Ptrace logging"
57731 + help
57732 + If you say Y here, all attempts to attach to a process via ptrace
57733 + will be logged. If the sysctl option is enabled, a sysctl option
57734 + with name "audit_ptrace" is created.
57735 +
57736 +config GRKERNSEC_AUDIT_CHDIR
57737 + bool "Chdir logging"
57738 + help
57739 + If you say Y here, all chdir() calls will be logged. If the sysctl
57740 + option is enabled, a sysctl option with name "audit_chdir" is created.
57741 +
57742 +config GRKERNSEC_AUDIT_MOUNT
57743 + bool "(Un)Mount logging"
57744 + help
57745 + If you say Y here, all mounts and unmounts will be logged. If the
57746 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57747 + created.
57748 +
57749 +config GRKERNSEC_SIGNAL
57750 + bool "Signal logging"
57751 + default y if GRKERNSEC_CONFIG_AUTO
57752 + help
57753 + If you say Y here, certain important signals will be logged, such as
57754 + SIGSEGV, which will as a result inform you of when a error in a program
57755 + occurred, which in some cases could mean a possible exploit attempt.
57756 + If the sysctl option is enabled, a sysctl option with name
57757 + "signal_logging" is created.
57758 +
57759 +config GRKERNSEC_FORKFAIL
57760 + bool "Fork failure logging"
57761 + help
57762 + If you say Y here, all failed fork() attempts will be logged.
57763 + This could suggest a fork bomb, or someone attempting to overstep
57764 + their process limit. If the sysctl option is enabled, a sysctl option
57765 + with name "forkfail_logging" is created.
57766 +
57767 +config GRKERNSEC_TIME
57768 + bool "Time change logging"
57769 + default y if GRKERNSEC_CONFIG_AUTO
57770 + help
57771 + If you say Y here, any changes of the system clock will be logged.
57772 + If the sysctl option is enabled, a sysctl option with name
57773 + "timechange_logging" is created.
57774 +
57775 +config GRKERNSEC_PROC_IPADDR
57776 + bool "/proc/<pid>/ipaddr support"
57777 + default y if GRKERNSEC_CONFIG_AUTO
57778 + help
57779 + If you say Y here, a new entry will be added to each /proc/<pid>
57780 + directory that contains the IP address of the person using the task.
57781 + The IP is carried across local TCP and AF_UNIX stream sockets.
57782 + This information can be useful for IDS/IPSes to perform remote response
57783 + to a local attack. The entry is readable by only the owner of the
57784 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57785 + the RBAC system), and thus does not create privacy concerns.
57786 +
57787 +config GRKERNSEC_RWXMAP_LOG
57788 + bool 'Denied RWX mmap/mprotect logging'
57789 + default y if GRKERNSEC_CONFIG_AUTO
57790 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57791 + help
57792 + If you say Y here, calls to mmap() and mprotect() with explicit
57793 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57794 + denied by the PAX_MPROTECT feature. If the sysctl option is
57795 + enabled, a sysctl option with name "rwxmap_logging" is created.
57796 +
57797 +config GRKERNSEC_AUDIT_TEXTREL
57798 + bool 'ELF text relocations logging (READ HELP)'
57799 + depends on PAX_MPROTECT
57800 + help
57801 + If you say Y here, text relocations will be logged with the filename
57802 + of the offending library or binary. The purpose of the feature is
57803 + to help Linux distribution developers get rid of libraries and
57804 + binaries that need text relocations which hinder the future progress
57805 + of PaX. Only Linux distribution developers should say Y here, and
57806 + never on a production machine, as this option creates an information
57807 + leak that could aid an attacker in defeating the randomization of
57808 + a single memory region. If the sysctl option is enabled, a sysctl
57809 + option with name "audit_textrel" is created.
57810 +
57811 +endmenu
57812 +
57813 +menu "Executable Protections"
57814 +depends on GRKERNSEC
57815 +
57816 +config GRKERNSEC_DMESG
57817 + bool "Dmesg(8) restriction"
57818 + default y if GRKERNSEC_CONFIG_AUTO
57819 + help
57820 + If you say Y here, non-root users will not be able to use dmesg(8)
57821 + to view the contents of the kernel's circular log buffer.
57822 + The kernel's log buffer often contains kernel addresses and other
57823 + identifying information useful to an attacker in fingerprinting a
57824 + system for a targeted exploit.
57825 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57826 + created.
57827 +
57828 +config GRKERNSEC_HARDEN_PTRACE
57829 + bool "Deter ptrace-based process snooping"
57830 + default y if GRKERNSEC_CONFIG_AUTO
57831 + help
57832 + If you say Y here, TTY sniffers and other malicious monitoring
57833 + programs implemented through ptrace will be defeated. If you
57834 + have been using the RBAC system, this option has already been
57835 + enabled for several years for all users, with the ability to make
57836 + fine-grained exceptions.
57837 +
57838 + This option only affects the ability of non-root users to ptrace
57839 + processes that are not a descendent of the ptracing process.
57840 + This means that strace ./binary and gdb ./binary will still work,
57841 + but attaching to arbitrary processes will not. If the sysctl
57842 + option is enabled, a sysctl option with name "harden_ptrace" is
57843 + created.
57844 +
57845 +config GRKERNSEC_PTRACE_READEXEC
57846 + bool "Require read access to ptrace sensitive binaries"
57847 + default y if GRKERNSEC_CONFIG_AUTO
57848 + help
57849 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57850 + binaries. This option is useful in environments that
57851 + remove the read bits (e.g. file mode 4711) from suid binaries to
57852 + prevent infoleaking of their contents. This option adds
57853 + consistency to the use of that file mode, as the binary could normally
57854 + be read out when run without privileges while ptracing.
57855 +
57856 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57857 + is created.
57858 +
57859 +config GRKERNSEC_SETXID
57860 + bool "Enforce consistent multithreaded privileges"
57861 + default y if GRKERNSEC_CONFIG_AUTO
57862 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57863 + help
57864 + If you say Y here, a change from a root uid to a non-root uid
57865 + in a multithreaded application will cause the resulting uids,
57866 + gids, supplementary groups, and capabilities in that thread
57867 + to be propagated to the other threads of the process. In most
57868 + cases this is unnecessary, as glibc will emulate this behavior
57869 + on behalf of the application. Other libcs do not act in the
57870 + same way, allowing the other threads of the process to continue
57871 + running with root privileges. If the sysctl option is enabled,
57872 + a sysctl option with name "consistent_setxid" is created.
57873 +
57874 +config GRKERNSEC_TPE
57875 + bool "Trusted Path Execution (TPE)"
57876 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57877 + help
57878 + If you say Y here, you will be able to choose a gid to add to the
57879 + supplementary groups of users you want to mark as "untrusted."
57880 + These users will not be able to execute any files that are not in
57881 + root-owned directories writable only by root. If the sysctl option
57882 + is enabled, a sysctl option with name "tpe" is created.
57883 +
57884 +config GRKERNSEC_TPE_ALL
57885 + bool "Partially restrict all non-root users"
57886 + depends on GRKERNSEC_TPE
57887 + help
57888 + If you say Y here, all non-root users will be covered under
57889 + a weaker TPE restriction. This is separate from, and in addition to,
57890 + the main TPE options that you have selected elsewhere. Thus, if a
57891 + "trusted" GID is chosen, this restriction applies to even that GID.
57892 + Under this restriction, all non-root users will only be allowed to
57893 + execute files in directories they own that are not group or
57894 + world-writable, or in directories owned by root and writable only by
57895 + root. If the sysctl option is enabled, a sysctl option with name
57896 + "tpe_restrict_all" is created.
57897 +
57898 +config GRKERNSEC_TPE_INVERT
57899 + bool "Invert GID option"
57900 + depends on GRKERNSEC_TPE
57901 + help
57902 + If you say Y here, the group you specify in the TPE configuration will
57903 + decide what group TPE restrictions will be *disabled* for. This
57904 + option is useful if you want TPE restrictions to be applied to most
57905 + users on the system. If the sysctl option is enabled, a sysctl option
57906 + with name "tpe_invert" is created. Unlike other sysctl options, this
57907 + entry will default to on for backward-compatibility.
57908 +
57909 +config GRKERNSEC_TPE_GID
57910 + int
57911 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57912 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57913 +
57914 +config GRKERNSEC_TPE_UNTRUSTED_GID
57915 + int "GID for TPE-untrusted users"
57916 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57917 + default 1005
57918 + help
57919 + Setting this GID determines what group TPE restrictions will be
57920 + *enabled* for. If the sysctl option is enabled, a sysctl option
57921 + with name "tpe_gid" is created.
57922 +
57923 +config GRKERNSEC_TPE_TRUSTED_GID
57924 + int "GID for TPE-trusted users"
57925 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57926 + default 1005
57927 + help
57928 + Setting this GID determines what group TPE restrictions will be
57929 + *disabled* for. If the sysctl option is enabled, a sysctl option
57930 + with name "tpe_gid" is created.
57931 +
57932 +endmenu
57933 +menu "Network Protections"
57934 +depends on GRKERNSEC
57935 +
57936 +config GRKERNSEC_RANDNET
57937 + bool "Larger entropy pools"
57938 + default y if GRKERNSEC_CONFIG_AUTO
57939 + help
57940 + If you say Y here, the entropy pools used for many features of Linux
57941 + and grsecurity will be doubled in size. Since several grsecurity
57942 + features use additional randomness, it is recommended that you say Y
57943 + here. Saying Y here has a similar effect as modifying
57944 + /proc/sys/kernel/random/poolsize.
57945 +
57946 +config GRKERNSEC_BLACKHOLE
57947 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57948 + default y if GRKERNSEC_CONFIG_AUTO
57949 + depends on NET
57950 + help
57951 + If you say Y here, neither TCP resets nor ICMP
57952 + destination-unreachable packets will be sent in response to packets
57953 + sent to ports for which no associated listening process exists.
57954 + This feature supports both IPV4 and IPV6 and exempts the
57955 + loopback interface from blackholing. Enabling this feature
57956 + makes a host more resilient to DoS attacks and reduces network
57957 + visibility against scanners.
57958 +
57959 + The blackhole feature as-implemented is equivalent to the FreeBSD
57960 + blackhole feature, as it prevents RST responses to all packets, not
57961 + just SYNs. Under most application behavior this causes no
57962 + problems, but applications (like haproxy) may not close certain
57963 + connections in a way that cleanly terminates them on the remote
57964 + end, leaving the remote host in LAST_ACK state. Because of this
57965 + side-effect and to prevent intentional LAST_ACK DoSes, this
57966 + feature also adds automatic mitigation against such attacks.
57967 + The mitigation drastically reduces the amount of time a socket
57968 + can spend in LAST_ACK state. If you're using haproxy and not
57969 + all servers it connects to have this option enabled, consider
57970 + disabling this feature on the haproxy host.
57971 +
57972 + If the sysctl option is enabled, two sysctl options with names
57973 + "ip_blackhole" and "lastack_retries" will be created.
57974 + While "ip_blackhole" takes the standard zero/non-zero on/off
57975 + toggle, "lastack_retries" uses the same kinds of values as
57976 + "tcp_retries1" and "tcp_retries2". The default value of 4
57977 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57978 + state.
57979 +
57980 +config GRKERNSEC_NO_SIMULT_CONNECT
57981 + bool "Disable TCP Simultaneous Connect"
57982 + default y if GRKERNSEC_CONFIG_AUTO
57983 + depends on NET
57984 + help
57985 + If you say Y here, a feature by Willy Tarreau will be enabled that
57986 + removes a weakness in Linux's strict implementation of TCP that
57987 + allows two clients to connect to each other without either entering
57988 + a listening state. The weakness allows an attacker to easily prevent
57989 + a client from connecting to a known server provided the source port
57990 + for the connection is guessed correctly.
57991 +
57992 + As the weakness could be used to prevent an antivirus or IPS from
57993 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57994 + it should be eliminated by enabling this option. Though Linux is
57995 + one of few operating systems supporting simultaneous connect, it
57996 + has no legitimate use in practice and is rarely supported by firewalls.
57997 +
57998 +config GRKERNSEC_SOCKET
57999 + bool "Socket restrictions"
58000 + depends on NET
58001 + help
58002 + If you say Y here, you will be able to choose from several options.
58003 + If you assign a GID on your system and add it to the supplementary
58004 + groups of users you want to restrict socket access to, this patch
58005 + will perform up to three things, based on the option(s) you choose.
58006 +
58007 +config GRKERNSEC_SOCKET_ALL
58008 + bool "Deny any sockets to group"
58009 + depends on GRKERNSEC_SOCKET
58010 + help
58011 + If you say Y here, you will be able to choose a GID of whose users will
58012 + be unable to connect to other hosts from your machine or run server
58013 + applications from your machine. If the sysctl option is enabled, a
58014 + sysctl option with name "socket_all" is created.
58015 +
58016 +config GRKERNSEC_SOCKET_ALL_GID
58017 + int "GID to deny all sockets for"
58018 + depends on GRKERNSEC_SOCKET_ALL
58019 + default 1004
58020 + help
58021 + Here you can choose the GID to disable socket access for. Remember to
58022 + add the users you want socket access disabled for to the GID
58023 + specified here. If the sysctl option is enabled, a sysctl option
58024 + with name "socket_all_gid" is created.
58025 +
58026 +config GRKERNSEC_SOCKET_CLIENT
58027 + bool "Deny client sockets to group"
58028 + depends on GRKERNSEC_SOCKET
58029 + help
58030 + If you say Y here, you will be able to choose a GID of whose users will
58031 + be unable to connect to other hosts from your machine, but will be
58032 + able to run servers. If this option is enabled, all users in the group
58033 + you specify will have to use passive mode when initiating ftp transfers
58034 + from the shell on your machine. If the sysctl option is enabled, a
58035 + sysctl option with name "socket_client" is created.
58036 +
58037 +config GRKERNSEC_SOCKET_CLIENT_GID
58038 + int "GID to deny client sockets for"
58039 + depends on GRKERNSEC_SOCKET_CLIENT
58040 + default 1003
58041 + help
58042 + Here you can choose the GID to disable client socket access for.
58043 + Remember to add the users you want client socket access disabled for to
58044 + the GID specified here. If the sysctl option is enabled, a sysctl
58045 + option with name "socket_client_gid" is created.
58046 +
58047 +config GRKERNSEC_SOCKET_SERVER
58048 + bool "Deny server sockets to group"
58049 + depends on GRKERNSEC_SOCKET
58050 + help
58051 + If you say Y here, you will be able to choose a GID of whose users will
58052 + be unable to run server applications from your machine. If the sysctl
58053 + option is enabled, a sysctl option with name "socket_server" is created.
58054 +
58055 +config GRKERNSEC_SOCKET_SERVER_GID
58056 + int "GID to deny server sockets for"
58057 + depends on GRKERNSEC_SOCKET_SERVER
58058 + default 1002
58059 + help
58060 + Here you can choose the GID to disable server socket access for.
58061 + Remember to add the users you want server socket access disabled for to
58062 + the GID specified here. If the sysctl option is enabled, a sysctl
58063 + option with name "socket_server_gid" is created.
58064 +
58065 +endmenu
58066 +menu "Sysctl Support"
58067 +depends on GRKERNSEC && SYSCTL
58068 +
58069 +config GRKERNSEC_SYSCTL
58070 + bool "Sysctl support"
58071 + default y if GRKERNSEC_CONFIG_AUTO
58072 + help
58073 + If you say Y here, you will be able to change the options that
58074 + grsecurity runs with at bootup, without having to recompile your
58075 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58076 + to enable (1) or disable (0) various features. All the sysctl entries
58077 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58078 + All features enabled in the kernel configuration are disabled at boot
58079 + if you do not say Y to the "Turn on features by default" option.
58080 + All options should be set at startup, and the grsec_lock entry should
58081 + be set to a non-zero value after all the options are set.
58082 + *THIS IS EXTREMELY IMPORTANT*
58083 +
58084 +config GRKERNSEC_SYSCTL_DISTRO
58085 + bool "Extra sysctl support for distro makers (READ HELP)"
58086 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58087 + help
58088 + If you say Y here, additional sysctl options will be created
58089 + for features that affect processes running as root. Therefore,
58090 + it is critical when using this option that the grsec_lock entry be
58091 + enabled after boot. Only distros with prebuilt kernel packages
58092 + with this option enabled that can ensure grsec_lock is enabled
58093 + after boot should use this option.
58094 + *Failure to set grsec_lock after boot makes all grsec features
58095 + this option covers useless*
58096 +
58097 + Currently this option creates the following sysctl entries:
58098 + "Disable Privileged I/O": "disable_priv_io"
58099 +
58100 +config GRKERNSEC_SYSCTL_ON
58101 + bool "Turn on features by default"
58102 + default y if GRKERNSEC_CONFIG_AUTO
58103 + depends on GRKERNSEC_SYSCTL
58104 + help
58105 + If you say Y here, instead of having all features enabled in the
58106 + kernel configuration disabled at boot time, the features will be
58107 + enabled at boot time. It is recommended you say Y here unless
58108 + there is some reason you would want all sysctl-tunable features to
58109 + be disabled by default. As mentioned elsewhere, it is important
58110 + to enable the grsec_lock entry once you have finished modifying
58111 + the sysctl entries.
58112 +
58113 +endmenu
58114 +menu "Logging Options"
58115 +depends on GRKERNSEC
58116 +
58117 +config GRKERNSEC_FLOODTIME
58118 + int "Seconds in between log messages (minimum)"
58119 + default 10
58120 + help
58121 + This option allows you to enforce the number of seconds between
58122 + grsecurity log messages. The default should be suitable for most
58123 + people, however, if you choose to change it, choose a value small enough
58124 + to allow informative logs to be produced, but large enough to
58125 + prevent flooding.
58126 +
58127 +config GRKERNSEC_FLOODBURST
58128 + int "Number of messages in a burst (maximum)"
58129 + default 6
58130 + help
58131 + This option allows you to choose the maximum number of messages allowed
58132 + within the flood time interval you chose in a separate option. The
58133 + default should be suitable for most people, however if you find that
58134 + many of your logs are being interpreted as flooding, you may want to
58135 + raise this value.
58136 +
58137 +endmenu
58138 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58139 new file mode 100644
58140 index 0000000..1b9afa9
58141 --- /dev/null
58142 +++ b/grsecurity/Makefile
58143 @@ -0,0 +1,38 @@
58144 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58145 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58146 +# into an RBAC system
58147 +#
58148 +# All code in this directory and various hooks inserted throughout the kernel
58149 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58150 +# under the GPL v2 or higher
58151 +
58152 +KBUILD_CFLAGS += -Werror
58153 +
58154 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58155 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58156 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58157 +
58158 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58159 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58160 + gracl_learn.o grsec_log.o
58161 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58162 +
58163 +ifdef CONFIG_NET
58164 +obj-y += grsec_sock.o
58165 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58166 +endif
58167 +
58168 +ifndef CONFIG_GRKERNSEC
58169 +obj-y += grsec_disabled.o
58170 +endif
58171 +
58172 +ifdef CONFIG_GRKERNSEC_HIDESYM
58173 +extra-y := grsec_hidesym.o
58174 +$(obj)/grsec_hidesym.o:
58175 + @-chmod -f 500 /boot
58176 + @-chmod -f 500 /lib/modules
58177 + @-chmod -f 500 /lib64/modules
58178 + @-chmod -f 500 /lib32/modules
58179 + @-chmod -f 700 .
58180 + @echo ' grsec: protected kernel image paths'
58181 +endif
58182 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58183 new file mode 100644
58184 index 0000000..b306b36
58185 --- /dev/null
58186 +++ b/grsecurity/gracl.c
58187 @@ -0,0 +1,4071 @@
58188 +#include <linux/kernel.h>
58189 +#include <linux/module.h>
58190 +#include <linux/sched.h>
58191 +#include <linux/mm.h>
58192 +#include <linux/file.h>
58193 +#include <linux/fs.h>
58194 +#include <linux/namei.h>
58195 +#include <linux/mount.h>
58196 +#include <linux/tty.h>
58197 +#include <linux/proc_fs.h>
58198 +#include <linux/lglock.h>
58199 +#include <linux/slab.h>
58200 +#include <linux/vmalloc.h>
58201 +#include <linux/types.h>
58202 +#include <linux/sysctl.h>
58203 +#include <linux/netdevice.h>
58204 +#include <linux/ptrace.h>
58205 +#include <linux/gracl.h>
58206 +#include <linux/gralloc.h>
58207 +#include <linux/security.h>
58208 +#include <linux/grinternal.h>
58209 +#include <linux/pid_namespace.h>
58210 +#include <linux/stop_machine.h>
58211 +#include <linux/fdtable.h>
58212 +#include <linux/percpu.h>
58213 +#include <linux/lglock.h>
58214 +#include <linux/hugetlb.h>
58215 +#include <linux/posix-timers.h>
58216 +#include "../fs/mount.h"
58217 +
58218 +#include <asm/uaccess.h>
58219 +#include <asm/errno.h>
58220 +#include <asm/mman.h>
58221 +
58222 +extern struct lglock vfsmount_lock;
58223 +
58224 +static struct acl_role_db acl_role_set;
58225 +static struct name_db name_set;
58226 +static struct inodev_db inodev_set;
58227 +
58228 +/* for keeping track of userspace pointers used for subjects, so we
58229 + can share references in the kernel as well
58230 +*/
58231 +
58232 +static struct path real_root;
58233 +
58234 +static struct acl_subj_map_db subj_map_set;
58235 +
58236 +static struct acl_role_label *default_role;
58237 +
58238 +static struct acl_role_label *role_list;
58239 +
58240 +static u16 acl_sp_role_value;
58241 +
58242 +extern char *gr_shared_page[4];
58243 +static DEFINE_MUTEX(gr_dev_mutex);
58244 +DEFINE_RWLOCK(gr_inode_lock);
58245 +
58246 +struct gr_arg *gr_usermode;
58247 +
58248 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58249 +
58250 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58251 +extern void gr_clear_learn_entries(void);
58252 +
58253 +unsigned char *gr_system_salt;
58254 +unsigned char *gr_system_sum;
58255 +
58256 +static struct sprole_pw **acl_special_roles = NULL;
58257 +static __u16 num_sprole_pws = 0;
58258 +
58259 +static struct acl_role_label *kernel_role = NULL;
58260 +
58261 +static unsigned int gr_auth_attempts = 0;
58262 +static unsigned long gr_auth_expires = 0UL;
58263 +
58264 +#ifdef CONFIG_NET
58265 +extern struct vfsmount *sock_mnt;
58266 +#endif
58267 +
58268 +extern struct vfsmount *pipe_mnt;
58269 +extern struct vfsmount *shm_mnt;
58270 +
58271 +#ifdef CONFIG_HUGETLBFS
58272 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58273 +#endif
58274 +
58275 +static struct acl_object_label *fakefs_obj_rw;
58276 +static struct acl_object_label *fakefs_obj_rwx;
58277 +
58278 +extern int gr_init_uidset(void);
58279 +extern void gr_free_uidset(void);
58280 +extern void gr_remove_uid(uid_t uid);
58281 +extern int gr_find_uid(uid_t uid);
58282 +
58283 +__inline__ int
58284 +gr_acl_is_enabled(void)
58285 +{
58286 + return (gr_status & GR_READY);
58287 +}
58288 +
58289 +#ifdef CONFIG_BTRFS_FS
58290 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58291 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58292 +#endif
58293 +
58294 +static inline dev_t __get_dev(const struct dentry *dentry)
58295 +{
58296 +#ifdef CONFIG_BTRFS_FS
58297 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58298 + return get_btrfs_dev_from_inode(dentry->d_inode);
58299 + else
58300 +#endif
58301 + return dentry->d_inode->i_sb->s_dev;
58302 +}
58303 +
58304 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58305 +{
58306 + return __get_dev(dentry);
58307 +}
58308 +
58309 +static char gr_task_roletype_to_char(struct task_struct *task)
58310 +{
58311 + switch (task->role->roletype &
58312 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58313 + GR_ROLE_SPECIAL)) {
58314 + case GR_ROLE_DEFAULT:
58315 + return 'D';
58316 + case GR_ROLE_USER:
58317 + return 'U';
58318 + case GR_ROLE_GROUP:
58319 + return 'G';
58320 + case GR_ROLE_SPECIAL:
58321 + return 'S';
58322 + }
58323 +
58324 + return 'X';
58325 +}
58326 +
58327 +char gr_roletype_to_char(void)
58328 +{
58329 + return gr_task_roletype_to_char(current);
58330 +}
58331 +
58332 +__inline__ int
58333 +gr_acl_tpe_check(void)
58334 +{
58335 + if (unlikely(!(gr_status & GR_READY)))
58336 + return 0;
58337 + if (current->role->roletype & GR_ROLE_TPE)
58338 + return 1;
58339 + else
58340 + return 0;
58341 +}
58342 +
58343 +int
58344 +gr_handle_rawio(const struct inode *inode)
58345 +{
58346 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58347 + if (inode && S_ISBLK(inode->i_mode) &&
58348 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58349 + !capable(CAP_SYS_RAWIO))
58350 + return 1;
58351 +#endif
58352 + return 0;
58353 +}
58354 +
58355 +static int
58356 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58357 +{
58358 + if (likely(lena != lenb))
58359 + return 0;
58360 +
58361 + return !memcmp(a, b, lena);
58362 +}
58363 +
58364 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58365 +{
58366 + *buflen -= namelen;
58367 + if (*buflen < 0)
58368 + return -ENAMETOOLONG;
58369 + *buffer -= namelen;
58370 + memcpy(*buffer, str, namelen);
58371 + return 0;
58372 +}
58373 +
58374 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58375 +{
58376 + return prepend(buffer, buflen, name->name, name->len);
58377 +}
58378 +
58379 +static int prepend_path(const struct path *path, struct path *root,
58380 + char **buffer, int *buflen)
58381 +{
58382 + struct dentry *dentry = path->dentry;
58383 + struct vfsmount *vfsmnt = path->mnt;
58384 + struct mount *mnt = real_mount(vfsmnt);
58385 + bool slash = false;
58386 + int error = 0;
58387 +
58388 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58389 + struct dentry * parent;
58390 +
58391 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58392 + /* Global root? */
58393 + if (!mnt_has_parent(mnt)) {
58394 + goto out;
58395 + }
58396 + dentry = mnt->mnt_mountpoint;
58397 + mnt = mnt->mnt_parent;
58398 + vfsmnt = &mnt->mnt;
58399 + continue;
58400 + }
58401 + parent = dentry->d_parent;
58402 + prefetch(parent);
58403 + spin_lock(&dentry->d_lock);
58404 + error = prepend_name(buffer, buflen, &dentry->d_name);
58405 + spin_unlock(&dentry->d_lock);
58406 + if (!error)
58407 + error = prepend(buffer, buflen, "/", 1);
58408 + if (error)
58409 + break;
58410 +
58411 + slash = true;
58412 + dentry = parent;
58413 + }
58414 +
58415 +out:
58416 + if (!error && !slash)
58417 + error = prepend(buffer, buflen, "/", 1);
58418 +
58419 + return error;
58420 +}
58421 +
58422 +/* this must be called with vfsmount_lock and rename_lock held */
58423 +
58424 +static char *__our_d_path(const struct path *path, struct path *root,
58425 + char *buf, int buflen)
58426 +{
58427 + char *res = buf + buflen;
58428 + int error;
58429 +
58430 + prepend(&res, &buflen, "\0", 1);
58431 + error = prepend_path(path, root, &res, &buflen);
58432 + if (error)
58433 + return ERR_PTR(error);
58434 +
58435 + return res;
58436 +}
58437 +
58438 +static char *
58439 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58440 +{
58441 + char *retval;
58442 +
58443 + retval = __our_d_path(path, root, buf, buflen);
58444 + if (unlikely(IS_ERR(retval)))
58445 + retval = strcpy(buf, "<path too long>");
58446 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58447 + retval[1] = '\0';
58448 +
58449 + return retval;
58450 +}
58451 +
58452 +static char *
58453 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58454 + char *buf, int buflen)
58455 +{
58456 + struct path path;
58457 + char *res;
58458 +
58459 + path.dentry = (struct dentry *)dentry;
58460 + path.mnt = (struct vfsmount *)vfsmnt;
58461 +
58462 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58463 + by the RBAC system */
58464 + res = gen_full_path(&path, &real_root, buf, buflen);
58465 +
58466 + return res;
58467 +}
58468 +
58469 +static char *
58470 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58471 + char *buf, int buflen)
58472 +{
58473 + char *res;
58474 + struct path path;
58475 + struct path root;
58476 + struct task_struct *reaper = init_pid_ns.child_reaper;
58477 +
58478 + path.dentry = (struct dentry *)dentry;
58479 + path.mnt = (struct vfsmount *)vfsmnt;
58480 +
58481 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58482 + get_fs_root(reaper->fs, &root);
58483 +
58484 + br_read_lock(&vfsmount_lock);
58485 + write_seqlock(&rename_lock);
58486 + res = gen_full_path(&path, &root, buf, buflen);
58487 + write_sequnlock(&rename_lock);
58488 + br_read_unlock(&vfsmount_lock);
58489 +
58490 + path_put(&root);
58491 + return res;
58492 +}
58493 +
58494 +static char *
58495 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58496 +{
58497 + char *ret;
58498 + br_read_lock(&vfsmount_lock);
58499 + write_seqlock(&rename_lock);
58500 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58501 + PAGE_SIZE);
58502 + write_sequnlock(&rename_lock);
58503 + br_read_unlock(&vfsmount_lock);
58504 + return ret;
58505 +}
58506 +
58507 +static char *
58508 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58509 +{
58510 + char *ret;
58511 + char *buf;
58512 + int buflen;
58513 +
58514 + br_read_lock(&vfsmount_lock);
58515 + write_seqlock(&rename_lock);
58516 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58517 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58518 + buflen = (int)(ret - buf);
58519 + if (buflen >= 5)
58520 + prepend(&ret, &buflen, "/proc", 5);
58521 + else
58522 + ret = strcpy(buf, "<path too long>");
58523 + write_sequnlock(&rename_lock);
58524 + br_read_unlock(&vfsmount_lock);
58525 + return ret;
58526 +}
58527 +
58528 +char *
58529 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58530 +{
58531 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58532 + PAGE_SIZE);
58533 +}
58534 +
58535 +char *
58536 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58537 +{
58538 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58539 + PAGE_SIZE);
58540 +}
58541 +
58542 +char *
58543 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58544 +{
58545 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58546 + PAGE_SIZE);
58547 +}
58548 +
58549 +char *
58550 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58551 +{
58552 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58553 + PAGE_SIZE);
58554 +}
58555 +
58556 +char *
58557 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58558 +{
58559 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58560 + PAGE_SIZE);
58561 +}
58562 +
58563 +__inline__ __u32
58564 +to_gr_audit(const __u32 reqmode)
58565 +{
58566 + /* masks off auditable permission flags, then shifts them to create
58567 + auditing flags, and adds the special case of append auditing if
58568 + we're requesting write */
58569 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58570 +}
58571 +
58572 +struct acl_subject_label *
58573 +lookup_subject_map(const struct acl_subject_label *userp)
58574 +{
58575 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58576 + struct subject_map *match;
58577 +
58578 + match = subj_map_set.s_hash[index];
58579 +
58580 + while (match && match->user != userp)
58581 + match = match->next;
58582 +
58583 + if (match != NULL)
58584 + return match->kernel;
58585 + else
58586 + return NULL;
58587 +}
58588 +
58589 +static void
58590 +insert_subj_map_entry(struct subject_map *subjmap)
58591 +{
58592 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58593 + struct subject_map **curr;
58594 +
58595 + subjmap->prev = NULL;
58596 +
58597 + curr = &subj_map_set.s_hash[index];
58598 + if (*curr != NULL)
58599 + (*curr)->prev = subjmap;
58600 +
58601 + subjmap->next = *curr;
58602 + *curr = subjmap;
58603 +
58604 + return;
58605 +}
58606 +
58607 +static struct acl_role_label *
58608 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58609 + const gid_t gid)
58610 +{
58611 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58612 + struct acl_role_label *match;
58613 + struct role_allowed_ip *ipp;
58614 + unsigned int x;
58615 + u32 curr_ip = task->signal->curr_ip;
58616 +
58617 + task->signal->saved_ip = curr_ip;
58618 +
58619 + match = acl_role_set.r_hash[index];
58620 +
58621 + while (match) {
58622 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58623 + for (x = 0; x < match->domain_child_num; x++) {
58624 + if (match->domain_children[x] == uid)
58625 + goto found;
58626 + }
58627 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58628 + break;
58629 + match = match->next;
58630 + }
58631 +found:
58632 + if (match == NULL) {
58633 + try_group:
58634 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58635 + match = acl_role_set.r_hash[index];
58636 +
58637 + while (match) {
58638 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58639 + for (x = 0; x < match->domain_child_num; x++) {
58640 + if (match->domain_children[x] == gid)
58641 + goto found2;
58642 + }
58643 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58644 + break;
58645 + match = match->next;
58646 + }
58647 +found2:
58648 + if (match == NULL)
58649 + match = default_role;
58650 + if (match->allowed_ips == NULL)
58651 + return match;
58652 + else {
58653 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58654 + if (likely
58655 + ((ntohl(curr_ip) & ipp->netmask) ==
58656 + (ntohl(ipp->addr) & ipp->netmask)))
58657 + return match;
58658 + }
58659 + match = default_role;
58660 + }
58661 + } else if (match->allowed_ips == NULL) {
58662 + return match;
58663 + } else {
58664 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58665 + if (likely
58666 + ((ntohl(curr_ip) & ipp->netmask) ==
58667 + (ntohl(ipp->addr) & ipp->netmask)))
58668 + return match;
58669 + }
58670 + goto try_group;
58671 + }
58672 +
58673 + return match;
58674 +}
58675 +
58676 +struct acl_subject_label *
58677 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58678 + const struct acl_role_label *role)
58679 +{
58680 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58681 + struct acl_subject_label *match;
58682 +
58683 + match = role->subj_hash[index];
58684 +
58685 + while (match && (match->inode != ino || match->device != dev ||
58686 + (match->mode & GR_DELETED))) {
58687 + match = match->next;
58688 + }
58689 +
58690 + if (match && !(match->mode & GR_DELETED))
58691 + return match;
58692 + else
58693 + return NULL;
58694 +}
58695 +
58696 +struct acl_subject_label *
58697 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58698 + const struct acl_role_label *role)
58699 +{
58700 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58701 + struct acl_subject_label *match;
58702 +
58703 + match = role->subj_hash[index];
58704 +
58705 + while (match && (match->inode != ino || match->device != dev ||
58706 + !(match->mode & GR_DELETED))) {
58707 + match = match->next;
58708 + }
58709 +
58710 + if (match && (match->mode & GR_DELETED))
58711 + return match;
58712 + else
58713 + return NULL;
58714 +}
58715 +
58716 +static struct acl_object_label *
58717 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58718 + const struct acl_subject_label *subj)
58719 +{
58720 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58721 + struct acl_object_label *match;
58722 +
58723 + match = subj->obj_hash[index];
58724 +
58725 + while (match && (match->inode != ino || match->device != dev ||
58726 + (match->mode & GR_DELETED))) {
58727 + match = match->next;
58728 + }
58729 +
58730 + if (match && !(match->mode & GR_DELETED))
58731 + return match;
58732 + else
58733 + return NULL;
58734 +}
58735 +
58736 +static struct acl_object_label *
58737 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58738 + const struct acl_subject_label *subj)
58739 +{
58740 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58741 + struct acl_object_label *match;
58742 +
58743 + match = subj->obj_hash[index];
58744 +
58745 + while (match && (match->inode != ino || match->device != dev ||
58746 + !(match->mode & GR_DELETED))) {
58747 + match = match->next;
58748 + }
58749 +
58750 + if (match && (match->mode & GR_DELETED))
58751 + return match;
58752 +
58753 + match = subj->obj_hash[index];
58754 +
58755 + while (match && (match->inode != ino || match->device != dev ||
58756 + (match->mode & GR_DELETED))) {
58757 + match = match->next;
58758 + }
58759 +
58760 + if (match && !(match->mode & GR_DELETED))
58761 + return match;
58762 + else
58763 + return NULL;
58764 +}
58765 +
58766 +static struct name_entry *
58767 +lookup_name_entry(const char *name)
58768 +{
58769 + unsigned int len = strlen(name);
58770 + unsigned int key = full_name_hash(name, len);
58771 + unsigned int index = key % name_set.n_size;
58772 + struct name_entry *match;
58773 +
58774 + match = name_set.n_hash[index];
58775 +
58776 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58777 + match = match->next;
58778 +
58779 + return match;
58780 +}
58781 +
58782 +static struct name_entry *
58783 +lookup_name_entry_create(const char *name)
58784 +{
58785 + unsigned int len = strlen(name);
58786 + unsigned int key = full_name_hash(name, len);
58787 + unsigned int index = key % name_set.n_size;
58788 + struct name_entry *match;
58789 +
58790 + match = name_set.n_hash[index];
58791 +
58792 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58793 + !match->deleted))
58794 + match = match->next;
58795 +
58796 + if (match && match->deleted)
58797 + return match;
58798 +
58799 + match = name_set.n_hash[index];
58800 +
58801 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58802 + match->deleted))
58803 + match = match->next;
58804 +
58805 + if (match && !match->deleted)
58806 + return match;
58807 + else
58808 + return NULL;
58809 +}
58810 +
58811 +static struct inodev_entry *
58812 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58813 +{
58814 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58815 + struct inodev_entry *match;
58816 +
58817 + match = inodev_set.i_hash[index];
58818 +
58819 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58820 + match = match->next;
58821 +
58822 + return match;
58823 +}
58824 +
58825 +static void
58826 +insert_inodev_entry(struct inodev_entry *entry)
58827 +{
58828 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58829 + inodev_set.i_size);
58830 + struct inodev_entry **curr;
58831 +
58832 + entry->prev = NULL;
58833 +
58834 + curr = &inodev_set.i_hash[index];
58835 + if (*curr != NULL)
58836 + (*curr)->prev = entry;
58837 +
58838 + entry->next = *curr;
58839 + *curr = entry;
58840 +
58841 + return;
58842 +}
58843 +
58844 +static void
58845 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58846 +{
58847 + unsigned int index =
58848 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58849 + struct acl_role_label **curr;
58850 + struct acl_role_label *tmp, *tmp2;
58851 +
58852 + curr = &acl_role_set.r_hash[index];
58853 +
58854 + /* simple case, slot is empty, just set it to our role */
58855 + if (*curr == NULL) {
58856 + *curr = role;
58857 + } else {
58858 + /* example:
58859 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58860 + 2 -> 3
58861 + */
58862 + /* first check to see if we can already be reached via this slot */
58863 + tmp = *curr;
58864 + while (tmp && tmp != role)
58865 + tmp = tmp->next;
58866 + if (tmp == role) {
58867 + /* we don't need to add ourselves to this slot's chain */
58868 + return;
58869 + }
58870 + /* we need to add ourselves to this chain, two cases */
58871 + if (role->next == NULL) {
58872 + /* simple case, append the current chain to our role */
58873 + role->next = *curr;
58874 + *curr = role;
58875 + } else {
58876 + /* 1 -> 2 -> 3 -> 4
58877 + 2 -> 3 -> 4
58878 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58879 + */
58880 + /* trickier case: walk our role's chain until we find
58881 + the role for the start of the current slot's chain */
58882 + tmp = role;
58883 + tmp2 = *curr;
58884 + while (tmp->next && tmp->next != tmp2)
58885 + tmp = tmp->next;
58886 + if (tmp->next == tmp2) {
58887 + /* from example above, we found 3, so just
58888 + replace this slot's chain with ours */
58889 + *curr = role;
58890 + } else {
58891 + /* we didn't find a subset of our role's chain
58892 + in the current slot's chain, so append their
58893 + chain to ours, and set us as the first role in
58894 + the slot's chain
58895 +
58896 + we could fold this case with the case above,
58897 + but making it explicit for clarity
58898 + */
58899 + tmp->next = tmp2;
58900 + *curr = role;
58901 + }
58902 + }
58903 + }
58904 +
58905 + return;
58906 +}
58907 +
58908 +static void
58909 +insert_acl_role_label(struct acl_role_label *role)
58910 +{
58911 + int i;
58912 +
58913 + if (role_list == NULL) {
58914 + role_list = role;
58915 + role->prev = NULL;
58916 + } else {
58917 + role->prev = role_list;
58918 + role_list = role;
58919 + }
58920 +
58921 + /* used for hash chains */
58922 + role->next = NULL;
58923 +
58924 + if (role->roletype & GR_ROLE_DOMAIN) {
58925 + for (i = 0; i < role->domain_child_num; i++)
58926 + __insert_acl_role_label(role, role->domain_children[i]);
58927 + } else
58928 + __insert_acl_role_label(role, role->uidgid);
58929 +}
58930 +
58931 +static int
58932 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58933 +{
58934 + struct name_entry **curr, *nentry;
58935 + struct inodev_entry *ientry;
58936 + unsigned int len = strlen(name);
58937 + unsigned int key = full_name_hash(name, len);
58938 + unsigned int index = key % name_set.n_size;
58939 +
58940 + curr = &name_set.n_hash[index];
58941 +
58942 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58943 + curr = &((*curr)->next);
58944 +
58945 + if (*curr != NULL)
58946 + return 1;
58947 +
58948 + nentry = acl_alloc(sizeof (struct name_entry));
58949 + if (nentry == NULL)
58950 + return 0;
58951 + ientry = acl_alloc(sizeof (struct inodev_entry));
58952 + if (ientry == NULL)
58953 + return 0;
58954 + ientry->nentry = nentry;
58955 +
58956 + nentry->key = key;
58957 + nentry->name = name;
58958 + nentry->inode = inode;
58959 + nentry->device = device;
58960 + nentry->len = len;
58961 + nentry->deleted = deleted;
58962 +
58963 + nentry->prev = NULL;
58964 + curr = &name_set.n_hash[index];
58965 + if (*curr != NULL)
58966 + (*curr)->prev = nentry;
58967 + nentry->next = *curr;
58968 + *curr = nentry;
58969 +
58970 + /* insert us into the table searchable by inode/dev */
58971 + insert_inodev_entry(ientry);
58972 +
58973 + return 1;
58974 +}
58975 +
58976 +static void
58977 +insert_acl_obj_label(struct acl_object_label *obj,
58978 + struct acl_subject_label *subj)
58979 +{
58980 + unsigned int index =
58981 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58982 + struct acl_object_label **curr;
58983 +
58984 +
58985 + obj->prev = NULL;
58986 +
58987 + curr = &subj->obj_hash[index];
58988 + if (*curr != NULL)
58989 + (*curr)->prev = obj;
58990 +
58991 + obj->next = *curr;
58992 + *curr = obj;
58993 +
58994 + return;
58995 +}
58996 +
58997 +static void
58998 +insert_acl_subj_label(struct acl_subject_label *obj,
58999 + struct acl_role_label *role)
59000 +{
59001 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59002 + struct acl_subject_label **curr;
59003 +
59004 + obj->prev = NULL;
59005 +
59006 + curr = &role->subj_hash[index];
59007 + if (*curr != NULL)
59008 + (*curr)->prev = obj;
59009 +
59010 + obj->next = *curr;
59011 + *curr = obj;
59012 +
59013 + return;
59014 +}
59015 +
59016 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59017 +
59018 +static void *
59019 +create_table(__u32 * len, int elementsize)
59020 +{
59021 + unsigned int table_sizes[] = {
59022 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59023 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59024 + 4194301, 8388593, 16777213, 33554393, 67108859
59025 + };
59026 + void *newtable = NULL;
59027 + unsigned int pwr = 0;
59028 +
59029 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59030 + table_sizes[pwr] <= *len)
59031 + pwr++;
59032 +
59033 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59034 + return newtable;
59035 +
59036 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59037 + newtable =
59038 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59039 + else
59040 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59041 +
59042 + *len = table_sizes[pwr];
59043 +
59044 + return newtable;
59045 +}
59046 +
59047 +static int
59048 +init_variables(const struct gr_arg *arg)
59049 +{
59050 + struct task_struct *reaper = init_pid_ns.child_reaper;
59051 + unsigned int stacksize;
59052 +
59053 + subj_map_set.s_size = arg->role_db.num_subjects;
59054 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59055 + name_set.n_size = arg->role_db.num_objects;
59056 + inodev_set.i_size = arg->role_db.num_objects;
59057 +
59058 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59059 + !name_set.n_size || !inodev_set.i_size)
59060 + return 1;
59061 +
59062 + if (!gr_init_uidset())
59063 + return 1;
59064 +
59065 + /* set up the stack that holds allocation info */
59066 +
59067 + stacksize = arg->role_db.num_pointers + 5;
59068 +
59069 + if (!acl_alloc_stack_init(stacksize))
59070 + return 1;
59071 +
59072 + /* grab reference for the real root dentry and vfsmount */
59073 + get_fs_root(reaper->fs, &real_root);
59074 +
59075 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59076 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59077 +#endif
59078 +
59079 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59080 + if (fakefs_obj_rw == NULL)
59081 + return 1;
59082 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59083 +
59084 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59085 + if (fakefs_obj_rwx == NULL)
59086 + return 1;
59087 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59088 +
59089 + subj_map_set.s_hash =
59090 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59091 + acl_role_set.r_hash =
59092 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59093 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59094 + inodev_set.i_hash =
59095 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59096 +
59097 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59098 + !name_set.n_hash || !inodev_set.i_hash)
59099 + return 1;
59100 +
59101 + memset(subj_map_set.s_hash, 0,
59102 + sizeof(struct subject_map *) * subj_map_set.s_size);
59103 + memset(acl_role_set.r_hash, 0,
59104 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59105 + memset(name_set.n_hash, 0,
59106 + sizeof (struct name_entry *) * name_set.n_size);
59107 + memset(inodev_set.i_hash, 0,
59108 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59109 +
59110 + return 0;
59111 +}
59112 +
59113 +/* free information not needed after startup
59114 + currently contains user->kernel pointer mappings for subjects
59115 +*/
59116 +
59117 +static void
59118 +free_init_variables(void)
59119 +{
59120 + __u32 i;
59121 +
59122 + if (subj_map_set.s_hash) {
59123 + for (i = 0; i < subj_map_set.s_size; i++) {
59124 + if (subj_map_set.s_hash[i]) {
59125 + kfree(subj_map_set.s_hash[i]);
59126 + subj_map_set.s_hash[i] = NULL;
59127 + }
59128 + }
59129 +
59130 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59131 + PAGE_SIZE)
59132 + kfree(subj_map_set.s_hash);
59133 + else
59134 + vfree(subj_map_set.s_hash);
59135 + }
59136 +
59137 + return;
59138 +}
59139 +
59140 +static void
59141 +free_variables(void)
59142 +{
59143 + struct acl_subject_label *s;
59144 + struct acl_role_label *r;
59145 + struct task_struct *task, *task2;
59146 + unsigned int x;
59147 +
59148 + gr_clear_learn_entries();
59149 +
59150 + read_lock(&tasklist_lock);
59151 + do_each_thread(task2, task) {
59152 + task->acl_sp_role = 0;
59153 + task->acl_role_id = 0;
59154 + task->acl = NULL;
59155 + task->role = NULL;
59156 + } while_each_thread(task2, task);
59157 + read_unlock(&tasklist_lock);
59158 +
59159 + /* release the reference to the real root dentry and vfsmount */
59160 + path_put(&real_root);
59161 + memset(&real_root, 0, sizeof(real_root));
59162 +
59163 + /* free all object hash tables */
59164 +
59165 + FOR_EACH_ROLE_START(r)
59166 + if (r->subj_hash == NULL)
59167 + goto next_role;
59168 + FOR_EACH_SUBJECT_START(r, s, x)
59169 + if (s->obj_hash == NULL)
59170 + break;
59171 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59172 + kfree(s->obj_hash);
59173 + else
59174 + vfree(s->obj_hash);
59175 + FOR_EACH_SUBJECT_END(s, x)
59176 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59177 + if (s->obj_hash == NULL)
59178 + break;
59179 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59180 + kfree(s->obj_hash);
59181 + else
59182 + vfree(s->obj_hash);
59183 + FOR_EACH_NESTED_SUBJECT_END(s)
59184 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59185 + kfree(r->subj_hash);
59186 + else
59187 + vfree(r->subj_hash);
59188 + r->subj_hash = NULL;
59189 +next_role:
59190 + FOR_EACH_ROLE_END(r)
59191 +
59192 + acl_free_all();
59193 +
59194 + if (acl_role_set.r_hash) {
59195 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59196 + PAGE_SIZE)
59197 + kfree(acl_role_set.r_hash);
59198 + else
59199 + vfree(acl_role_set.r_hash);
59200 + }
59201 + if (name_set.n_hash) {
59202 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59203 + PAGE_SIZE)
59204 + kfree(name_set.n_hash);
59205 + else
59206 + vfree(name_set.n_hash);
59207 + }
59208 +
59209 + if (inodev_set.i_hash) {
59210 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59211 + PAGE_SIZE)
59212 + kfree(inodev_set.i_hash);
59213 + else
59214 + vfree(inodev_set.i_hash);
59215 + }
59216 +
59217 + gr_free_uidset();
59218 +
59219 + memset(&name_set, 0, sizeof (struct name_db));
59220 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59221 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59222 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59223 +
59224 + default_role = NULL;
59225 + kernel_role = NULL;
59226 + role_list = NULL;
59227 +
59228 + return;
59229 +}
59230 +
59231 +static __u32
59232 +count_user_objs(struct acl_object_label *userp)
59233 +{
59234 + struct acl_object_label o_tmp;
59235 + __u32 num = 0;
59236 +
59237 + while (userp) {
59238 + if (copy_from_user(&o_tmp, userp,
59239 + sizeof (struct acl_object_label)))
59240 + break;
59241 +
59242 + userp = o_tmp.prev;
59243 + num++;
59244 + }
59245 +
59246 + return num;
59247 +}
59248 +
59249 +static struct acl_subject_label *
59250 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59251 +
59252 +static int
59253 +copy_user_glob(struct acl_object_label *obj)
59254 +{
59255 + struct acl_object_label *g_tmp, **guser;
59256 + unsigned int len;
59257 + char *tmp;
59258 +
59259 + if (obj->globbed == NULL)
59260 + return 0;
59261 +
59262 + guser = &obj->globbed;
59263 + while (*guser) {
59264 + g_tmp = (struct acl_object_label *)
59265 + acl_alloc(sizeof (struct acl_object_label));
59266 + if (g_tmp == NULL)
59267 + return -ENOMEM;
59268 +
59269 + if (copy_from_user(g_tmp, *guser,
59270 + sizeof (struct acl_object_label)))
59271 + return -EFAULT;
59272 +
59273 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59274 +
59275 + if (!len || len >= PATH_MAX)
59276 + return -EINVAL;
59277 +
59278 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59279 + return -ENOMEM;
59280 +
59281 + if (copy_from_user(tmp, g_tmp->filename, len))
59282 + return -EFAULT;
59283 + tmp[len-1] = '\0';
59284 + g_tmp->filename = tmp;
59285 +
59286 + *guser = g_tmp;
59287 + guser = &(g_tmp->next);
59288 + }
59289 +
59290 + return 0;
59291 +}
59292 +
59293 +static int
59294 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59295 + struct acl_role_label *role)
59296 +{
59297 + struct acl_object_label *o_tmp;
59298 + unsigned int len;
59299 + int ret;
59300 + char *tmp;
59301 +
59302 + while (userp) {
59303 + if ((o_tmp = (struct acl_object_label *)
59304 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59305 + return -ENOMEM;
59306 +
59307 + if (copy_from_user(o_tmp, userp,
59308 + sizeof (struct acl_object_label)))
59309 + return -EFAULT;
59310 +
59311 + userp = o_tmp->prev;
59312 +
59313 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59314 +
59315 + if (!len || len >= PATH_MAX)
59316 + return -EINVAL;
59317 +
59318 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59319 + return -ENOMEM;
59320 +
59321 + if (copy_from_user(tmp, o_tmp->filename, len))
59322 + return -EFAULT;
59323 + tmp[len-1] = '\0';
59324 + o_tmp->filename = tmp;
59325 +
59326 + insert_acl_obj_label(o_tmp, subj);
59327 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59328 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59329 + return -ENOMEM;
59330 +
59331 + ret = copy_user_glob(o_tmp);
59332 + if (ret)
59333 + return ret;
59334 +
59335 + if (o_tmp->nested) {
59336 + int already_copied;
59337 +
59338 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59339 + if (IS_ERR(o_tmp->nested))
59340 + return PTR_ERR(o_tmp->nested);
59341 +
59342 + /* insert into nested subject list if we haven't copied this one yet
59343 + to prevent duplicate entries */
59344 + if (!already_copied) {
59345 + o_tmp->nested->next = role->hash->first;
59346 + role->hash->first = o_tmp->nested;
59347 + }
59348 + }
59349 + }
59350 +
59351 + return 0;
59352 +}
59353 +
59354 +static __u32
59355 +count_user_subjs(struct acl_subject_label *userp)
59356 +{
59357 + struct acl_subject_label s_tmp;
59358 + __u32 num = 0;
59359 +
59360 + while (userp) {
59361 + if (copy_from_user(&s_tmp, userp,
59362 + sizeof (struct acl_subject_label)))
59363 + break;
59364 +
59365 + userp = s_tmp.prev;
59366 + }
59367 +
59368 + return num;
59369 +}
59370 +
59371 +static int
59372 +copy_user_allowedips(struct acl_role_label *rolep)
59373 +{
59374 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59375 +
59376 + ruserip = rolep->allowed_ips;
59377 +
59378 + while (ruserip) {
59379 + rlast = rtmp;
59380 +
59381 + if ((rtmp = (struct role_allowed_ip *)
59382 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59383 + return -ENOMEM;
59384 +
59385 + if (copy_from_user(rtmp, ruserip,
59386 + sizeof (struct role_allowed_ip)))
59387 + return -EFAULT;
59388 +
59389 + ruserip = rtmp->prev;
59390 +
59391 + if (!rlast) {
59392 + rtmp->prev = NULL;
59393 + rolep->allowed_ips = rtmp;
59394 + } else {
59395 + rlast->next = rtmp;
59396 + rtmp->prev = rlast;
59397 + }
59398 +
59399 + if (!ruserip)
59400 + rtmp->next = NULL;
59401 + }
59402 +
59403 + return 0;
59404 +}
59405 +
59406 +static int
59407 +copy_user_transitions(struct acl_role_label *rolep)
59408 +{
59409 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59410 +
59411 + unsigned int len;
59412 + char *tmp;
59413 +
59414 + rusertp = rolep->transitions;
59415 +
59416 + while (rusertp) {
59417 + rlast = rtmp;
59418 +
59419 + if ((rtmp = (struct role_transition *)
59420 + acl_alloc(sizeof (struct role_transition))) == NULL)
59421 + return -ENOMEM;
59422 +
59423 + if (copy_from_user(rtmp, rusertp,
59424 + sizeof (struct role_transition)))
59425 + return -EFAULT;
59426 +
59427 + rusertp = rtmp->prev;
59428 +
59429 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59430 +
59431 + if (!len || len >= GR_SPROLE_LEN)
59432 + return -EINVAL;
59433 +
59434 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59435 + return -ENOMEM;
59436 +
59437 + if (copy_from_user(tmp, rtmp->rolename, len))
59438 + return -EFAULT;
59439 + tmp[len-1] = '\0';
59440 + rtmp->rolename = tmp;
59441 +
59442 + if (!rlast) {
59443 + rtmp->prev = NULL;
59444 + rolep->transitions = rtmp;
59445 + } else {
59446 + rlast->next = rtmp;
59447 + rtmp->prev = rlast;
59448 + }
59449 +
59450 + if (!rusertp)
59451 + rtmp->next = NULL;
59452 + }
59453 +
59454 + return 0;
59455 +}
59456 +
59457 +static struct acl_subject_label *
59458 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59459 +{
59460 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59461 + unsigned int len;
59462 + char *tmp;
59463 + __u32 num_objs;
59464 + struct acl_ip_label **i_tmp, *i_utmp2;
59465 + struct gr_hash_struct ghash;
59466 + struct subject_map *subjmap;
59467 + unsigned int i_num;
59468 + int err;
59469 +
59470 + if (already_copied != NULL)
59471 + *already_copied = 0;
59472 +
59473 + s_tmp = lookup_subject_map(userp);
59474 +
59475 + /* we've already copied this subject into the kernel, just return
59476 + the reference to it, and don't copy it over again
59477 + */
59478 + if (s_tmp) {
59479 + if (already_copied != NULL)
59480 + *already_copied = 1;
59481 + return(s_tmp);
59482 + }
59483 +
59484 + if ((s_tmp = (struct acl_subject_label *)
59485 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59486 + return ERR_PTR(-ENOMEM);
59487 +
59488 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59489 + if (subjmap == NULL)
59490 + return ERR_PTR(-ENOMEM);
59491 +
59492 + subjmap->user = userp;
59493 + subjmap->kernel = s_tmp;
59494 + insert_subj_map_entry(subjmap);
59495 +
59496 + if (copy_from_user(s_tmp, userp,
59497 + sizeof (struct acl_subject_label)))
59498 + return ERR_PTR(-EFAULT);
59499 +
59500 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59501 +
59502 + if (!len || len >= PATH_MAX)
59503 + return ERR_PTR(-EINVAL);
59504 +
59505 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59506 + return ERR_PTR(-ENOMEM);
59507 +
59508 + if (copy_from_user(tmp, s_tmp->filename, len))
59509 + return ERR_PTR(-EFAULT);
59510 + tmp[len-1] = '\0';
59511 + s_tmp->filename = tmp;
59512 +
59513 + if (!strcmp(s_tmp->filename, "/"))
59514 + role->root_label = s_tmp;
59515 +
59516 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59517 + return ERR_PTR(-EFAULT);
59518 +
59519 + /* copy user and group transition tables */
59520 +
59521 + if (s_tmp->user_trans_num) {
59522 + uid_t *uidlist;
59523 +
59524 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59525 + if (uidlist == NULL)
59526 + return ERR_PTR(-ENOMEM);
59527 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59528 + return ERR_PTR(-EFAULT);
59529 +
59530 + s_tmp->user_transitions = uidlist;
59531 + }
59532 +
59533 + if (s_tmp->group_trans_num) {
59534 + gid_t *gidlist;
59535 +
59536 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59537 + if (gidlist == NULL)
59538 + return ERR_PTR(-ENOMEM);
59539 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59540 + return ERR_PTR(-EFAULT);
59541 +
59542 + s_tmp->group_transitions = gidlist;
59543 + }
59544 +
59545 + /* set up object hash table */
59546 + num_objs = count_user_objs(ghash.first);
59547 +
59548 + s_tmp->obj_hash_size = num_objs;
59549 + s_tmp->obj_hash =
59550 + (struct acl_object_label **)
59551 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59552 +
59553 + if (!s_tmp->obj_hash)
59554 + return ERR_PTR(-ENOMEM);
59555 +
59556 + memset(s_tmp->obj_hash, 0,
59557 + s_tmp->obj_hash_size *
59558 + sizeof (struct acl_object_label *));
59559 +
59560 + /* add in objects */
59561 + err = copy_user_objs(ghash.first, s_tmp, role);
59562 +
59563 + if (err)
59564 + return ERR_PTR(err);
59565 +
59566 + /* set pointer for parent subject */
59567 + if (s_tmp->parent_subject) {
59568 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59569 +
59570 + if (IS_ERR(s_tmp2))
59571 + return s_tmp2;
59572 +
59573 + s_tmp->parent_subject = s_tmp2;
59574 + }
59575 +
59576 + /* add in ip acls */
59577 +
59578 + if (!s_tmp->ip_num) {
59579 + s_tmp->ips = NULL;
59580 + goto insert;
59581 + }
59582 +
59583 + i_tmp =
59584 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59585 + sizeof (struct acl_ip_label *));
59586 +
59587 + if (!i_tmp)
59588 + return ERR_PTR(-ENOMEM);
59589 +
59590 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59591 + *(i_tmp + i_num) =
59592 + (struct acl_ip_label *)
59593 + acl_alloc(sizeof (struct acl_ip_label));
59594 + if (!*(i_tmp + i_num))
59595 + return ERR_PTR(-ENOMEM);
59596 +
59597 + if (copy_from_user
59598 + (&i_utmp2, s_tmp->ips + i_num,
59599 + sizeof (struct acl_ip_label *)))
59600 + return ERR_PTR(-EFAULT);
59601 +
59602 + if (copy_from_user
59603 + (*(i_tmp + i_num), i_utmp2,
59604 + sizeof (struct acl_ip_label)))
59605 + return ERR_PTR(-EFAULT);
59606 +
59607 + if ((*(i_tmp + i_num))->iface == NULL)
59608 + continue;
59609 +
59610 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59611 + if (!len || len >= IFNAMSIZ)
59612 + return ERR_PTR(-EINVAL);
59613 + tmp = acl_alloc(len);
59614 + if (tmp == NULL)
59615 + return ERR_PTR(-ENOMEM);
59616 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59617 + return ERR_PTR(-EFAULT);
59618 + (*(i_tmp + i_num))->iface = tmp;
59619 + }
59620 +
59621 + s_tmp->ips = i_tmp;
59622 +
59623 +insert:
59624 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59625 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59626 + return ERR_PTR(-ENOMEM);
59627 +
59628 + return s_tmp;
59629 +}
59630 +
59631 +static int
59632 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59633 +{
59634 + struct acl_subject_label s_pre;
59635 + struct acl_subject_label * ret;
59636 + int err;
59637 +
59638 + while (userp) {
59639 + if (copy_from_user(&s_pre, userp,
59640 + sizeof (struct acl_subject_label)))
59641 + return -EFAULT;
59642 +
59643 + ret = do_copy_user_subj(userp, role, NULL);
59644 +
59645 + err = PTR_ERR(ret);
59646 + if (IS_ERR(ret))
59647 + return err;
59648 +
59649 + insert_acl_subj_label(ret, role);
59650 +
59651 + userp = s_pre.prev;
59652 + }
59653 +
59654 + return 0;
59655 +}
59656 +
59657 +static int
59658 +copy_user_acl(struct gr_arg *arg)
59659 +{
59660 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59661 + struct acl_subject_label *subj_list;
59662 + struct sprole_pw *sptmp;
59663 + struct gr_hash_struct *ghash;
59664 + uid_t *domainlist;
59665 + unsigned int r_num;
59666 + unsigned int len;
59667 + char *tmp;
59668 + int err = 0;
59669 + __u16 i;
59670 + __u32 num_subjs;
59671 +
59672 + /* we need a default and kernel role */
59673 + if (arg->role_db.num_roles < 2)
59674 + return -EINVAL;
59675 +
59676 + /* copy special role authentication info from userspace */
59677 +
59678 + num_sprole_pws = arg->num_sprole_pws;
59679 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59680 +
59681 + if (!acl_special_roles && num_sprole_pws)
59682 + return -ENOMEM;
59683 +
59684 + for (i = 0; i < num_sprole_pws; i++) {
59685 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59686 + if (!sptmp)
59687 + return -ENOMEM;
59688 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59689 + sizeof (struct sprole_pw)))
59690 + return -EFAULT;
59691 +
59692 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59693 +
59694 + if (!len || len >= GR_SPROLE_LEN)
59695 + return -EINVAL;
59696 +
59697 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59698 + return -ENOMEM;
59699 +
59700 + if (copy_from_user(tmp, sptmp->rolename, len))
59701 + return -EFAULT;
59702 +
59703 + tmp[len-1] = '\0';
59704 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59705 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59706 +#endif
59707 + sptmp->rolename = tmp;
59708 + acl_special_roles[i] = sptmp;
59709 + }
59710 +
59711 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59712 +
59713 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59714 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59715 +
59716 + if (!r_tmp)
59717 + return -ENOMEM;
59718 +
59719 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59720 + sizeof (struct acl_role_label *)))
59721 + return -EFAULT;
59722 +
59723 + if (copy_from_user(r_tmp, r_utmp2,
59724 + sizeof (struct acl_role_label)))
59725 + return -EFAULT;
59726 +
59727 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59728 +
59729 + if (!len || len >= PATH_MAX)
59730 + return -EINVAL;
59731 +
59732 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59733 + return -ENOMEM;
59734 +
59735 + if (copy_from_user(tmp, r_tmp->rolename, len))
59736 + return -EFAULT;
59737 +
59738 + tmp[len-1] = '\0';
59739 + r_tmp->rolename = tmp;
59740 +
59741 + if (!strcmp(r_tmp->rolename, "default")
59742 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59743 + default_role = r_tmp;
59744 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59745 + kernel_role = r_tmp;
59746 + }
59747 +
59748 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59749 + return -ENOMEM;
59750 +
59751 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59752 + return -EFAULT;
59753 +
59754 + r_tmp->hash = ghash;
59755 +
59756 + num_subjs = count_user_subjs(r_tmp->hash->first);
59757 +
59758 + r_tmp->subj_hash_size = num_subjs;
59759 + r_tmp->subj_hash =
59760 + (struct acl_subject_label **)
59761 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59762 +
59763 + if (!r_tmp->subj_hash)
59764 + return -ENOMEM;
59765 +
59766 + err = copy_user_allowedips(r_tmp);
59767 + if (err)
59768 + return err;
59769 +
59770 + /* copy domain info */
59771 + if (r_tmp->domain_children != NULL) {
59772 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59773 + if (domainlist == NULL)
59774 + return -ENOMEM;
59775 +
59776 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59777 + return -EFAULT;
59778 +
59779 + r_tmp->domain_children = domainlist;
59780 + }
59781 +
59782 + err = copy_user_transitions(r_tmp);
59783 + if (err)
59784 + return err;
59785 +
59786 + memset(r_tmp->subj_hash, 0,
59787 + r_tmp->subj_hash_size *
59788 + sizeof (struct acl_subject_label *));
59789 +
59790 + /* acquire the list of subjects, then NULL out
59791 + the list prior to parsing the subjects for this role,
59792 + as during this parsing the list is replaced with a list
59793 + of *nested* subjects for the role
59794 + */
59795 + subj_list = r_tmp->hash->first;
59796 +
59797 + /* set nested subject list to null */
59798 + r_tmp->hash->first = NULL;
59799 +
59800 + err = copy_user_subjs(subj_list, r_tmp);
59801 +
59802 + if (err)
59803 + return err;
59804 +
59805 + insert_acl_role_label(r_tmp);
59806 + }
59807 +
59808 + if (default_role == NULL || kernel_role == NULL)
59809 + return -EINVAL;
59810 +
59811 + return err;
59812 +}
59813 +
59814 +static int
59815 +gracl_init(struct gr_arg *args)
59816 +{
59817 + int error = 0;
59818 +
59819 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59820 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59821 +
59822 + if (init_variables(args)) {
59823 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59824 + error = -ENOMEM;
59825 + free_variables();
59826 + goto out;
59827 + }
59828 +
59829 + error = copy_user_acl(args);
59830 + free_init_variables();
59831 + if (error) {
59832 + free_variables();
59833 + goto out;
59834 + }
59835 +
59836 + if ((error = gr_set_acls(0))) {
59837 + free_variables();
59838 + goto out;
59839 + }
59840 +
59841 + pax_open_kernel();
59842 + gr_status |= GR_READY;
59843 + pax_close_kernel();
59844 +
59845 + out:
59846 + return error;
59847 +}
59848 +
59849 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59850 +
59851 +static int
59852 +glob_match(const char *p, const char *n)
59853 +{
59854 + char c;
59855 +
59856 + while ((c = *p++) != '\0') {
59857 + switch (c) {
59858 + case '?':
59859 + if (*n == '\0')
59860 + return 1;
59861 + else if (*n == '/')
59862 + return 1;
59863 + break;
59864 + case '\\':
59865 + if (*n != c)
59866 + return 1;
59867 + break;
59868 + case '*':
59869 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59870 + if (*n == '/')
59871 + return 1;
59872 + else if (c == '?') {
59873 + if (*n == '\0')
59874 + return 1;
59875 + else
59876 + ++n;
59877 + }
59878 + }
59879 + if (c == '\0') {
59880 + return 0;
59881 + } else {
59882 + const char *endp;
59883 +
59884 + if ((endp = strchr(n, '/')) == NULL)
59885 + endp = n + strlen(n);
59886 +
59887 + if (c == '[') {
59888 + for (--p; n < endp; ++n)
59889 + if (!glob_match(p, n))
59890 + return 0;
59891 + } else if (c == '/') {
59892 + while (*n != '\0' && *n != '/')
59893 + ++n;
59894 + if (*n == '/' && !glob_match(p, n + 1))
59895 + return 0;
59896 + } else {
59897 + for (--p; n < endp; ++n)
59898 + if (*n == c && !glob_match(p, n))
59899 + return 0;
59900 + }
59901 +
59902 + return 1;
59903 + }
59904 + case '[':
59905 + {
59906 + int not;
59907 + char cold;
59908 +
59909 + if (*n == '\0' || *n == '/')
59910 + return 1;
59911 +
59912 + not = (*p == '!' || *p == '^');
59913 + if (not)
59914 + ++p;
59915 +
59916 + c = *p++;
59917 + for (;;) {
59918 + unsigned char fn = (unsigned char)*n;
59919 +
59920 + if (c == '\0')
59921 + return 1;
59922 + else {
59923 + if (c == fn)
59924 + goto matched;
59925 + cold = c;
59926 + c = *p++;
59927 +
59928 + if (c == '-' && *p != ']') {
59929 + unsigned char cend = *p++;
59930 +
59931 + if (cend == '\0')
59932 + return 1;
59933 +
59934 + if (cold <= fn && fn <= cend)
59935 + goto matched;
59936 +
59937 + c = *p++;
59938 + }
59939 + }
59940 +
59941 + if (c == ']')
59942 + break;
59943 + }
59944 + if (!not)
59945 + return 1;
59946 + break;
59947 + matched:
59948 + while (c != ']') {
59949 + if (c == '\0')
59950 + return 1;
59951 +
59952 + c = *p++;
59953 + }
59954 + if (not)
59955 + return 1;
59956 + }
59957 + break;
59958 + default:
59959 + if (c != *n)
59960 + return 1;
59961 + }
59962 +
59963 + ++n;
59964 + }
59965 +
59966 + if (*n == '\0')
59967 + return 0;
59968 +
59969 + if (*n == '/')
59970 + return 0;
59971 +
59972 + return 1;
59973 +}
59974 +
59975 +static struct acl_object_label *
59976 +chk_glob_label(struct acl_object_label *globbed,
59977 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59978 +{
59979 + struct acl_object_label *tmp;
59980 +
59981 + if (*path == NULL)
59982 + *path = gr_to_filename_nolock(dentry, mnt);
59983 +
59984 + tmp = globbed;
59985 +
59986 + while (tmp) {
59987 + if (!glob_match(tmp->filename, *path))
59988 + return tmp;
59989 + tmp = tmp->next;
59990 + }
59991 +
59992 + return NULL;
59993 +}
59994 +
59995 +static struct acl_object_label *
59996 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59997 + const ino_t curr_ino, const dev_t curr_dev,
59998 + const struct acl_subject_label *subj, char **path, const int checkglob)
59999 +{
60000 + struct acl_subject_label *tmpsubj;
60001 + struct acl_object_label *retval;
60002 + struct acl_object_label *retval2;
60003 +
60004 + tmpsubj = (struct acl_subject_label *) subj;
60005 + read_lock(&gr_inode_lock);
60006 + do {
60007 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60008 + if (retval) {
60009 + if (checkglob && retval->globbed) {
60010 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60011 + if (retval2)
60012 + retval = retval2;
60013 + }
60014 + break;
60015 + }
60016 + } while ((tmpsubj = tmpsubj->parent_subject));
60017 + read_unlock(&gr_inode_lock);
60018 +
60019 + return retval;
60020 +}
60021 +
60022 +static __inline__ struct acl_object_label *
60023 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60024 + struct dentry *curr_dentry,
60025 + const struct acl_subject_label *subj, char **path, const int checkglob)
60026 +{
60027 + int newglob = checkglob;
60028 + ino_t inode;
60029 + dev_t device;
60030 +
60031 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60032 + as we don't want a / * rule to match instead of the / object
60033 + don't do this for create lookups that call this function though, since they're looking up
60034 + on the parent and thus need globbing checks on all paths
60035 + */
60036 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60037 + newglob = GR_NO_GLOB;
60038 +
60039 + spin_lock(&curr_dentry->d_lock);
60040 + inode = curr_dentry->d_inode->i_ino;
60041 + device = __get_dev(curr_dentry);
60042 + spin_unlock(&curr_dentry->d_lock);
60043 +
60044 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60045 +}
60046 +
60047 +#ifdef CONFIG_HUGETLBFS
60048 +static inline bool
60049 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60050 +{
60051 + int i;
60052 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60053 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60054 + return true;
60055 + }
60056 +
60057 + return false;
60058 +}
60059 +#endif
60060 +
60061 +static struct acl_object_label *
60062 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60063 + const struct acl_subject_label *subj, char *path, const int checkglob)
60064 +{
60065 + struct dentry *dentry = (struct dentry *) l_dentry;
60066 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60067 + struct mount *real_mnt = real_mount(mnt);
60068 + struct acl_object_label *retval;
60069 + struct dentry *parent;
60070 +
60071 + br_read_lock(&vfsmount_lock);
60072 + write_seqlock(&rename_lock);
60073 +
60074 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60075 +#ifdef CONFIG_NET
60076 + mnt == sock_mnt ||
60077 +#endif
60078 +#ifdef CONFIG_HUGETLBFS
60079 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60080 +#endif
60081 + /* ignore Eric Biederman */
60082 + IS_PRIVATE(l_dentry->d_inode))) {
60083 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60084 + goto out;
60085 + }
60086 +
60087 + for (;;) {
60088 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60089 + break;
60090 +
60091 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60092 + if (!mnt_has_parent(real_mnt))
60093 + break;
60094 +
60095 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60096 + if (retval != NULL)
60097 + goto out;
60098 +
60099 + dentry = real_mnt->mnt_mountpoint;
60100 + real_mnt = real_mnt->mnt_parent;
60101 + mnt = &real_mnt->mnt;
60102 + continue;
60103 + }
60104 +
60105 + parent = dentry->d_parent;
60106 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60107 + if (retval != NULL)
60108 + goto out;
60109 +
60110 + dentry = parent;
60111 + }
60112 +
60113 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60114 +
60115 + /* real_root is pinned so we don't have to hold a reference */
60116 + if (retval == NULL)
60117 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60118 +out:
60119 + write_sequnlock(&rename_lock);
60120 + br_read_unlock(&vfsmount_lock);
60121 +
60122 + BUG_ON(retval == NULL);
60123 +
60124 + return retval;
60125 +}
60126 +
60127 +static __inline__ struct acl_object_label *
60128 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60129 + const struct acl_subject_label *subj)
60130 +{
60131 + char *path = NULL;
60132 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60133 +}
60134 +
60135 +static __inline__ struct acl_object_label *
60136 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60137 + const struct acl_subject_label *subj)
60138 +{
60139 + char *path = NULL;
60140 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60141 +}
60142 +
60143 +static __inline__ struct acl_object_label *
60144 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60145 + const struct acl_subject_label *subj, char *path)
60146 +{
60147 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60148 +}
60149 +
60150 +static struct acl_subject_label *
60151 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60152 + const struct acl_role_label *role)
60153 +{
60154 + struct dentry *dentry = (struct dentry *) l_dentry;
60155 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60156 + struct mount *real_mnt = real_mount(mnt);
60157 + struct acl_subject_label *retval;
60158 + struct dentry *parent;
60159 +
60160 + br_read_lock(&vfsmount_lock);
60161 + write_seqlock(&rename_lock);
60162 +
60163 + for (;;) {
60164 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60165 + break;
60166 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60167 + if (!mnt_has_parent(real_mnt))
60168 + break;
60169 +
60170 + spin_lock(&dentry->d_lock);
60171 + read_lock(&gr_inode_lock);
60172 + retval =
60173 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60174 + __get_dev(dentry), role);
60175 + read_unlock(&gr_inode_lock);
60176 + spin_unlock(&dentry->d_lock);
60177 + if (retval != NULL)
60178 + goto out;
60179 +
60180 + dentry = real_mnt->mnt_mountpoint;
60181 + real_mnt = real_mnt->mnt_parent;
60182 + mnt = &real_mnt->mnt;
60183 + continue;
60184 + }
60185 +
60186 + spin_lock(&dentry->d_lock);
60187 + read_lock(&gr_inode_lock);
60188 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60189 + __get_dev(dentry), role);
60190 + read_unlock(&gr_inode_lock);
60191 + parent = dentry->d_parent;
60192 + spin_unlock(&dentry->d_lock);
60193 +
60194 + if (retval != NULL)
60195 + goto out;
60196 +
60197 + dentry = parent;
60198 + }
60199 +
60200 + spin_lock(&dentry->d_lock);
60201 + read_lock(&gr_inode_lock);
60202 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60203 + __get_dev(dentry), role);
60204 + read_unlock(&gr_inode_lock);
60205 + spin_unlock(&dentry->d_lock);
60206 +
60207 + if (unlikely(retval == NULL)) {
60208 + /* real_root is pinned, we don't need to hold a reference */
60209 + read_lock(&gr_inode_lock);
60210 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60211 + __get_dev(real_root.dentry), role);
60212 + read_unlock(&gr_inode_lock);
60213 + }
60214 +out:
60215 + write_sequnlock(&rename_lock);
60216 + br_read_unlock(&vfsmount_lock);
60217 +
60218 + BUG_ON(retval == NULL);
60219 +
60220 + return retval;
60221 +}
60222 +
60223 +static void
60224 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60225 +{
60226 + struct task_struct *task = current;
60227 + const struct cred *cred = current_cred();
60228 +
60229 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60230 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60231 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60232 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60233 +
60234 + return;
60235 +}
60236 +
60237 +static void
60238 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60239 +{
60240 + struct task_struct *task = current;
60241 + const struct cred *cred = current_cred();
60242 +
60243 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60244 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60245 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60246 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60247 +
60248 + return;
60249 +}
60250 +
60251 +static void
60252 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60253 +{
60254 + struct task_struct *task = current;
60255 + const struct cred *cred = current_cred();
60256 +
60257 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60258 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60259 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60260 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60261 +
60262 + return;
60263 +}
60264 +
60265 +__u32
60266 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60267 + const struct vfsmount * mnt)
60268 +{
60269 + __u32 retval = mode;
60270 + struct acl_subject_label *curracl;
60271 + struct acl_object_label *currobj;
60272 +
60273 + if (unlikely(!(gr_status & GR_READY)))
60274 + return (mode & ~GR_AUDITS);
60275 +
60276 + curracl = current->acl;
60277 +
60278 + currobj = chk_obj_label(dentry, mnt, curracl);
60279 + retval = currobj->mode & mode;
60280 +
60281 + /* if we're opening a specified transfer file for writing
60282 + (e.g. /dev/initctl), then transfer our role to init
60283 + */
60284 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60285 + current->role->roletype & GR_ROLE_PERSIST)) {
60286 + struct task_struct *task = init_pid_ns.child_reaper;
60287 +
60288 + if (task->role != current->role) {
60289 + task->acl_sp_role = 0;
60290 + task->acl_role_id = current->acl_role_id;
60291 + task->role = current->role;
60292 + rcu_read_lock();
60293 + read_lock(&grsec_exec_file_lock);
60294 + gr_apply_subject_to_task(task);
60295 + read_unlock(&grsec_exec_file_lock);
60296 + rcu_read_unlock();
60297 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60298 + }
60299 + }
60300 +
60301 + if (unlikely
60302 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60303 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60304 + __u32 new_mode = mode;
60305 +
60306 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60307 +
60308 + retval = new_mode;
60309 +
60310 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60311 + new_mode |= GR_INHERIT;
60312 +
60313 + if (!(mode & GR_NOLEARN))
60314 + gr_log_learn(dentry, mnt, new_mode);
60315 + }
60316 +
60317 + return retval;
60318 +}
60319 +
60320 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60321 + const struct dentry *parent,
60322 + const struct vfsmount *mnt)
60323 +{
60324 + struct name_entry *match;
60325 + struct acl_object_label *matchpo;
60326 + struct acl_subject_label *curracl;
60327 + char *path;
60328 +
60329 + if (unlikely(!(gr_status & GR_READY)))
60330 + return NULL;
60331 +
60332 + preempt_disable();
60333 + path = gr_to_filename_rbac(new_dentry, mnt);
60334 + match = lookup_name_entry_create(path);
60335 +
60336 + curracl = current->acl;
60337 +
60338 + if (match) {
60339 + read_lock(&gr_inode_lock);
60340 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60341 + read_unlock(&gr_inode_lock);
60342 +
60343 + if (matchpo) {
60344 + preempt_enable();
60345 + return matchpo;
60346 + }
60347 + }
60348 +
60349 + // lookup parent
60350 +
60351 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60352 +
60353 + preempt_enable();
60354 + return matchpo;
60355 +}
60356 +
60357 +__u32
60358 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60359 + const struct vfsmount * mnt, const __u32 mode)
60360 +{
60361 + struct acl_object_label *matchpo;
60362 + __u32 retval;
60363 +
60364 + if (unlikely(!(gr_status & GR_READY)))
60365 + return (mode & ~GR_AUDITS);
60366 +
60367 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60368 +
60369 + retval = matchpo->mode & mode;
60370 +
60371 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60372 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60373 + __u32 new_mode = mode;
60374 +
60375 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60376 +
60377 + gr_log_learn(new_dentry, mnt, new_mode);
60378 + return new_mode;
60379 + }
60380 +
60381 + return retval;
60382 +}
60383 +
60384 +__u32
60385 +gr_check_link(const struct dentry * new_dentry,
60386 + const struct dentry * parent_dentry,
60387 + const struct vfsmount * parent_mnt,
60388 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60389 +{
60390 + struct acl_object_label *obj;
60391 + __u32 oldmode, newmode;
60392 + __u32 needmode;
60393 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60394 + GR_DELETE | GR_INHERIT;
60395 +
60396 + if (unlikely(!(gr_status & GR_READY)))
60397 + return (GR_CREATE | GR_LINK);
60398 +
60399 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60400 + oldmode = obj->mode;
60401 +
60402 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60403 + newmode = obj->mode;
60404 +
60405 + needmode = newmode & checkmodes;
60406 +
60407 + // old name for hardlink must have at least the permissions of the new name
60408 + if ((oldmode & needmode) != needmode)
60409 + goto bad;
60410 +
60411 + // if old name had restrictions/auditing, make sure the new name does as well
60412 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60413 +
60414 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60415 + if (is_privileged_binary(old_dentry))
60416 + needmode |= GR_SETID;
60417 +
60418 + if ((newmode & needmode) != needmode)
60419 + goto bad;
60420 +
60421 + // enforce minimum permissions
60422 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60423 + return newmode;
60424 +bad:
60425 + needmode = oldmode;
60426 + if (is_privileged_binary(old_dentry))
60427 + needmode |= GR_SETID;
60428 +
60429 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60430 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60431 + return (GR_CREATE | GR_LINK);
60432 + } else if (newmode & GR_SUPPRESS)
60433 + return GR_SUPPRESS;
60434 + else
60435 + return 0;
60436 +}
60437 +
60438 +int
60439 +gr_check_hidden_task(const struct task_struct *task)
60440 +{
60441 + if (unlikely(!(gr_status & GR_READY)))
60442 + return 0;
60443 +
60444 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60445 + return 1;
60446 +
60447 + return 0;
60448 +}
60449 +
60450 +int
60451 +gr_check_protected_task(const struct task_struct *task)
60452 +{
60453 + if (unlikely(!(gr_status & GR_READY) || !task))
60454 + return 0;
60455 +
60456 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60457 + task->acl != current->acl)
60458 + return 1;
60459 +
60460 + return 0;
60461 +}
60462 +
60463 +int
60464 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60465 +{
60466 + struct task_struct *p;
60467 + int ret = 0;
60468 +
60469 + if (unlikely(!(gr_status & GR_READY) || !pid))
60470 + return ret;
60471 +
60472 + read_lock(&tasklist_lock);
60473 + do_each_pid_task(pid, type, p) {
60474 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60475 + p->acl != current->acl) {
60476 + ret = 1;
60477 + goto out;
60478 + }
60479 + } while_each_pid_task(pid, type, p);
60480 +out:
60481 + read_unlock(&tasklist_lock);
60482 +
60483 + return ret;
60484 +}
60485 +
60486 +void
60487 +gr_copy_label(struct task_struct *tsk)
60488 +{
60489 + tsk->signal->used_accept = 0;
60490 + tsk->acl_sp_role = 0;
60491 + tsk->acl_role_id = current->acl_role_id;
60492 + tsk->acl = current->acl;
60493 + tsk->role = current->role;
60494 + tsk->signal->curr_ip = current->signal->curr_ip;
60495 + tsk->signal->saved_ip = current->signal->saved_ip;
60496 + if (current->exec_file)
60497 + get_file(current->exec_file);
60498 + tsk->exec_file = current->exec_file;
60499 + tsk->is_writable = current->is_writable;
60500 + if (unlikely(current->signal->used_accept)) {
60501 + current->signal->curr_ip = 0;
60502 + current->signal->saved_ip = 0;
60503 + }
60504 +
60505 + return;
60506 +}
60507 +
60508 +static void
60509 +gr_set_proc_res(struct task_struct *task)
60510 +{
60511 + struct acl_subject_label *proc;
60512 + unsigned short i;
60513 +
60514 + proc = task->acl;
60515 +
60516 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60517 + return;
60518 +
60519 + for (i = 0; i < RLIM_NLIMITS; i++) {
60520 + if (!(proc->resmask & (1U << i)))
60521 + continue;
60522 +
60523 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60524 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60525 +
60526 + if (i == RLIMIT_CPU)
60527 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60528 + }
60529 +
60530 + return;
60531 +}
60532 +
60533 +extern int __gr_process_user_ban(struct user_struct *user);
60534 +
60535 +int
60536 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60537 +{
60538 + unsigned int i;
60539 + __u16 num;
60540 + uid_t *uidlist;
60541 + uid_t curuid;
60542 + int realok = 0;
60543 + int effectiveok = 0;
60544 + int fsok = 0;
60545 + uid_t globalreal, globaleffective, globalfs;
60546 +
60547 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60548 + struct user_struct *user;
60549 +
60550 + if (!uid_valid(real))
60551 + goto skipit;
60552 +
60553 + /* find user based on global namespace */
60554 +
60555 + globalreal = GR_GLOBAL_UID(real);
60556 +
60557 + user = find_user(make_kuid(&init_user_ns, globalreal));
60558 + if (user == NULL)
60559 + goto skipit;
60560 +
60561 + if (__gr_process_user_ban(user)) {
60562 + /* for find_user */
60563 + free_uid(user);
60564 + return 1;
60565 + }
60566 +
60567 + /* for find_user */
60568 + free_uid(user);
60569 +
60570 +skipit:
60571 +#endif
60572 +
60573 + if (unlikely(!(gr_status & GR_READY)))
60574 + return 0;
60575 +
60576 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60577 + gr_log_learn_uid_change(real, effective, fs);
60578 +
60579 + num = current->acl->user_trans_num;
60580 + uidlist = current->acl->user_transitions;
60581 +
60582 + if (uidlist == NULL)
60583 + return 0;
60584 +
60585 + if (!uid_valid(real)) {
60586 + realok = 1;
60587 + globalreal = (uid_t)-1;
60588 + } else {
60589 + globalreal = GR_GLOBAL_UID(real);
60590 + }
60591 + if (!uid_valid(effective)) {
60592 + effectiveok = 1;
60593 + globaleffective = (uid_t)-1;
60594 + } else {
60595 + globaleffective = GR_GLOBAL_UID(effective);
60596 + }
60597 + if (!uid_valid(fs)) {
60598 + fsok = 1;
60599 + globalfs = (uid_t)-1;
60600 + } else {
60601 + globalfs = GR_GLOBAL_UID(fs);
60602 + }
60603 +
60604 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60605 + for (i = 0; i < num; i++) {
60606 + curuid = uidlist[i];
60607 + if (globalreal == curuid)
60608 + realok = 1;
60609 + if (globaleffective == curuid)
60610 + effectiveok = 1;
60611 + if (globalfs == curuid)
60612 + fsok = 1;
60613 + }
60614 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60615 + for (i = 0; i < num; i++) {
60616 + curuid = uidlist[i];
60617 + if (globalreal == curuid)
60618 + break;
60619 + if (globaleffective == curuid)
60620 + break;
60621 + if (globalfs == curuid)
60622 + break;
60623 + }
60624 + /* not in deny list */
60625 + if (i == num) {
60626 + realok = 1;
60627 + effectiveok = 1;
60628 + fsok = 1;
60629 + }
60630 + }
60631 +
60632 + if (realok && effectiveok && fsok)
60633 + return 0;
60634 + else {
60635 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60636 + return 1;
60637 + }
60638 +}
60639 +
60640 +int
60641 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60642 +{
60643 + unsigned int i;
60644 + __u16 num;
60645 + gid_t *gidlist;
60646 + gid_t curgid;
60647 + int realok = 0;
60648 + int effectiveok = 0;
60649 + int fsok = 0;
60650 + gid_t globalreal, globaleffective, globalfs;
60651 +
60652 + if (unlikely(!(gr_status & GR_READY)))
60653 + return 0;
60654 +
60655 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60656 + gr_log_learn_gid_change(real, effective, fs);
60657 +
60658 + num = current->acl->group_trans_num;
60659 + gidlist = current->acl->group_transitions;
60660 +
60661 + if (gidlist == NULL)
60662 + return 0;
60663 +
60664 + if (!gid_valid(real)) {
60665 + realok = 1;
60666 + globalreal = (gid_t)-1;
60667 + } else {
60668 + globalreal = GR_GLOBAL_GID(real);
60669 + }
60670 + if (!gid_valid(effective)) {
60671 + effectiveok = 1;
60672 + globaleffective = (gid_t)-1;
60673 + } else {
60674 + globaleffective = GR_GLOBAL_GID(effective);
60675 + }
60676 + if (!gid_valid(fs)) {
60677 + fsok = 1;
60678 + globalfs = (gid_t)-1;
60679 + } else {
60680 + globalfs = GR_GLOBAL_GID(fs);
60681 + }
60682 +
60683 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60684 + for (i = 0; i < num; i++) {
60685 + curgid = gidlist[i];
60686 + if (globalreal == curgid)
60687 + realok = 1;
60688 + if (globaleffective == curgid)
60689 + effectiveok = 1;
60690 + if (globalfs == curgid)
60691 + fsok = 1;
60692 + }
60693 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60694 + for (i = 0; i < num; i++) {
60695 + curgid = gidlist[i];
60696 + if (globalreal == curgid)
60697 + break;
60698 + if (globaleffective == curgid)
60699 + break;
60700 + if (globalfs == curgid)
60701 + break;
60702 + }
60703 + /* not in deny list */
60704 + if (i == num) {
60705 + realok = 1;
60706 + effectiveok = 1;
60707 + fsok = 1;
60708 + }
60709 + }
60710 +
60711 + if (realok && effectiveok && fsok)
60712 + return 0;
60713 + else {
60714 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60715 + return 1;
60716 + }
60717 +}
60718 +
60719 +extern int gr_acl_is_capable(const int cap);
60720 +
60721 +void
60722 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60723 +{
60724 + struct acl_role_label *role = task->role;
60725 + struct acl_subject_label *subj = NULL;
60726 + struct acl_object_label *obj;
60727 + struct file *filp;
60728 + uid_t uid;
60729 + gid_t gid;
60730 +
60731 + if (unlikely(!(gr_status & GR_READY)))
60732 + return;
60733 +
60734 + uid = GR_GLOBAL_UID(kuid);
60735 + gid = GR_GLOBAL_GID(kgid);
60736 +
60737 + filp = task->exec_file;
60738 +
60739 + /* kernel process, we'll give them the kernel role */
60740 + if (unlikely(!filp)) {
60741 + task->role = kernel_role;
60742 + task->acl = kernel_role->root_label;
60743 + return;
60744 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60745 + role = lookup_acl_role_label(task, uid, gid);
60746 +
60747 + /* don't change the role if we're not a privileged process */
60748 + if (role && task->role != role &&
60749 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60750 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60751 + return;
60752 +
60753 + /* perform subject lookup in possibly new role
60754 + we can use this result below in the case where role == task->role
60755 + */
60756 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60757 +
60758 + /* if we changed uid/gid, but result in the same role
60759 + and are using inheritance, don't lose the inherited subject
60760 + if current subject is other than what normal lookup
60761 + would result in, we arrived via inheritance, don't
60762 + lose subject
60763 + */
60764 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60765 + (subj == task->acl)))
60766 + task->acl = subj;
60767 +
60768 + task->role = role;
60769 +
60770 + task->is_writable = 0;
60771 +
60772 + /* ignore additional mmap checks for processes that are writable
60773 + by the default ACL */
60774 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60775 + if (unlikely(obj->mode & GR_WRITE))
60776 + task->is_writable = 1;
60777 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60778 + if (unlikely(obj->mode & GR_WRITE))
60779 + task->is_writable = 1;
60780 +
60781 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60782 + 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);
60783 +#endif
60784 +
60785 + gr_set_proc_res(task);
60786 +
60787 + return;
60788 +}
60789 +
60790 +int
60791 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60792 + const int unsafe_flags)
60793 +{
60794 + struct task_struct *task = current;
60795 + struct acl_subject_label *newacl;
60796 + struct acl_object_label *obj;
60797 + __u32 retmode;
60798 +
60799 + if (unlikely(!(gr_status & GR_READY)))
60800 + return 0;
60801 +
60802 + newacl = chk_subj_label(dentry, mnt, task->role);
60803 +
60804 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60805 + did an exec
60806 + */
60807 + rcu_read_lock();
60808 + read_lock(&tasklist_lock);
60809 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60810 + (task->parent->acl->mode & GR_POVERRIDE))) {
60811 + read_unlock(&tasklist_lock);
60812 + rcu_read_unlock();
60813 + goto skip_check;
60814 + }
60815 + read_unlock(&tasklist_lock);
60816 + rcu_read_unlock();
60817 +
60818 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60819 + !(task->role->roletype & GR_ROLE_GOD) &&
60820 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60821 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60822 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60823 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60824 + else
60825 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60826 + return -EACCES;
60827 + }
60828 +
60829 +skip_check:
60830 +
60831 + obj = chk_obj_label(dentry, mnt, task->acl);
60832 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60833 +
60834 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60835 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60836 + if (obj->nested)
60837 + task->acl = obj->nested;
60838 + else
60839 + task->acl = newacl;
60840 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60841 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60842 +
60843 + task->is_writable = 0;
60844 +
60845 + /* ignore additional mmap checks for processes that are writable
60846 + by the default ACL */
60847 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60848 + if (unlikely(obj->mode & GR_WRITE))
60849 + task->is_writable = 1;
60850 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60851 + if (unlikely(obj->mode & GR_WRITE))
60852 + task->is_writable = 1;
60853 +
60854 + gr_set_proc_res(task);
60855 +
60856 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60857 + 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);
60858 +#endif
60859 + return 0;
60860 +}
60861 +
60862 +/* always called with valid inodev ptr */
60863 +static void
60864 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60865 +{
60866 + struct acl_object_label *matchpo;
60867 + struct acl_subject_label *matchps;
60868 + struct acl_subject_label *subj;
60869 + struct acl_role_label *role;
60870 + unsigned int x;
60871 +
60872 + FOR_EACH_ROLE_START(role)
60873 + FOR_EACH_SUBJECT_START(role, subj, x)
60874 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60875 + matchpo->mode |= GR_DELETED;
60876 + FOR_EACH_SUBJECT_END(subj,x)
60877 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60878 + /* nested subjects aren't in the role's subj_hash table */
60879 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60880 + matchpo->mode |= GR_DELETED;
60881 + FOR_EACH_NESTED_SUBJECT_END(subj)
60882 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60883 + matchps->mode |= GR_DELETED;
60884 + FOR_EACH_ROLE_END(role)
60885 +
60886 + inodev->nentry->deleted = 1;
60887 +
60888 + return;
60889 +}
60890 +
60891 +void
60892 +gr_handle_delete(const ino_t ino, const dev_t dev)
60893 +{
60894 + struct inodev_entry *inodev;
60895 +
60896 + if (unlikely(!(gr_status & GR_READY)))
60897 + return;
60898 +
60899 + write_lock(&gr_inode_lock);
60900 + inodev = lookup_inodev_entry(ino, dev);
60901 + if (inodev != NULL)
60902 + do_handle_delete(inodev, ino, dev);
60903 + write_unlock(&gr_inode_lock);
60904 +
60905 + return;
60906 +}
60907 +
60908 +static void
60909 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60910 + const ino_t newinode, const dev_t newdevice,
60911 + struct acl_subject_label *subj)
60912 +{
60913 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60914 + struct acl_object_label *match;
60915 +
60916 + match = subj->obj_hash[index];
60917 +
60918 + while (match && (match->inode != oldinode ||
60919 + match->device != olddevice ||
60920 + !(match->mode & GR_DELETED)))
60921 + match = match->next;
60922 +
60923 + if (match && (match->inode == oldinode)
60924 + && (match->device == olddevice)
60925 + && (match->mode & GR_DELETED)) {
60926 + if (match->prev == NULL) {
60927 + subj->obj_hash[index] = match->next;
60928 + if (match->next != NULL)
60929 + match->next->prev = NULL;
60930 + } else {
60931 + match->prev->next = match->next;
60932 + if (match->next != NULL)
60933 + match->next->prev = match->prev;
60934 + }
60935 + match->prev = NULL;
60936 + match->next = NULL;
60937 + match->inode = newinode;
60938 + match->device = newdevice;
60939 + match->mode &= ~GR_DELETED;
60940 +
60941 + insert_acl_obj_label(match, subj);
60942 + }
60943 +
60944 + return;
60945 +}
60946 +
60947 +static void
60948 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60949 + const ino_t newinode, const dev_t newdevice,
60950 + struct acl_role_label *role)
60951 +{
60952 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60953 + struct acl_subject_label *match;
60954 +
60955 + match = role->subj_hash[index];
60956 +
60957 + while (match && (match->inode != oldinode ||
60958 + match->device != olddevice ||
60959 + !(match->mode & GR_DELETED)))
60960 + match = match->next;
60961 +
60962 + if (match && (match->inode == oldinode)
60963 + && (match->device == olddevice)
60964 + && (match->mode & GR_DELETED)) {
60965 + if (match->prev == NULL) {
60966 + role->subj_hash[index] = match->next;
60967 + if (match->next != NULL)
60968 + match->next->prev = NULL;
60969 + } else {
60970 + match->prev->next = match->next;
60971 + if (match->next != NULL)
60972 + match->next->prev = match->prev;
60973 + }
60974 + match->prev = NULL;
60975 + match->next = NULL;
60976 + match->inode = newinode;
60977 + match->device = newdevice;
60978 + match->mode &= ~GR_DELETED;
60979 +
60980 + insert_acl_subj_label(match, role);
60981 + }
60982 +
60983 + return;
60984 +}
60985 +
60986 +static void
60987 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60988 + const ino_t newinode, const dev_t newdevice)
60989 +{
60990 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60991 + struct inodev_entry *match;
60992 +
60993 + match = inodev_set.i_hash[index];
60994 +
60995 + while (match && (match->nentry->inode != oldinode ||
60996 + match->nentry->device != olddevice || !match->nentry->deleted))
60997 + match = match->next;
60998 +
60999 + if (match && (match->nentry->inode == oldinode)
61000 + && (match->nentry->device == olddevice) &&
61001 + match->nentry->deleted) {
61002 + if (match->prev == NULL) {
61003 + inodev_set.i_hash[index] = match->next;
61004 + if (match->next != NULL)
61005 + match->next->prev = NULL;
61006 + } else {
61007 + match->prev->next = match->next;
61008 + if (match->next != NULL)
61009 + match->next->prev = match->prev;
61010 + }
61011 + match->prev = NULL;
61012 + match->next = NULL;
61013 + match->nentry->inode = newinode;
61014 + match->nentry->device = newdevice;
61015 + match->nentry->deleted = 0;
61016 +
61017 + insert_inodev_entry(match);
61018 + }
61019 +
61020 + return;
61021 +}
61022 +
61023 +static void
61024 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61025 +{
61026 + struct acl_subject_label *subj;
61027 + struct acl_role_label *role;
61028 + unsigned int x;
61029 +
61030 + FOR_EACH_ROLE_START(role)
61031 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61032 +
61033 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61034 + if ((subj->inode == ino) && (subj->device == dev)) {
61035 + subj->inode = ino;
61036 + subj->device = dev;
61037 + }
61038 + /* nested subjects aren't in the role's subj_hash table */
61039 + update_acl_obj_label(matchn->inode, matchn->device,
61040 + ino, dev, subj);
61041 + FOR_EACH_NESTED_SUBJECT_END(subj)
61042 + FOR_EACH_SUBJECT_START(role, subj, x)
61043 + update_acl_obj_label(matchn->inode, matchn->device,
61044 + ino, dev, subj);
61045 + FOR_EACH_SUBJECT_END(subj,x)
61046 + FOR_EACH_ROLE_END(role)
61047 +
61048 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61049 +
61050 + return;
61051 +}
61052 +
61053 +static void
61054 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61055 + const struct vfsmount *mnt)
61056 +{
61057 + ino_t ino = dentry->d_inode->i_ino;
61058 + dev_t dev = __get_dev(dentry);
61059 +
61060 + __do_handle_create(matchn, ino, dev);
61061 +
61062 + return;
61063 +}
61064 +
61065 +void
61066 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61067 +{
61068 + struct name_entry *matchn;
61069 +
61070 + if (unlikely(!(gr_status & GR_READY)))
61071 + return;
61072 +
61073 + preempt_disable();
61074 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61075 +
61076 + if (unlikely((unsigned long)matchn)) {
61077 + write_lock(&gr_inode_lock);
61078 + do_handle_create(matchn, dentry, mnt);
61079 + write_unlock(&gr_inode_lock);
61080 + }
61081 + preempt_enable();
61082 +
61083 + return;
61084 +}
61085 +
61086 +void
61087 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61088 +{
61089 + struct name_entry *matchn;
61090 +
61091 + if (unlikely(!(gr_status & GR_READY)))
61092 + return;
61093 +
61094 + preempt_disable();
61095 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61096 +
61097 + if (unlikely((unsigned long)matchn)) {
61098 + write_lock(&gr_inode_lock);
61099 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61100 + write_unlock(&gr_inode_lock);
61101 + }
61102 + preempt_enable();
61103 +
61104 + return;
61105 +}
61106 +
61107 +void
61108 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61109 + struct dentry *old_dentry,
61110 + struct dentry *new_dentry,
61111 + struct vfsmount *mnt, const __u8 replace)
61112 +{
61113 + struct name_entry *matchn;
61114 + struct inodev_entry *inodev;
61115 + struct inode *inode = new_dentry->d_inode;
61116 + ino_t old_ino = old_dentry->d_inode->i_ino;
61117 + dev_t old_dev = __get_dev(old_dentry);
61118 +
61119 + /* vfs_rename swaps the name and parent link for old_dentry and
61120 + new_dentry
61121 + at this point, old_dentry has the new name, parent link, and inode
61122 + for the renamed file
61123 + if a file is being replaced by a rename, new_dentry has the inode
61124 + and name for the replaced file
61125 + */
61126 +
61127 + if (unlikely(!(gr_status & GR_READY)))
61128 + return;
61129 +
61130 + preempt_disable();
61131 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61132 +
61133 + /* we wouldn't have to check d_inode if it weren't for
61134 + NFS silly-renaming
61135 + */
61136 +
61137 + write_lock(&gr_inode_lock);
61138 + if (unlikely(replace && inode)) {
61139 + ino_t new_ino = inode->i_ino;
61140 + dev_t new_dev = __get_dev(new_dentry);
61141 +
61142 + inodev = lookup_inodev_entry(new_ino, new_dev);
61143 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61144 + do_handle_delete(inodev, new_ino, new_dev);
61145 + }
61146 +
61147 + inodev = lookup_inodev_entry(old_ino, old_dev);
61148 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61149 + do_handle_delete(inodev, old_ino, old_dev);
61150 +
61151 + if (unlikely((unsigned long)matchn))
61152 + do_handle_create(matchn, old_dentry, mnt);
61153 +
61154 + write_unlock(&gr_inode_lock);
61155 + preempt_enable();
61156 +
61157 + return;
61158 +}
61159 +
61160 +static int
61161 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61162 + unsigned char **sum)
61163 +{
61164 + struct acl_role_label *r;
61165 + struct role_allowed_ip *ipp;
61166 + struct role_transition *trans;
61167 + unsigned int i;
61168 + int found = 0;
61169 + u32 curr_ip = current->signal->curr_ip;
61170 +
61171 + current->signal->saved_ip = curr_ip;
61172 +
61173 + /* check transition table */
61174 +
61175 + for (trans = current->role->transitions; trans; trans = trans->next) {
61176 + if (!strcmp(rolename, trans->rolename)) {
61177 + found = 1;
61178 + break;
61179 + }
61180 + }
61181 +
61182 + if (!found)
61183 + return 0;
61184 +
61185 + /* handle special roles that do not require authentication
61186 + and check ip */
61187 +
61188 + FOR_EACH_ROLE_START(r)
61189 + if (!strcmp(rolename, r->rolename) &&
61190 + (r->roletype & GR_ROLE_SPECIAL)) {
61191 + found = 0;
61192 + if (r->allowed_ips != NULL) {
61193 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61194 + if ((ntohl(curr_ip) & ipp->netmask) ==
61195 + (ntohl(ipp->addr) & ipp->netmask))
61196 + found = 1;
61197 + }
61198 + } else
61199 + found = 2;
61200 + if (!found)
61201 + return 0;
61202 +
61203 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61204 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61205 + *salt = NULL;
61206 + *sum = NULL;
61207 + return 1;
61208 + }
61209 + }
61210 + FOR_EACH_ROLE_END(r)
61211 +
61212 + for (i = 0; i < num_sprole_pws; i++) {
61213 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61214 + *salt = acl_special_roles[i]->salt;
61215 + *sum = acl_special_roles[i]->sum;
61216 + return 1;
61217 + }
61218 + }
61219 +
61220 + return 0;
61221 +}
61222 +
61223 +static void
61224 +assign_special_role(char *rolename)
61225 +{
61226 + struct acl_object_label *obj;
61227 + struct acl_role_label *r;
61228 + struct acl_role_label *assigned = NULL;
61229 + struct task_struct *tsk;
61230 + struct file *filp;
61231 +
61232 + FOR_EACH_ROLE_START(r)
61233 + if (!strcmp(rolename, r->rolename) &&
61234 + (r->roletype & GR_ROLE_SPECIAL)) {
61235 + assigned = r;
61236 + break;
61237 + }
61238 + FOR_EACH_ROLE_END(r)
61239 +
61240 + if (!assigned)
61241 + return;
61242 +
61243 + read_lock(&tasklist_lock);
61244 + read_lock(&grsec_exec_file_lock);
61245 +
61246 + tsk = current->real_parent;
61247 + if (tsk == NULL)
61248 + goto out_unlock;
61249 +
61250 + filp = tsk->exec_file;
61251 + if (filp == NULL)
61252 + goto out_unlock;
61253 +
61254 + tsk->is_writable = 0;
61255 +
61256 + tsk->acl_sp_role = 1;
61257 + tsk->acl_role_id = ++acl_sp_role_value;
61258 + tsk->role = assigned;
61259 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61260 +
61261 + /* ignore additional mmap checks for processes that are writable
61262 + by the default ACL */
61263 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61264 + if (unlikely(obj->mode & GR_WRITE))
61265 + tsk->is_writable = 1;
61266 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61267 + if (unlikely(obj->mode & GR_WRITE))
61268 + tsk->is_writable = 1;
61269 +
61270 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61271 + 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));
61272 +#endif
61273 +
61274 +out_unlock:
61275 + read_unlock(&grsec_exec_file_lock);
61276 + read_unlock(&tasklist_lock);
61277 + return;
61278 +}
61279 +
61280 +int gr_check_secure_terminal(struct task_struct *task)
61281 +{
61282 + struct task_struct *p, *p2, *p3;
61283 + struct files_struct *files;
61284 + struct fdtable *fdt;
61285 + struct file *our_file = NULL, *file;
61286 + int i;
61287 +
61288 + if (task->signal->tty == NULL)
61289 + return 1;
61290 +
61291 + files = get_files_struct(task);
61292 + if (files != NULL) {
61293 + rcu_read_lock();
61294 + fdt = files_fdtable(files);
61295 + for (i=0; i < fdt->max_fds; i++) {
61296 + file = fcheck_files(files, i);
61297 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61298 + get_file(file);
61299 + our_file = file;
61300 + }
61301 + }
61302 + rcu_read_unlock();
61303 + put_files_struct(files);
61304 + }
61305 +
61306 + if (our_file == NULL)
61307 + return 1;
61308 +
61309 + read_lock(&tasklist_lock);
61310 + do_each_thread(p2, p) {
61311 + files = get_files_struct(p);
61312 + if (files == NULL ||
61313 + (p->signal && p->signal->tty == task->signal->tty)) {
61314 + if (files != NULL)
61315 + put_files_struct(files);
61316 + continue;
61317 + }
61318 + rcu_read_lock();
61319 + fdt = files_fdtable(files);
61320 + for (i=0; i < fdt->max_fds; i++) {
61321 + file = fcheck_files(files, i);
61322 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61323 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61324 + p3 = task;
61325 + while (task_pid_nr(p3) > 0) {
61326 + if (p3 == p)
61327 + break;
61328 + p3 = p3->real_parent;
61329 + }
61330 + if (p3 == p)
61331 + break;
61332 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61333 + gr_handle_alertkill(p);
61334 + rcu_read_unlock();
61335 + put_files_struct(files);
61336 + read_unlock(&tasklist_lock);
61337 + fput(our_file);
61338 + return 0;
61339 + }
61340 + }
61341 + rcu_read_unlock();
61342 + put_files_struct(files);
61343 + } while_each_thread(p2, p);
61344 + read_unlock(&tasklist_lock);
61345 +
61346 + fput(our_file);
61347 + return 1;
61348 +}
61349 +
61350 +static int gr_rbac_disable(void *unused)
61351 +{
61352 + pax_open_kernel();
61353 + gr_status &= ~GR_READY;
61354 + pax_close_kernel();
61355 +
61356 + return 0;
61357 +}
61358 +
61359 +ssize_t
61360 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61361 +{
61362 + struct gr_arg_wrapper uwrap;
61363 + unsigned char *sprole_salt = NULL;
61364 + unsigned char *sprole_sum = NULL;
61365 + int error = sizeof (struct gr_arg_wrapper);
61366 + int error2 = 0;
61367 +
61368 + mutex_lock(&gr_dev_mutex);
61369 +
61370 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61371 + error = -EPERM;
61372 + goto out;
61373 + }
61374 +
61375 + if (count != sizeof (struct gr_arg_wrapper)) {
61376 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61377 + error = -EINVAL;
61378 + goto out;
61379 + }
61380 +
61381 +
61382 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61383 + gr_auth_expires = 0;
61384 + gr_auth_attempts = 0;
61385 + }
61386 +
61387 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61388 + error = -EFAULT;
61389 + goto out;
61390 + }
61391 +
61392 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61393 + error = -EINVAL;
61394 + goto out;
61395 + }
61396 +
61397 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61398 + error = -EFAULT;
61399 + goto out;
61400 + }
61401 +
61402 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61403 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61404 + time_after(gr_auth_expires, get_seconds())) {
61405 + error = -EBUSY;
61406 + goto out;
61407 + }
61408 +
61409 + /* if non-root trying to do anything other than use a special role,
61410 + do not attempt authentication, do not count towards authentication
61411 + locking
61412 + */
61413 +
61414 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61415 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61416 + gr_is_global_nonroot(current_uid())) {
61417 + error = -EPERM;
61418 + goto out;
61419 + }
61420 +
61421 + /* ensure pw and special role name are null terminated */
61422 +
61423 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61424 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61425 +
61426 + /* Okay.
61427 + * We have our enough of the argument structure..(we have yet
61428 + * to copy_from_user the tables themselves) . Copy the tables
61429 + * only if we need them, i.e. for loading operations. */
61430 +
61431 + switch (gr_usermode->mode) {
61432 + case GR_STATUS:
61433 + if (gr_status & GR_READY) {
61434 + error = 1;
61435 + if (!gr_check_secure_terminal(current))
61436 + error = 3;
61437 + } else
61438 + error = 2;
61439 + goto out;
61440 + case GR_SHUTDOWN:
61441 + if ((gr_status & GR_READY)
61442 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61443 + stop_machine(gr_rbac_disable, NULL, NULL);
61444 + free_variables();
61445 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61446 + memset(gr_system_salt, 0, GR_SALT_LEN);
61447 + memset(gr_system_sum, 0, GR_SHA_LEN);
61448 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61449 + } else if (gr_status & GR_READY) {
61450 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61451 + error = -EPERM;
61452 + } else {
61453 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61454 + error = -EAGAIN;
61455 + }
61456 + break;
61457 + case GR_ENABLE:
61458 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61459 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61460 + else {
61461 + if (gr_status & GR_READY)
61462 + error = -EAGAIN;
61463 + else
61464 + error = error2;
61465 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61466 + }
61467 + break;
61468 + case GR_RELOAD:
61469 + if (!(gr_status & GR_READY)) {
61470 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61471 + error = -EAGAIN;
61472 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61473 + stop_machine(gr_rbac_disable, NULL, NULL);
61474 + free_variables();
61475 + error2 = gracl_init(gr_usermode);
61476 + if (!error2)
61477 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61478 + else {
61479 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61480 + error = error2;
61481 + }
61482 + } else {
61483 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61484 + error = -EPERM;
61485 + }
61486 + break;
61487 + case GR_SEGVMOD:
61488 + if (unlikely(!(gr_status & GR_READY))) {
61489 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61490 + error = -EAGAIN;
61491 + break;
61492 + }
61493 +
61494 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61495 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61496 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61497 + struct acl_subject_label *segvacl;
61498 + segvacl =
61499 + lookup_acl_subj_label(gr_usermode->segv_inode,
61500 + gr_usermode->segv_device,
61501 + current->role);
61502 + if (segvacl) {
61503 + segvacl->crashes = 0;
61504 + segvacl->expires = 0;
61505 + }
61506 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61507 + gr_remove_uid(gr_usermode->segv_uid);
61508 + }
61509 + } else {
61510 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61511 + error = -EPERM;
61512 + }
61513 + break;
61514 + case GR_SPROLE:
61515 + case GR_SPROLEPAM:
61516 + if (unlikely(!(gr_status & GR_READY))) {
61517 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61518 + error = -EAGAIN;
61519 + break;
61520 + }
61521 +
61522 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61523 + current->role->expires = 0;
61524 + current->role->auth_attempts = 0;
61525 + }
61526 +
61527 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61528 + time_after(current->role->expires, get_seconds())) {
61529 + error = -EBUSY;
61530 + goto out;
61531 + }
61532 +
61533 + if (lookup_special_role_auth
61534 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61535 + && ((!sprole_salt && !sprole_sum)
61536 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61537 + char *p = "";
61538 + assign_special_role(gr_usermode->sp_role);
61539 + read_lock(&tasklist_lock);
61540 + if (current->real_parent)
61541 + p = current->real_parent->role->rolename;
61542 + read_unlock(&tasklist_lock);
61543 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61544 + p, acl_sp_role_value);
61545 + } else {
61546 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61547 + error = -EPERM;
61548 + if(!(current->role->auth_attempts++))
61549 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61550 +
61551 + goto out;
61552 + }
61553 + break;
61554 + case GR_UNSPROLE:
61555 + if (unlikely(!(gr_status & GR_READY))) {
61556 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61557 + error = -EAGAIN;
61558 + break;
61559 + }
61560 +
61561 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61562 + char *p = "";
61563 + int i = 0;
61564 +
61565 + read_lock(&tasklist_lock);
61566 + if (current->real_parent) {
61567 + p = current->real_parent->role->rolename;
61568 + i = current->real_parent->acl_role_id;
61569 + }
61570 + read_unlock(&tasklist_lock);
61571 +
61572 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61573 + gr_set_acls(1);
61574 + } else {
61575 + error = -EPERM;
61576 + goto out;
61577 + }
61578 + break;
61579 + default:
61580 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61581 + error = -EINVAL;
61582 + break;
61583 + }
61584 +
61585 + if (error != -EPERM)
61586 + goto out;
61587 +
61588 + if(!(gr_auth_attempts++))
61589 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61590 +
61591 + out:
61592 + mutex_unlock(&gr_dev_mutex);
61593 + return error;
61594 +}
61595 +
61596 +/* must be called with
61597 + rcu_read_lock();
61598 + read_lock(&tasklist_lock);
61599 + read_lock(&grsec_exec_file_lock);
61600 +*/
61601 +int gr_apply_subject_to_task(struct task_struct *task)
61602 +{
61603 + struct acl_object_label *obj;
61604 + char *tmpname;
61605 + struct acl_subject_label *tmpsubj;
61606 + struct file *filp;
61607 + struct name_entry *nmatch;
61608 +
61609 + filp = task->exec_file;
61610 + if (filp == NULL)
61611 + return 0;
61612 +
61613 + /* the following is to apply the correct subject
61614 + on binaries running when the RBAC system
61615 + is enabled, when the binaries have been
61616 + replaced or deleted since their execution
61617 + -----
61618 + when the RBAC system starts, the inode/dev
61619 + from exec_file will be one the RBAC system
61620 + is unaware of. It only knows the inode/dev
61621 + of the present file on disk, or the absence
61622 + of it.
61623 + */
61624 + preempt_disable();
61625 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61626 +
61627 + nmatch = lookup_name_entry(tmpname);
61628 + preempt_enable();
61629 + tmpsubj = NULL;
61630 + if (nmatch) {
61631 + if (nmatch->deleted)
61632 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61633 + else
61634 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61635 + if (tmpsubj != NULL)
61636 + task->acl = tmpsubj;
61637 + }
61638 + if (tmpsubj == NULL)
61639 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61640 + task->role);
61641 + if (task->acl) {
61642 + task->is_writable = 0;
61643 + /* ignore additional mmap checks for processes that are writable
61644 + by the default ACL */
61645 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61646 + if (unlikely(obj->mode & GR_WRITE))
61647 + task->is_writable = 1;
61648 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61649 + if (unlikely(obj->mode & GR_WRITE))
61650 + task->is_writable = 1;
61651 +
61652 + gr_set_proc_res(task);
61653 +
61654 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61655 + 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);
61656 +#endif
61657 + } else {
61658 + return 1;
61659 + }
61660 +
61661 + return 0;
61662 +}
61663 +
61664 +int
61665 +gr_set_acls(const int type)
61666 +{
61667 + struct task_struct *task, *task2;
61668 + struct acl_role_label *role = current->role;
61669 + __u16 acl_role_id = current->acl_role_id;
61670 + const struct cred *cred;
61671 + int ret;
61672 +
61673 + rcu_read_lock();
61674 + read_lock(&tasklist_lock);
61675 + read_lock(&grsec_exec_file_lock);
61676 + do_each_thread(task2, task) {
61677 + /* check to see if we're called from the exit handler,
61678 + if so, only replace ACLs that have inherited the admin
61679 + ACL */
61680 +
61681 + if (type && (task->role != role ||
61682 + task->acl_role_id != acl_role_id))
61683 + continue;
61684 +
61685 + task->acl_role_id = 0;
61686 + task->acl_sp_role = 0;
61687 +
61688 + if (task->exec_file) {
61689 + cred = __task_cred(task);
61690 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61691 + ret = gr_apply_subject_to_task(task);
61692 + if (ret) {
61693 + read_unlock(&grsec_exec_file_lock);
61694 + read_unlock(&tasklist_lock);
61695 + rcu_read_unlock();
61696 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61697 + return ret;
61698 + }
61699 + } else {
61700 + // it's a kernel process
61701 + task->role = kernel_role;
61702 + task->acl = kernel_role->root_label;
61703 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61704 + task->acl->mode &= ~GR_PROCFIND;
61705 +#endif
61706 + }
61707 + } while_each_thread(task2, task);
61708 + read_unlock(&grsec_exec_file_lock);
61709 + read_unlock(&tasklist_lock);
61710 + rcu_read_unlock();
61711 +
61712 + return 0;
61713 +}
61714 +
61715 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61716 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61717 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61718 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61719 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61720 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61721 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61722 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61723 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61724 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61725 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61726 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61727 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61728 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61729 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61730 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61731 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61732 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61733 +};
61734 +
61735 +void
61736 +gr_learn_resource(const struct task_struct *task,
61737 + const int res, const unsigned long wanted, const int gt)
61738 +{
61739 + struct acl_subject_label *acl;
61740 + const struct cred *cred;
61741 +
61742 + if (unlikely((gr_status & GR_READY) &&
61743 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61744 + goto skip_reslog;
61745 +
61746 + gr_log_resource(task, res, wanted, gt);
61747 +skip_reslog:
61748 +
61749 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61750 + return;
61751 +
61752 + acl = task->acl;
61753 +
61754 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61755 + !(acl->resmask & (1U << (unsigned short) res))))
61756 + return;
61757 +
61758 + if (wanted >= acl->res[res].rlim_cur) {
61759 + unsigned long res_add;
61760 +
61761 + res_add = wanted + res_learn_bumps[res];
61762 +
61763 + acl->res[res].rlim_cur = res_add;
61764 +
61765 + if (wanted > acl->res[res].rlim_max)
61766 + acl->res[res].rlim_max = res_add;
61767 +
61768 + /* only log the subject filename, since resource logging is supported for
61769 + single-subject learning only */
61770 + rcu_read_lock();
61771 + cred = __task_cred(task);
61772 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61773 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61774 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61775 + "", (unsigned long) res, &task->signal->saved_ip);
61776 + rcu_read_unlock();
61777 + }
61778 +
61779 + return;
61780 +}
61781 +EXPORT_SYMBOL(gr_learn_resource);
61782 +#endif
61783 +
61784 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61785 +void
61786 +pax_set_initial_flags(struct linux_binprm *bprm)
61787 +{
61788 + struct task_struct *task = current;
61789 + struct acl_subject_label *proc;
61790 + unsigned long flags;
61791 +
61792 + if (unlikely(!(gr_status & GR_READY)))
61793 + return;
61794 +
61795 + flags = pax_get_flags(task);
61796 +
61797 + proc = task->acl;
61798 +
61799 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61800 + flags &= ~MF_PAX_PAGEEXEC;
61801 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61802 + flags &= ~MF_PAX_SEGMEXEC;
61803 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61804 + flags &= ~MF_PAX_RANDMMAP;
61805 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61806 + flags &= ~MF_PAX_EMUTRAMP;
61807 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61808 + flags &= ~MF_PAX_MPROTECT;
61809 +
61810 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61811 + flags |= MF_PAX_PAGEEXEC;
61812 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61813 + flags |= MF_PAX_SEGMEXEC;
61814 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61815 + flags |= MF_PAX_RANDMMAP;
61816 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61817 + flags |= MF_PAX_EMUTRAMP;
61818 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61819 + flags |= MF_PAX_MPROTECT;
61820 +
61821 + pax_set_flags(task, flags);
61822 +
61823 + return;
61824 +}
61825 +#endif
61826 +
61827 +int
61828 +gr_handle_proc_ptrace(struct task_struct *task)
61829 +{
61830 + struct file *filp;
61831 + struct task_struct *tmp = task;
61832 + struct task_struct *curtemp = current;
61833 + __u32 retmode;
61834 +
61835 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61836 + if (unlikely(!(gr_status & GR_READY)))
61837 + return 0;
61838 +#endif
61839 +
61840 + read_lock(&tasklist_lock);
61841 + read_lock(&grsec_exec_file_lock);
61842 + filp = task->exec_file;
61843 +
61844 + while (task_pid_nr(tmp) > 0) {
61845 + if (tmp == curtemp)
61846 + break;
61847 + tmp = tmp->real_parent;
61848 + }
61849 +
61850 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61851 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61852 + read_unlock(&grsec_exec_file_lock);
61853 + read_unlock(&tasklist_lock);
61854 + return 1;
61855 + }
61856 +
61857 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61858 + if (!(gr_status & GR_READY)) {
61859 + read_unlock(&grsec_exec_file_lock);
61860 + read_unlock(&tasklist_lock);
61861 + return 0;
61862 + }
61863 +#endif
61864 +
61865 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61866 + read_unlock(&grsec_exec_file_lock);
61867 + read_unlock(&tasklist_lock);
61868 +
61869 + if (retmode & GR_NOPTRACE)
61870 + return 1;
61871 +
61872 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61873 + && (current->acl != task->acl || (current->acl != current->role->root_label
61874 + && task_pid_nr(current) != task_pid_nr(task))))
61875 + return 1;
61876 +
61877 + return 0;
61878 +}
61879 +
61880 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61881 +{
61882 + if (unlikely(!(gr_status & GR_READY)))
61883 + return;
61884 +
61885 + if (!(current->role->roletype & GR_ROLE_GOD))
61886 + return;
61887 +
61888 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61889 + p->role->rolename, gr_task_roletype_to_char(p),
61890 + p->acl->filename);
61891 +}
61892 +
61893 +int
61894 +gr_handle_ptrace(struct task_struct *task, const long request)
61895 +{
61896 + struct task_struct *tmp = task;
61897 + struct task_struct *curtemp = current;
61898 + __u32 retmode;
61899 +
61900 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61901 + if (unlikely(!(gr_status & GR_READY)))
61902 + return 0;
61903 +#endif
61904 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61905 + read_lock(&tasklist_lock);
61906 + while (task_pid_nr(tmp) > 0) {
61907 + if (tmp == curtemp)
61908 + break;
61909 + tmp = tmp->real_parent;
61910 + }
61911 +
61912 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61913 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61914 + read_unlock(&tasklist_lock);
61915 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61916 + return 1;
61917 + }
61918 + read_unlock(&tasklist_lock);
61919 + }
61920 +
61921 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61922 + if (!(gr_status & GR_READY))
61923 + return 0;
61924 +#endif
61925 +
61926 + read_lock(&grsec_exec_file_lock);
61927 + if (unlikely(!task->exec_file)) {
61928 + read_unlock(&grsec_exec_file_lock);
61929 + return 0;
61930 + }
61931 +
61932 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61933 + read_unlock(&grsec_exec_file_lock);
61934 +
61935 + if (retmode & GR_NOPTRACE) {
61936 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61937 + return 1;
61938 + }
61939 +
61940 + if (retmode & GR_PTRACERD) {
61941 + switch (request) {
61942 + case PTRACE_SEIZE:
61943 + case PTRACE_POKETEXT:
61944 + case PTRACE_POKEDATA:
61945 + case PTRACE_POKEUSR:
61946 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61947 + case PTRACE_SETREGS:
61948 + case PTRACE_SETFPREGS:
61949 +#endif
61950 +#ifdef CONFIG_X86
61951 + case PTRACE_SETFPXREGS:
61952 +#endif
61953 +#ifdef CONFIG_ALTIVEC
61954 + case PTRACE_SETVRREGS:
61955 +#endif
61956 + return 1;
61957 + default:
61958 + return 0;
61959 + }
61960 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61961 + !(current->role->roletype & GR_ROLE_GOD) &&
61962 + (current->acl != task->acl)) {
61963 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61964 + return 1;
61965 + }
61966 +
61967 + return 0;
61968 +}
61969 +
61970 +static int is_writable_mmap(const struct file *filp)
61971 +{
61972 + struct task_struct *task = current;
61973 + struct acl_object_label *obj, *obj2;
61974 +
61975 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61976 + !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))) {
61977 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61978 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61979 + task->role->root_label);
61980 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61981 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61982 + return 1;
61983 + }
61984 + }
61985 + return 0;
61986 +}
61987 +
61988 +int
61989 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61990 +{
61991 + __u32 mode;
61992 +
61993 + if (unlikely(!file || !(prot & PROT_EXEC)))
61994 + return 1;
61995 +
61996 + if (is_writable_mmap(file))
61997 + return 0;
61998 +
61999 + mode =
62000 + gr_search_file(file->f_path.dentry,
62001 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62002 + file->f_path.mnt);
62003 +
62004 + if (!gr_tpe_allow(file))
62005 + return 0;
62006 +
62007 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62008 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62009 + return 0;
62010 + } else if (unlikely(!(mode & GR_EXEC))) {
62011 + return 0;
62012 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62013 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62014 + return 1;
62015 + }
62016 +
62017 + return 1;
62018 +}
62019 +
62020 +int
62021 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62022 +{
62023 + __u32 mode;
62024 +
62025 + if (unlikely(!file || !(prot & PROT_EXEC)))
62026 + return 1;
62027 +
62028 + if (is_writable_mmap(file))
62029 + return 0;
62030 +
62031 + mode =
62032 + gr_search_file(file->f_path.dentry,
62033 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62034 + file->f_path.mnt);
62035 +
62036 + if (!gr_tpe_allow(file))
62037 + return 0;
62038 +
62039 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62040 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62041 + return 0;
62042 + } else if (unlikely(!(mode & GR_EXEC))) {
62043 + return 0;
62044 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62045 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62046 + return 1;
62047 + }
62048 +
62049 + return 1;
62050 +}
62051 +
62052 +void
62053 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62054 +{
62055 + unsigned long runtime;
62056 + unsigned long cputime;
62057 + unsigned int wday, cday;
62058 + __u8 whr, chr;
62059 + __u8 wmin, cmin;
62060 + __u8 wsec, csec;
62061 + struct timespec timeval;
62062 +
62063 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62064 + !(task->acl->mode & GR_PROCACCT)))
62065 + return;
62066 +
62067 + do_posix_clock_monotonic_gettime(&timeval);
62068 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62069 + wday = runtime / (3600 * 24);
62070 + runtime -= wday * (3600 * 24);
62071 + whr = runtime / 3600;
62072 + runtime -= whr * 3600;
62073 + wmin = runtime / 60;
62074 + runtime -= wmin * 60;
62075 + wsec = runtime;
62076 +
62077 + cputime = (task->utime + task->stime) / HZ;
62078 + cday = cputime / (3600 * 24);
62079 + cputime -= cday * (3600 * 24);
62080 + chr = cputime / 3600;
62081 + cputime -= chr * 3600;
62082 + cmin = cputime / 60;
62083 + cputime -= cmin * 60;
62084 + csec = cputime;
62085 +
62086 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62087 +
62088 + return;
62089 +}
62090 +
62091 +void gr_set_kernel_label(struct task_struct *task)
62092 +{
62093 + if (gr_status & GR_READY) {
62094 + task->role = kernel_role;
62095 + task->acl = kernel_role->root_label;
62096 + }
62097 + return;
62098 +}
62099 +
62100 +#ifdef CONFIG_TASKSTATS
62101 +int gr_is_taskstats_denied(int pid)
62102 +{
62103 + struct task_struct *task;
62104 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62105 + const struct cred *cred;
62106 +#endif
62107 + int ret = 0;
62108 +
62109 + /* restrict taskstats viewing to un-chrooted root users
62110 + who have the 'view' subject flag if the RBAC system is enabled
62111 + */
62112 +
62113 + rcu_read_lock();
62114 + read_lock(&tasklist_lock);
62115 + task = find_task_by_vpid(pid);
62116 + if (task) {
62117 +#ifdef CONFIG_GRKERNSEC_CHROOT
62118 + if (proc_is_chrooted(task))
62119 + ret = -EACCES;
62120 +#endif
62121 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62122 + cred = __task_cred(task);
62123 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62124 + if (gr_is_global_nonroot(cred->uid))
62125 + ret = -EACCES;
62126 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62127 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62128 + ret = -EACCES;
62129 +#endif
62130 +#endif
62131 + if (gr_status & GR_READY) {
62132 + if (!(task->acl->mode & GR_VIEW))
62133 + ret = -EACCES;
62134 + }
62135 + } else
62136 + ret = -ENOENT;
62137 +
62138 + read_unlock(&tasklist_lock);
62139 + rcu_read_unlock();
62140 +
62141 + return ret;
62142 +}
62143 +#endif
62144 +
62145 +/* AUXV entries are filled via a descendant of search_binary_handler
62146 + after we've already applied the subject for the target
62147 +*/
62148 +int gr_acl_enable_at_secure(void)
62149 +{
62150 + if (unlikely(!(gr_status & GR_READY)))
62151 + return 0;
62152 +
62153 + if (current->acl->mode & GR_ATSECURE)
62154 + return 1;
62155 +
62156 + return 0;
62157 +}
62158 +
62159 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62160 +{
62161 + struct task_struct *task = current;
62162 + struct dentry *dentry = file->f_path.dentry;
62163 + struct vfsmount *mnt = file->f_path.mnt;
62164 + struct acl_object_label *obj, *tmp;
62165 + struct acl_subject_label *subj;
62166 + unsigned int bufsize;
62167 + int is_not_root;
62168 + char *path;
62169 + dev_t dev = __get_dev(dentry);
62170 +
62171 + if (unlikely(!(gr_status & GR_READY)))
62172 + return 1;
62173 +
62174 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62175 + return 1;
62176 +
62177 + /* ignore Eric Biederman */
62178 + if (IS_PRIVATE(dentry->d_inode))
62179 + return 1;
62180 +
62181 + subj = task->acl;
62182 + read_lock(&gr_inode_lock);
62183 + do {
62184 + obj = lookup_acl_obj_label(ino, dev, subj);
62185 + if (obj != NULL) {
62186 + read_unlock(&gr_inode_lock);
62187 + return (obj->mode & GR_FIND) ? 1 : 0;
62188 + }
62189 + } while ((subj = subj->parent_subject));
62190 + read_unlock(&gr_inode_lock);
62191 +
62192 + /* this is purely an optimization since we're looking for an object
62193 + for the directory we're doing a readdir on
62194 + if it's possible for any globbed object to match the entry we're
62195 + filling into the directory, then the object we find here will be
62196 + an anchor point with attached globbed objects
62197 + */
62198 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62199 + if (obj->globbed == NULL)
62200 + return (obj->mode & GR_FIND) ? 1 : 0;
62201 +
62202 + is_not_root = ((obj->filename[0] == '/') &&
62203 + (obj->filename[1] == '\0')) ? 0 : 1;
62204 + bufsize = PAGE_SIZE - namelen - is_not_root;
62205 +
62206 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62207 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62208 + return 1;
62209 +
62210 + preempt_disable();
62211 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62212 + bufsize);
62213 +
62214 + bufsize = strlen(path);
62215 +
62216 + /* if base is "/", don't append an additional slash */
62217 + if (is_not_root)
62218 + *(path + bufsize) = '/';
62219 + memcpy(path + bufsize + is_not_root, name, namelen);
62220 + *(path + bufsize + namelen + is_not_root) = '\0';
62221 +
62222 + tmp = obj->globbed;
62223 + while (tmp) {
62224 + if (!glob_match(tmp->filename, path)) {
62225 + preempt_enable();
62226 + return (tmp->mode & GR_FIND) ? 1 : 0;
62227 + }
62228 + tmp = tmp->next;
62229 + }
62230 + preempt_enable();
62231 + return (obj->mode & GR_FIND) ? 1 : 0;
62232 +}
62233 +
62234 +void gr_put_exec_file(struct task_struct *task)
62235 +{
62236 + struct file *filp;
62237 +
62238 + write_lock(&grsec_exec_file_lock);
62239 + filp = task->exec_file;
62240 + task->exec_file = NULL;
62241 + write_unlock(&grsec_exec_file_lock);
62242 +
62243 + if (filp)
62244 + fput(filp);
62245 +
62246 + return;
62247 +}
62248 +
62249 +
62250 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62251 +EXPORT_SYMBOL(gr_acl_is_enabled);
62252 +#endif
62253 +EXPORT_SYMBOL(gr_set_kernel_label);
62254 +#ifdef CONFIG_SECURITY
62255 +EXPORT_SYMBOL(gr_check_user_change);
62256 +EXPORT_SYMBOL(gr_check_group_change);
62257 +#endif
62258 +
62259 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62260 new file mode 100644
62261 index 0000000..34fefda
62262 --- /dev/null
62263 +++ b/grsecurity/gracl_alloc.c
62264 @@ -0,0 +1,105 @@
62265 +#include <linux/kernel.h>
62266 +#include <linux/mm.h>
62267 +#include <linux/slab.h>
62268 +#include <linux/vmalloc.h>
62269 +#include <linux/gracl.h>
62270 +#include <linux/grsecurity.h>
62271 +
62272 +static unsigned long alloc_stack_next = 1;
62273 +static unsigned long alloc_stack_size = 1;
62274 +static void **alloc_stack;
62275 +
62276 +static __inline__ int
62277 +alloc_pop(void)
62278 +{
62279 + if (alloc_stack_next == 1)
62280 + return 0;
62281 +
62282 + kfree(alloc_stack[alloc_stack_next - 2]);
62283 +
62284 + alloc_stack_next--;
62285 +
62286 + return 1;
62287 +}
62288 +
62289 +static __inline__ int
62290 +alloc_push(void *buf)
62291 +{
62292 + if (alloc_stack_next >= alloc_stack_size)
62293 + return 1;
62294 +
62295 + alloc_stack[alloc_stack_next - 1] = buf;
62296 +
62297 + alloc_stack_next++;
62298 +
62299 + return 0;
62300 +}
62301 +
62302 +void *
62303 +acl_alloc(unsigned long len)
62304 +{
62305 + void *ret = NULL;
62306 +
62307 + if (!len || len > PAGE_SIZE)
62308 + goto out;
62309 +
62310 + ret = kmalloc(len, GFP_KERNEL);
62311 +
62312 + if (ret) {
62313 + if (alloc_push(ret)) {
62314 + kfree(ret);
62315 + ret = NULL;
62316 + }
62317 + }
62318 +
62319 +out:
62320 + return ret;
62321 +}
62322 +
62323 +void *
62324 +acl_alloc_num(unsigned long num, unsigned long len)
62325 +{
62326 + if (!len || (num > (PAGE_SIZE / len)))
62327 + return NULL;
62328 +
62329 + return acl_alloc(num * len);
62330 +}
62331 +
62332 +void
62333 +acl_free_all(void)
62334 +{
62335 + if (gr_acl_is_enabled() || !alloc_stack)
62336 + return;
62337 +
62338 + while (alloc_pop()) ;
62339 +
62340 + if (alloc_stack) {
62341 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62342 + kfree(alloc_stack);
62343 + else
62344 + vfree(alloc_stack);
62345 + }
62346 +
62347 + alloc_stack = NULL;
62348 + alloc_stack_size = 1;
62349 + alloc_stack_next = 1;
62350 +
62351 + return;
62352 +}
62353 +
62354 +int
62355 +acl_alloc_stack_init(unsigned long size)
62356 +{
62357 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62358 + alloc_stack =
62359 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62360 + else
62361 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62362 +
62363 + alloc_stack_size = size;
62364 +
62365 + if (!alloc_stack)
62366 + return 0;
62367 + else
62368 + return 1;
62369 +}
62370 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62371 new file mode 100644
62372 index 0000000..bdd51ea
62373 --- /dev/null
62374 +++ b/grsecurity/gracl_cap.c
62375 @@ -0,0 +1,110 @@
62376 +#include <linux/kernel.h>
62377 +#include <linux/module.h>
62378 +#include <linux/sched.h>
62379 +#include <linux/gracl.h>
62380 +#include <linux/grsecurity.h>
62381 +#include <linux/grinternal.h>
62382 +
62383 +extern const char *captab_log[];
62384 +extern int captab_log_entries;
62385 +
62386 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62387 +{
62388 + struct acl_subject_label *curracl;
62389 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62390 + kernel_cap_t cap_audit = __cap_empty_set;
62391 +
62392 + if (!gr_acl_is_enabled())
62393 + return 1;
62394 +
62395 + curracl = task->acl;
62396 +
62397 + cap_drop = curracl->cap_lower;
62398 + cap_mask = curracl->cap_mask;
62399 + cap_audit = curracl->cap_invert_audit;
62400 +
62401 + while ((curracl = curracl->parent_subject)) {
62402 + /* if the cap isn't specified in the current computed mask but is specified in the
62403 + current level subject, and is lowered in the current level subject, then add
62404 + it to the set of dropped capabilities
62405 + otherwise, add the current level subject's mask to the current computed mask
62406 + */
62407 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62408 + cap_raise(cap_mask, cap);
62409 + if (cap_raised(curracl->cap_lower, cap))
62410 + cap_raise(cap_drop, cap);
62411 + if (cap_raised(curracl->cap_invert_audit, cap))
62412 + cap_raise(cap_audit, cap);
62413 + }
62414 + }
62415 +
62416 + if (!cap_raised(cap_drop, cap)) {
62417 + if (cap_raised(cap_audit, cap))
62418 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62419 + return 1;
62420 + }
62421 +
62422 + curracl = task->acl;
62423 +
62424 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62425 + && cap_raised(cred->cap_effective, cap)) {
62426 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62427 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62428 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62429 + gr_to_filename(task->exec_file->f_path.dentry,
62430 + task->exec_file->f_path.mnt) : curracl->filename,
62431 + curracl->filename, 0UL,
62432 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62433 + return 1;
62434 + }
62435 +
62436 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62437 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62438 +
62439 + return 0;
62440 +}
62441 +
62442 +int
62443 +gr_acl_is_capable(const int cap)
62444 +{
62445 + return gr_task_acl_is_capable(current, current_cred(), cap);
62446 +}
62447 +
62448 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62449 +{
62450 + struct acl_subject_label *curracl;
62451 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62452 +
62453 + if (!gr_acl_is_enabled())
62454 + return 1;
62455 +
62456 + curracl = task->acl;
62457 +
62458 + cap_drop = curracl->cap_lower;
62459 + cap_mask = curracl->cap_mask;
62460 +
62461 + while ((curracl = curracl->parent_subject)) {
62462 + /* if the cap isn't specified in the current computed mask but is specified in the
62463 + current level subject, and is lowered in the current level subject, then add
62464 + it to the set of dropped capabilities
62465 + otherwise, add the current level subject's mask to the current computed mask
62466 + */
62467 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62468 + cap_raise(cap_mask, cap);
62469 + if (cap_raised(curracl->cap_lower, cap))
62470 + cap_raise(cap_drop, cap);
62471 + }
62472 + }
62473 +
62474 + if (!cap_raised(cap_drop, cap))
62475 + return 1;
62476 +
62477 + return 0;
62478 +}
62479 +
62480 +int
62481 +gr_acl_is_capable_nolog(const int cap)
62482 +{
62483 + return gr_task_acl_is_capable_nolog(current, cap);
62484 +}
62485 +
62486 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62487 new file mode 100644
62488 index 0000000..a340c17
62489 --- /dev/null
62490 +++ b/grsecurity/gracl_fs.c
62491 @@ -0,0 +1,431 @@
62492 +#include <linux/kernel.h>
62493 +#include <linux/sched.h>
62494 +#include <linux/types.h>
62495 +#include <linux/fs.h>
62496 +#include <linux/file.h>
62497 +#include <linux/stat.h>
62498 +#include <linux/grsecurity.h>
62499 +#include <linux/grinternal.h>
62500 +#include <linux/gracl.h>
62501 +
62502 +umode_t
62503 +gr_acl_umask(void)
62504 +{
62505 + if (unlikely(!gr_acl_is_enabled()))
62506 + return 0;
62507 +
62508 + return current->role->umask;
62509 +}
62510 +
62511 +__u32
62512 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62513 + const struct vfsmount * mnt)
62514 +{
62515 + __u32 mode;
62516 +
62517 + if (unlikely(!dentry->d_inode))
62518 + return GR_FIND;
62519 +
62520 + mode =
62521 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62522 +
62523 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62524 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62525 + return mode;
62526 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62527 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62528 + return 0;
62529 + } else if (unlikely(!(mode & GR_FIND)))
62530 + return 0;
62531 +
62532 + return GR_FIND;
62533 +}
62534 +
62535 +__u32
62536 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62537 + int acc_mode)
62538 +{
62539 + __u32 reqmode = GR_FIND;
62540 + __u32 mode;
62541 +
62542 + if (unlikely(!dentry->d_inode))
62543 + return reqmode;
62544 +
62545 + if (acc_mode & MAY_APPEND)
62546 + reqmode |= GR_APPEND;
62547 + else if (acc_mode & MAY_WRITE)
62548 + reqmode |= GR_WRITE;
62549 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62550 + reqmode |= GR_READ;
62551 +
62552 + mode =
62553 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62554 + mnt);
62555 +
62556 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62557 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62558 + reqmode & GR_READ ? " reading" : "",
62559 + reqmode & GR_WRITE ? " writing" : reqmode &
62560 + GR_APPEND ? " appending" : "");
62561 + return reqmode;
62562 + } else
62563 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62564 + {
62565 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62566 + reqmode & GR_READ ? " reading" : "",
62567 + reqmode & GR_WRITE ? " writing" : reqmode &
62568 + GR_APPEND ? " appending" : "");
62569 + return 0;
62570 + } else if (unlikely((mode & reqmode) != reqmode))
62571 + return 0;
62572 +
62573 + return reqmode;
62574 +}
62575 +
62576 +__u32
62577 +gr_acl_handle_creat(const struct dentry * dentry,
62578 + const struct dentry * p_dentry,
62579 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62580 + const int imode)
62581 +{
62582 + __u32 reqmode = GR_WRITE | GR_CREATE;
62583 + __u32 mode;
62584 +
62585 + if (acc_mode & MAY_APPEND)
62586 + reqmode |= GR_APPEND;
62587 + // if a directory was required or the directory already exists, then
62588 + // don't count this open as a read
62589 + if ((acc_mode & MAY_READ) &&
62590 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62591 + reqmode |= GR_READ;
62592 + if ((open_flags & O_CREAT) &&
62593 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62594 + reqmode |= GR_SETID;
62595 +
62596 + mode =
62597 + gr_check_create(dentry, p_dentry, p_mnt,
62598 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62599 +
62600 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62601 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62602 + reqmode & GR_READ ? " reading" : "",
62603 + reqmode & GR_WRITE ? " writing" : reqmode &
62604 + GR_APPEND ? " appending" : "");
62605 + return reqmode;
62606 + } else
62607 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62608 + {
62609 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62610 + reqmode & GR_READ ? " reading" : "",
62611 + reqmode & GR_WRITE ? " writing" : reqmode &
62612 + GR_APPEND ? " appending" : "");
62613 + return 0;
62614 + } else if (unlikely((mode & reqmode) != reqmode))
62615 + return 0;
62616 +
62617 + return reqmode;
62618 +}
62619 +
62620 +__u32
62621 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62622 + const int fmode)
62623 +{
62624 + __u32 mode, reqmode = GR_FIND;
62625 +
62626 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62627 + reqmode |= GR_EXEC;
62628 + if (fmode & S_IWOTH)
62629 + reqmode |= GR_WRITE;
62630 + if (fmode & S_IROTH)
62631 + reqmode |= GR_READ;
62632 +
62633 + mode =
62634 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62635 + mnt);
62636 +
62637 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62638 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62639 + reqmode & GR_READ ? " reading" : "",
62640 + reqmode & GR_WRITE ? " writing" : "",
62641 + reqmode & GR_EXEC ? " executing" : "");
62642 + return reqmode;
62643 + } else
62644 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62645 + {
62646 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62647 + reqmode & GR_READ ? " reading" : "",
62648 + reqmode & GR_WRITE ? " writing" : "",
62649 + reqmode & GR_EXEC ? " executing" : "");
62650 + return 0;
62651 + } else if (unlikely((mode & reqmode) != reqmode))
62652 + return 0;
62653 +
62654 + return reqmode;
62655 +}
62656 +
62657 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62658 +{
62659 + __u32 mode;
62660 +
62661 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62662 +
62663 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62664 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62665 + return mode;
62666 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62667 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62668 + return 0;
62669 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62670 + return 0;
62671 +
62672 + return (reqmode);
62673 +}
62674 +
62675 +__u32
62676 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62677 +{
62678 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62679 +}
62680 +
62681 +__u32
62682 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62683 +{
62684 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62685 +}
62686 +
62687 +__u32
62688 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62689 +{
62690 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62691 +}
62692 +
62693 +__u32
62694 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62695 +{
62696 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62697 +}
62698 +
62699 +__u32
62700 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62701 + umode_t *modeptr)
62702 +{
62703 + umode_t mode;
62704 +
62705 + *modeptr &= ~gr_acl_umask();
62706 + mode = *modeptr;
62707 +
62708 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62709 + return 1;
62710 +
62711 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62712 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62713 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62714 + GR_CHMOD_ACL_MSG);
62715 + } else {
62716 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62717 + }
62718 +}
62719 +
62720 +__u32
62721 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62722 +{
62723 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62724 +}
62725 +
62726 +__u32
62727 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62728 +{
62729 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62730 +}
62731 +
62732 +__u32
62733 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62734 +{
62735 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62736 +}
62737 +
62738 +__u32
62739 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62740 +{
62741 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62742 + GR_UNIXCONNECT_ACL_MSG);
62743 +}
62744 +
62745 +/* hardlinks require at minimum create and link permission,
62746 + any additional privilege required is based on the
62747 + privilege of the file being linked to
62748 +*/
62749 +__u32
62750 +gr_acl_handle_link(const struct dentry * new_dentry,
62751 + const struct dentry * parent_dentry,
62752 + const struct vfsmount * parent_mnt,
62753 + const struct dentry * old_dentry,
62754 + const struct vfsmount * old_mnt, const struct filename *to)
62755 +{
62756 + __u32 mode;
62757 + __u32 needmode = GR_CREATE | GR_LINK;
62758 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62759 +
62760 + mode =
62761 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62762 + old_mnt);
62763 +
62764 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62765 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62766 + return mode;
62767 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62768 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62769 + return 0;
62770 + } else if (unlikely((mode & needmode) != needmode))
62771 + return 0;
62772 +
62773 + return 1;
62774 +}
62775 +
62776 +__u32
62777 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62778 + const struct dentry * parent_dentry,
62779 + const struct vfsmount * parent_mnt, const struct filename *from)
62780 +{
62781 + __u32 needmode = GR_WRITE | GR_CREATE;
62782 + __u32 mode;
62783 +
62784 + mode =
62785 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62786 + GR_CREATE | GR_AUDIT_CREATE |
62787 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62788 +
62789 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62790 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62791 + return mode;
62792 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62793 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62794 + return 0;
62795 + } else if (unlikely((mode & needmode) != needmode))
62796 + return 0;
62797 +
62798 + return (GR_WRITE | GR_CREATE);
62799 +}
62800 +
62801 +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)
62802 +{
62803 + __u32 mode;
62804 +
62805 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62806 +
62807 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62808 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62809 + return mode;
62810 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62811 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62812 + return 0;
62813 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62814 + return 0;
62815 +
62816 + return (reqmode);
62817 +}
62818 +
62819 +__u32
62820 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62821 + const struct dentry * parent_dentry,
62822 + const struct vfsmount * parent_mnt,
62823 + const int mode)
62824 +{
62825 + __u32 reqmode = GR_WRITE | GR_CREATE;
62826 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62827 + reqmode |= GR_SETID;
62828 +
62829 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62830 + reqmode, GR_MKNOD_ACL_MSG);
62831 +}
62832 +
62833 +__u32
62834 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62835 + const struct dentry *parent_dentry,
62836 + const struct vfsmount *parent_mnt)
62837 +{
62838 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62839 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62840 +}
62841 +
62842 +#define RENAME_CHECK_SUCCESS(old, new) \
62843 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62844 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62845 +
62846 +int
62847 +gr_acl_handle_rename(struct dentry *new_dentry,
62848 + struct dentry *parent_dentry,
62849 + const struct vfsmount *parent_mnt,
62850 + struct dentry *old_dentry,
62851 + struct inode *old_parent_inode,
62852 + struct vfsmount *old_mnt, const struct filename *newname)
62853 +{
62854 + __u32 comp1, comp2;
62855 + int error = 0;
62856 +
62857 + if (unlikely(!gr_acl_is_enabled()))
62858 + return 0;
62859 +
62860 + if (!new_dentry->d_inode) {
62861 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62862 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62863 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62864 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62865 + GR_DELETE | GR_AUDIT_DELETE |
62866 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62867 + GR_SUPPRESS, old_mnt);
62868 + } else {
62869 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62870 + GR_CREATE | GR_DELETE |
62871 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62872 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62873 + GR_SUPPRESS, parent_mnt);
62874 + comp2 =
62875 + gr_search_file(old_dentry,
62876 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62877 + GR_DELETE | GR_AUDIT_DELETE |
62878 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62879 + }
62880 +
62881 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62882 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62883 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62884 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62885 + && !(comp2 & GR_SUPPRESS)) {
62886 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62887 + error = -EACCES;
62888 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62889 + error = -EACCES;
62890 +
62891 + return error;
62892 +}
62893 +
62894 +void
62895 +gr_acl_handle_exit(void)
62896 +{
62897 + u16 id;
62898 + char *rolename;
62899 +
62900 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62901 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62902 + id = current->acl_role_id;
62903 + rolename = current->role->rolename;
62904 + gr_set_acls(1);
62905 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62906 + }
62907 +
62908 + gr_put_exec_file(current);
62909 + return;
62910 +}
62911 +
62912 +int
62913 +gr_acl_handle_procpidmem(const struct task_struct *task)
62914 +{
62915 + if (unlikely(!gr_acl_is_enabled()))
62916 + return 0;
62917 +
62918 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62919 + return -EACCES;
62920 +
62921 + return 0;
62922 +}
62923 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62924 new file mode 100644
62925 index 0000000..8132048
62926 --- /dev/null
62927 +++ b/grsecurity/gracl_ip.c
62928 @@ -0,0 +1,387 @@
62929 +#include <linux/kernel.h>
62930 +#include <asm/uaccess.h>
62931 +#include <asm/errno.h>
62932 +#include <net/sock.h>
62933 +#include <linux/file.h>
62934 +#include <linux/fs.h>
62935 +#include <linux/net.h>
62936 +#include <linux/in.h>
62937 +#include <linux/skbuff.h>
62938 +#include <linux/ip.h>
62939 +#include <linux/udp.h>
62940 +#include <linux/types.h>
62941 +#include <linux/sched.h>
62942 +#include <linux/netdevice.h>
62943 +#include <linux/inetdevice.h>
62944 +#include <linux/gracl.h>
62945 +#include <linux/grsecurity.h>
62946 +#include <linux/grinternal.h>
62947 +
62948 +#define GR_BIND 0x01
62949 +#define GR_CONNECT 0x02
62950 +#define GR_INVERT 0x04
62951 +#define GR_BINDOVERRIDE 0x08
62952 +#define GR_CONNECTOVERRIDE 0x10
62953 +#define GR_SOCK_FAMILY 0x20
62954 +
62955 +static const char * gr_protocols[IPPROTO_MAX] = {
62956 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62957 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62958 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62959 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62960 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62961 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62962 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62963 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62964 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62965 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62966 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62967 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62968 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62969 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62970 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62971 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62972 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62973 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62974 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62975 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62976 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62977 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62978 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62979 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62980 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62981 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62982 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62983 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62984 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62985 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62986 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62987 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62988 + };
62989 +
62990 +static const char * gr_socktypes[SOCK_MAX] = {
62991 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62992 + "unknown:7", "unknown:8", "unknown:9", "packet"
62993 + };
62994 +
62995 +static const char * gr_sockfamilies[AF_MAX+1] = {
62996 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62997 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62998 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62999 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63000 + };
63001 +
63002 +const char *
63003 +gr_proto_to_name(unsigned char proto)
63004 +{
63005 + return gr_protocols[proto];
63006 +}
63007 +
63008 +const char *
63009 +gr_socktype_to_name(unsigned char type)
63010 +{
63011 + return gr_socktypes[type];
63012 +}
63013 +
63014 +const char *
63015 +gr_sockfamily_to_name(unsigned char family)
63016 +{
63017 + return gr_sockfamilies[family];
63018 +}
63019 +
63020 +int
63021 +gr_search_socket(const int domain, const int type, const int protocol)
63022 +{
63023 + struct acl_subject_label *curr;
63024 + const struct cred *cred = current_cred();
63025 +
63026 + if (unlikely(!gr_acl_is_enabled()))
63027 + goto exit;
63028 +
63029 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63030 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63031 + goto exit; // let the kernel handle it
63032 +
63033 + curr = current->acl;
63034 +
63035 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63036 + /* the family is allowed, if this is PF_INET allow it only if
63037 + the extra sock type/protocol checks pass */
63038 + if (domain == PF_INET)
63039 + goto inet_check;
63040 + goto exit;
63041 + } else {
63042 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63043 + __u32 fakeip = 0;
63044 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63045 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63046 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63047 + gr_to_filename(current->exec_file->f_path.dentry,
63048 + current->exec_file->f_path.mnt) :
63049 + curr->filename, curr->filename,
63050 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63051 + &current->signal->saved_ip);
63052 + goto exit;
63053 + }
63054 + goto exit_fail;
63055 + }
63056 +
63057 +inet_check:
63058 + /* the rest of this checking is for IPv4 only */
63059 + if (!curr->ips)
63060 + goto exit;
63061 +
63062 + if ((curr->ip_type & (1U << type)) &&
63063 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63064 + goto exit;
63065 +
63066 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63067 + /* we don't place acls on raw sockets , and sometimes
63068 + dgram/ip sockets are opened for ioctl and not
63069 + bind/connect, so we'll fake a bind learn log */
63070 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63071 + __u32 fakeip = 0;
63072 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63073 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63074 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63075 + gr_to_filename(current->exec_file->f_path.dentry,
63076 + current->exec_file->f_path.mnt) :
63077 + curr->filename, curr->filename,
63078 + &fakeip, 0, type,
63079 + protocol, GR_CONNECT, &current->signal->saved_ip);
63080 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63081 + __u32 fakeip = 0;
63082 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63083 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63084 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63085 + gr_to_filename(current->exec_file->f_path.dentry,
63086 + current->exec_file->f_path.mnt) :
63087 + curr->filename, curr->filename,
63088 + &fakeip, 0, type,
63089 + protocol, GR_BIND, &current->signal->saved_ip);
63090 + }
63091 + /* we'll log when they use connect or bind */
63092 + goto exit;
63093 + }
63094 +
63095 +exit_fail:
63096 + if (domain == PF_INET)
63097 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63098 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63099 + else
63100 +#ifndef CONFIG_IPV6
63101 + if (domain != PF_INET6)
63102 +#endif
63103 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63104 + gr_socktype_to_name(type), protocol);
63105 +
63106 + return 0;
63107 +exit:
63108 + return 1;
63109 +}
63110 +
63111 +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)
63112 +{
63113 + if ((ip->mode & mode) &&
63114 + (ip_port >= ip->low) &&
63115 + (ip_port <= ip->high) &&
63116 + ((ntohl(ip_addr) & our_netmask) ==
63117 + (ntohl(our_addr) & our_netmask))
63118 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63119 + && (ip->type & (1U << type))) {
63120 + if (ip->mode & GR_INVERT)
63121 + return 2; // specifically denied
63122 + else
63123 + return 1; // allowed
63124 + }
63125 +
63126 + return 0; // not specifically allowed, may continue parsing
63127 +}
63128 +
63129 +static int
63130 +gr_search_connectbind(const int full_mode, struct sock *sk,
63131 + struct sockaddr_in *addr, const int type)
63132 +{
63133 + char iface[IFNAMSIZ] = {0};
63134 + struct acl_subject_label *curr;
63135 + struct acl_ip_label *ip;
63136 + struct inet_sock *isk;
63137 + struct net_device *dev;
63138 + struct in_device *idev;
63139 + unsigned long i;
63140 + int ret;
63141 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63142 + __u32 ip_addr = 0;
63143 + __u32 our_addr;
63144 + __u32 our_netmask;
63145 + char *p;
63146 + __u16 ip_port = 0;
63147 + const struct cred *cred = current_cred();
63148 +
63149 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63150 + return 0;
63151 +
63152 + curr = current->acl;
63153 + isk = inet_sk(sk);
63154 +
63155 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63156 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63157 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63158 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63159 + struct sockaddr_in saddr;
63160 + int err;
63161 +
63162 + saddr.sin_family = AF_INET;
63163 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63164 + saddr.sin_port = isk->inet_sport;
63165 +
63166 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63167 + if (err)
63168 + return err;
63169 +
63170 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63171 + if (err)
63172 + return err;
63173 + }
63174 +
63175 + if (!curr->ips)
63176 + return 0;
63177 +
63178 + ip_addr = addr->sin_addr.s_addr;
63179 + ip_port = ntohs(addr->sin_port);
63180 +
63181 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63182 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63183 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63184 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63185 + gr_to_filename(current->exec_file->f_path.dentry,
63186 + current->exec_file->f_path.mnt) :
63187 + curr->filename, curr->filename,
63188 + &ip_addr, ip_port, type,
63189 + sk->sk_protocol, mode, &current->signal->saved_ip);
63190 + return 0;
63191 + }
63192 +
63193 + for (i = 0; i < curr->ip_num; i++) {
63194 + ip = *(curr->ips + i);
63195 + if (ip->iface != NULL) {
63196 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63197 + p = strchr(iface, ':');
63198 + if (p != NULL)
63199 + *p = '\0';
63200 + dev = dev_get_by_name(sock_net(sk), iface);
63201 + if (dev == NULL)
63202 + continue;
63203 + idev = in_dev_get(dev);
63204 + if (idev == NULL) {
63205 + dev_put(dev);
63206 + continue;
63207 + }
63208 + rcu_read_lock();
63209 + for_ifa(idev) {
63210 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63211 + our_addr = ifa->ifa_address;
63212 + our_netmask = 0xffffffff;
63213 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63214 + if (ret == 1) {
63215 + rcu_read_unlock();
63216 + in_dev_put(idev);
63217 + dev_put(dev);
63218 + return 0;
63219 + } else if (ret == 2) {
63220 + rcu_read_unlock();
63221 + in_dev_put(idev);
63222 + dev_put(dev);
63223 + goto denied;
63224 + }
63225 + }
63226 + } endfor_ifa(idev);
63227 + rcu_read_unlock();
63228 + in_dev_put(idev);
63229 + dev_put(dev);
63230 + } else {
63231 + our_addr = ip->addr;
63232 + our_netmask = ip->netmask;
63233 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63234 + if (ret == 1)
63235 + return 0;
63236 + else if (ret == 2)
63237 + goto denied;
63238 + }
63239 + }
63240 +
63241 +denied:
63242 + if (mode == GR_BIND)
63243 + 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));
63244 + else if (mode == GR_CONNECT)
63245 + 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));
63246 +
63247 + return -EACCES;
63248 +}
63249 +
63250 +int
63251 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63252 +{
63253 + /* always allow disconnection of dgram sockets with connect */
63254 + if (addr->sin_family == AF_UNSPEC)
63255 + return 0;
63256 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63257 +}
63258 +
63259 +int
63260 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63261 +{
63262 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63263 +}
63264 +
63265 +int gr_search_listen(struct socket *sock)
63266 +{
63267 + struct sock *sk = sock->sk;
63268 + struct sockaddr_in addr;
63269 +
63270 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63271 + addr.sin_port = inet_sk(sk)->inet_sport;
63272 +
63273 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63274 +}
63275 +
63276 +int gr_search_accept(struct socket *sock)
63277 +{
63278 + struct sock *sk = sock->sk;
63279 + struct sockaddr_in addr;
63280 +
63281 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63282 + addr.sin_port = inet_sk(sk)->inet_sport;
63283 +
63284 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63285 +}
63286 +
63287 +int
63288 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63289 +{
63290 + if (addr)
63291 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63292 + else {
63293 + struct sockaddr_in sin;
63294 + const struct inet_sock *inet = inet_sk(sk);
63295 +
63296 + sin.sin_addr.s_addr = inet->inet_daddr;
63297 + sin.sin_port = inet->inet_dport;
63298 +
63299 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63300 + }
63301 +}
63302 +
63303 +int
63304 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63305 +{
63306 + struct sockaddr_in sin;
63307 +
63308 + if (unlikely(skb->len < sizeof (struct udphdr)))
63309 + return 0; // skip this packet
63310 +
63311 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63312 + sin.sin_port = udp_hdr(skb)->source;
63313 +
63314 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63315 +}
63316 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63317 new file mode 100644
63318 index 0000000..25f54ef
63319 --- /dev/null
63320 +++ b/grsecurity/gracl_learn.c
63321 @@ -0,0 +1,207 @@
63322 +#include <linux/kernel.h>
63323 +#include <linux/mm.h>
63324 +#include <linux/sched.h>
63325 +#include <linux/poll.h>
63326 +#include <linux/string.h>
63327 +#include <linux/file.h>
63328 +#include <linux/types.h>
63329 +#include <linux/vmalloc.h>
63330 +#include <linux/grinternal.h>
63331 +
63332 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63333 + size_t count, loff_t *ppos);
63334 +extern int gr_acl_is_enabled(void);
63335 +
63336 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63337 +static int gr_learn_attached;
63338 +
63339 +/* use a 512k buffer */
63340 +#define LEARN_BUFFER_SIZE (512 * 1024)
63341 +
63342 +static DEFINE_SPINLOCK(gr_learn_lock);
63343 +static DEFINE_MUTEX(gr_learn_user_mutex);
63344 +
63345 +/* we need to maintain two buffers, so that the kernel context of grlearn
63346 + uses a semaphore around the userspace copying, and the other kernel contexts
63347 + use a spinlock when copying into the buffer, since they cannot sleep
63348 +*/
63349 +static char *learn_buffer;
63350 +static char *learn_buffer_user;
63351 +static int learn_buffer_len;
63352 +static int learn_buffer_user_len;
63353 +
63354 +static ssize_t
63355 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63356 +{
63357 + DECLARE_WAITQUEUE(wait, current);
63358 + ssize_t retval = 0;
63359 +
63360 + add_wait_queue(&learn_wait, &wait);
63361 + set_current_state(TASK_INTERRUPTIBLE);
63362 + do {
63363 + mutex_lock(&gr_learn_user_mutex);
63364 + spin_lock(&gr_learn_lock);
63365 + if (learn_buffer_len)
63366 + break;
63367 + spin_unlock(&gr_learn_lock);
63368 + mutex_unlock(&gr_learn_user_mutex);
63369 + if (file->f_flags & O_NONBLOCK) {
63370 + retval = -EAGAIN;
63371 + goto out;
63372 + }
63373 + if (signal_pending(current)) {
63374 + retval = -ERESTARTSYS;
63375 + goto out;
63376 + }
63377 +
63378 + schedule();
63379 + } while (1);
63380 +
63381 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63382 + learn_buffer_user_len = learn_buffer_len;
63383 + retval = learn_buffer_len;
63384 + learn_buffer_len = 0;
63385 +
63386 + spin_unlock(&gr_learn_lock);
63387 +
63388 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63389 + retval = -EFAULT;
63390 +
63391 + mutex_unlock(&gr_learn_user_mutex);
63392 +out:
63393 + set_current_state(TASK_RUNNING);
63394 + remove_wait_queue(&learn_wait, &wait);
63395 + return retval;
63396 +}
63397 +
63398 +static unsigned int
63399 +poll_learn(struct file * file, poll_table * wait)
63400 +{
63401 + poll_wait(file, &learn_wait, wait);
63402 +
63403 + if (learn_buffer_len)
63404 + return (POLLIN | POLLRDNORM);
63405 +
63406 + return 0;
63407 +}
63408 +
63409 +void
63410 +gr_clear_learn_entries(void)
63411 +{
63412 + char *tmp;
63413 +
63414 + mutex_lock(&gr_learn_user_mutex);
63415 + spin_lock(&gr_learn_lock);
63416 + tmp = learn_buffer;
63417 + learn_buffer = NULL;
63418 + spin_unlock(&gr_learn_lock);
63419 + if (tmp)
63420 + vfree(tmp);
63421 + if (learn_buffer_user != NULL) {
63422 + vfree(learn_buffer_user);
63423 + learn_buffer_user = NULL;
63424 + }
63425 + learn_buffer_len = 0;
63426 + mutex_unlock(&gr_learn_user_mutex);
63427 +
63428 + return;
63429 +}
63430 +
63431 +void
63432 +gr_add_learn_entry(const char *fmt, ...)
63433 +{
63434 + va_list args;
63435 + unsigned int len;
63436 +
63437 + if (!gr_learn_attached)
63438 + return;
63439 +
63440 + spin_lock(&gr_learn_lock);
63441 +
63442 + /* leave a gap at the end so we know when it's "full" but don't have to
63443 + compute the exact length of the string we're trying to append
63444 + */
63445 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63446 + spin_unlock(&gr_learn_lock);
63447 + wake_up_interruptible(&learn_wait);
63448 + return;
63449 + }
63450 + if (learn_buffer == NULL) {
63451 + spin_unlock(&gr_learn_lock);
63452 + return;
63453 + }
63454 +
63455 + va_start(args, fmt);
63456 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63457 + va_end(args);
63458 +
63459 + learn_buffer_len += len + 1;
63460 +
63461 + spin_unlock(&gr_learn_lock);
63462 + wake_up_interruptible(&learn_wait);
63463 +
63464 + return;
63465 +}
63466 +
63467 +static int
63468 +open_learn(struct inode *inode, struct file *file)
63469 +{
63470 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63471 + return -EBUSY;
63472 + if (file->f_mode & FMODE_READ) {
63473 + int retval = 0;
63474 + mutex_lock(&gr_learn_user_mutex);
63475 + if (learn_buffer == NULL)
63476 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63477 + if (learn_buffer_user == NULL)
63478 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63479 + if (learn_buffer == NULL) {
63480 + retval = -ENOMEM;
63481 + goto out_error;
63482 + }
63483 + if (learn_buffer_user == NULL) {
63484 + retval = -ENOMEM;
63485 + goto out_error;
63486 + }
63487 + learn_buffer_len = 0;
63488 + learn_buffer_user_len = 0;
63489 + gr_learn_attached = 1;
63490 +out_error:
63491 + mutex_unlock(&gr_learn_user_mutex);
63492 + return retval;
63493 + }
63494 + return 0;
63495 +}
63496 +
63497 +static int
63498 +close_learn(struct inode *inode, struct file *file)
63499 +{
63500 + if (file->f_mode & FMODE_READ) {
63501 + char *tmp = NULL;
63502 + mutex_lock(&gr_learn_user_mutex);
63503 + spin_lock(&gr_learn_lock);
63504 + tmp = learn_buffer;
63505 + learn_buffer = NULL;
63506 + spin_unlock(&gr_learn_lock);
63507 + if (tmp)
63508 + vfree(tmp);
63509 + if (learn_buffer_user != NULL) {
63510 + vfree(learn_buffer_user);
63511 + learn_buffer_user = NULL;
63512 + }
63513 + learn_buffer_len = 0;
63514 + learn_buffer_user_len = 0;
63515 + gr_learn_attached = 0;
63516 + mutex_unlock(&gr_learn_user_mutex);
63517 + }
63518 +
63519 + return 0;
63520 +}
63521 +
63522 +const struct file_operations grsec_fops = {
63523 + .read = read_learn,
63524 + .write = write_grsec_handler,
63525 + .open = open_learn,
63526 + .release = close_learn,
63527 + .poll = poll_learn,
63528 +};
63529 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63530 new file mode 100644
63531 index 0000000..39645c9
63532 --- /dev/null
63533 +++ b/grsecurity/gracl_res.c
63534 @@ -0,0 +1,68 @@
63535 +#include <linux/kernel.h>
63536 +#include <linux/sched.h>
63537 +#include <linux/gracl.h>
63538 +#include <linux/grinternal.h>
63539 +
63540 +static const char *restab_log[] = {
63541 + [RLIMIT_CPU] = "RLIMIT_CPU",
63542 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63543 + [RLIMIT_DATA] = "RLIMIT_DATA",
63544 + [RLIMIT_STACK] = "RLIMIT_STACK",
63545 + [RLIMIT_CORE] = "RLIMIT_CORE",
63546 + [RLIMIT_RSS] = "RLIMIT_RSS",
63547 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63548 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63549 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63550 + [RLIMIT_AS] = "RLIMIT_AS",
63551 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63552 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63553 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63554 + [RLIMIT_NICE] = "RLIMIT_NICE",
63555 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63556 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63557 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63558 +};
63559 +
63560 +void
63561 +gr_log_resource(const struct task_struct *task,
63562 + const int res, const unsigned long wanted, const int gt)
63563 +{
63564 + const struct cred *cred;
63565 + unsigned long rlim;
63566 +
63567 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63568 + return;
63569 +
63570 + // not yet supported resource
63571 + if (unlikely(!restab_log[res]))
63572 + return;
63573 +
63574 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63575 + rlim = task_rlimit_max(task, res);
63576 + else
63577 + rlim = task_rlimit(task, res);
63578 +
63579 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63580 + return;
63581 +
63582 + rcu_read_lock();
63583 + cred = __task_cred(task);
63584 +
63585 + if (res == RLIMIT_NPROC &&
63586 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63587 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63588 + goto out_rcu_unlock;
63589 + else if (res == RLIMIT_MEMLOCK &&
63590 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63591 + goto out_rcu_unlock;
63592 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63593 + goto out_rcu_unlock;
63594 + rcu_read_unlock();
63595 +
63596 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63597 +
63598 + return;
63599 +out_rcu_unlock:
63600 + rcu_read_unlock();
63601 + return;
63602 +}
63603 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63604 new file mode 100644
63605 index 0000000..cb1e5ab
63606 --- /dev/null
63607 +++ b/grsecurity/gracl_segv.c
63608 @@ -0,0 +1,303 @@
63609 +#include <linux/kernel.h>
63610 +#include <linux/mm.h>
63611 +#include <asm/uaccess.h>
63612 +#include <asm/errno.h>
63613 +#include <asm/mman.h>
63614 +#include <net/sock.h>
63615 +#include <linux/file.h>
63616 +#include <linux/fs.h>
63617 +#include <linux/net.h>
63618 +#include <linux/in.h>
63619 +#include <linux/slab.h>
63620 +#include <linux/types.h>
63621 +#include <linux/sched.h>
63622 +#include <linux/timer.h>
63623 +#include <linux/gracl.h>
63624 +#include <linux/grsecurity.h>
63625 +#include <linux/grinternal.h>
63626 +
63627 +static struct crash_uid *uid_set;
63628 +static unsigned short uid_used;
63629 +static DEFINE_SPINLOCK(gr_uid_lock);
63630 +extern rwlock_t gr_inode_lock;
63631 +extern struct acl_subject_label *
63632 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63633 + struct acl_role_label *role);
63634 +
63635 +#ifdef CONFIG_BTRFS_FS
63636 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63637 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63638 +#endif
63639 +
63640 +static inline dev_t __get_dev(const struct dentry *dentry)
63641 +{
63642 +#ifdef CONFIG_BTRFS_FS
63643 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63644 + return get_btrfs_dev_from_inode(dentry->d_inode);
63645 + else
63646 +#endif
63647 + return dentry->d_inode->i_sb->s_dev;
63648 +}
63649 +
63650 +int
63651 +gr_init_uidset(void)
63652 +{
63653 + uid_set =
63654 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63655 + uid_used = 0;
63656 +
63657 + return uid_set ? 1 : 0;
63658 +}
63659 +
63660 +void
63661 +gr_free_uidset(void)
63662 +{
63663 + if (uid_set)
63664 + kfree(uid_set);
63665 +
63666 + return;
63667 +}
63668 +
63669 +int
63670 +gr_find_uid(const uid_t uid)
63671 +{
63672 + struct crash_uid *tmp = uid_set;
63673 + uid_t buid;
63674 + int low = 0, high = uid_used - 1, mid;
63675 +
63676 + while (high >= low) {
63677 + mid = (low + high) >> 1;
63678 + buid = tmp[mid].uid;
63679 + if (buid == uid)
63680 + return mid;
63681 + if (buid > uid)
63682 + high = mid - 1;
63683 + if (buid < uid)
63684 + low = mid + 1;
63685 + }
63686 +
63687 + return -1;
63688 +}
63689 +
63690 +static __inline__ void
63691 +gr_insertsort(void)
63692 +{
63693 + unsigned short i, j;
63694 + struct crash_uid index;
63695 +
63696 + for (i = 1; i < uid_used; i++) {
63697 + index = uid_set[i];
63698 + j = i;
63699 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63700 + uid_set[j] = uid_set[j - 1];
63701 + j--;
63702 + }
63703 + uid_set[j] = index;
63704 + }
63705 +
63706 + return;
63707 +}
63708 +
63709 +static __inline__ void
63710 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63711 +{
63712 + int loc;
63713 + uid_t uid = GR_GLOBAL_UID(kuid);
63714 +
63715 + if (uid_used == GR_UIDTABLE_MAX)
63716 + return;
63717 +
63718 + loc = gr_find_uid(uid);
63719 +
63720 + if (loc >= 0) {
63721 + uid_set[loc].expires = expires;
63722 + return;
63723 + }
63724 +
63725 + uid_set[uid_used].uid = uid;
63726 + uid_set[uid_used].expires = expires;
63727 + uid_used++;
63728 +
63729 + gr_insertsort();
63730 +
63731 + return;
63732 +}
63733 +
63734 +void
63735 +gr_remove_uid(const unsigned short loc)
63736 +{
63737 + unsigned short i;
63738 +
63739 + for (i = loc + 1; i < uid_used; i++)
63740 + uid_set[i - 1] = uid_set[i];
63741 +
63742 + uid_used--;
63743 +
63744 + return;
63745 +}
63746 +
63747 +int
63748 +gr_check_crash_uid(const kuid_t kuid)
63749 +{
63750 + int loc;
63751 + int ret = 0;
63752 + uid_t uid;
63753 +
63754 + if (unlikely(!gr_acl_is_enabled()))
63755 + return 0;
63756 +
63757 + uid = GR_GLOBAL_UID(kuid);
63758 +
63759 + spin_lock(&gr_uid_lock);
63760 + loc = gr_find_uid(uid);
63761 +
63762 + if (loc < 0)
63763 + goto out_unlock;
63764 +
63765 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63766 + gr_remove_uid(loc);
63767 + else
63768 + ret = 1;
63769 +
63770 +out_unlock:
63771 + spin_unlock(&gr_uid_lock);
63772 + return ret;
63773 +}
63774 +
63775 +static __inline__ int
63776 +proc_is_setxid(const struct cred *cred)
63777 +{
63778 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63779 + !uid_eq(cred->uid, cred->fsuid))
63780 + return 1;
63781 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63782 + !gid_eq(cred->gid, cred->fsgid))
63783 + return 1;
63784 +
63785 + return 0;
63786 +}
63787 +
63788 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63789 +
63790 +void
63791 +gr_handle_crash(struct task_struct *task, const int sig)
63792 +{
63793 + struct acl_subject_label *curr;
63794 + struct task_struct *tsk, *tsk2;
63795 + const struct cred *cred;
63796 + const struct cred *cred2;
63797 +
63798 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63799 + return;
63800 +
63801 + if (unlikely(!gr_acl_is_enabled()))
63802 + return;
63803 +
63804 + curr = task->acl;
63805 +
63806 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63807 + return;
63808 +
63809 + if (time_before_eq(curr->expires, get_seconds())) {
63810 + curr->expires = 0;
63811 + curr->crashes = 0;
63812 + }
63813 +
63814 + curr->crashes++;
63815 +
63816 + if (!curr->expires)
63817 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63818 +
63819 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63820 + time_after(curr->expires, get_seconds())) {
63821 + rcu_read_lock();
63822 + cred = __task_cred(task);
63823 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63824 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63825 + spin_lock(&gr_uid_lock);
63826 + gr_insert_uid(cred->uid, curr->expires);
63827 + spin_unlock(&gr_uid_lock);
63828 + curr->expires = 0;
63829 + curr->crashes = 0;
63830 + read_lock(&tasklist_lock);
63831 + do_each_thread(tsk2, tsk) {
63832 + cred2 = __task_cred(tsk);
63833 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63834 + gr_fake_force_sig(SIGKILL, tsk);
63835 + } while_each_thread(tsk2, tsk);
63836 + read_unlock(&tasklist_lock);
63837 + } else {
63838 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63839 + read_lock(&tasklist_lock);
63840 + read_lock(&grsec_exec_file_lock);
63841 + do_each_thread(tsk2, tsk) {
63842 + if (likely(tsk != task)) {
63843 + // if this thread has the same subject as the one that triggered
63844 + // RES_CRASH and it's the same binary, kill it
63845 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63846 + gr_fake_force_sig(SIGKILL, tsk);
63847 + }
63848 + } while_each_thread(tsk2, tsk);
63849 + read_unlock(&grsec_exec_file_lock);
63850 + read_unlock(&tasklist_lock);
63851 + }
63852 + rcu_read_unlock();
63853 + }
63854 +
63855 + return;
63856 +}
63857 +
63858 +int
63859 +gr_check_crash_exec(const struct file *filp)
63860 +{
63861 + struct acl_subject_label *curr;
63862 +
63863 + if (unlikely(!gr_acl_is_enabled()))
63864 + return 0;
63865 +
63866 + read_lock(&gr_inode_lock);
63867 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63868 + __get_dev(filp->f_path.dentry),
63869 + current->role);
63870 + read_unlock(&gr_inode_lock);
63871 +
63872 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63873 + (!curr->crashes && !curr->expires))
63874 + return 0;
63875 +
63876 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63877 + time_after(curr->expires, get_seconds()))
63878 + return 1;
63879 + else if (time_before_eq(curr->expires, get_seconds())) {
63880 + curr->crashes = 0;
63881 + curr->expires = 0;
63882 + }
63883 +
63884 + return 0;
63885 +}
63886 +
63887 +void
63888 +gr_handle_alertkill(struct task_struct *task)
63889 +{
63890 + struct acl_subject_label *curracl;
63891 + __u32 curr_ip;
63892 + struct task_struct *p, *p2;
63893 +
63894 + if (unlikely(!gr_acl_is_enabled()))
63895 + return;
63896 +
63897 + curracl = task->acl;
63898 + curr_ip = task->signal->curr_ip;
63899 +
63900 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63901 + read_lock(&tasklist_lock);
63902 + do_each_thread(p2, p) {
63903 + if (p->signal->curr_ip == curr_ip)
63904 + gr_fake_force_sig(SIGKILL, p);
63905 + } while_each_thread(p2, p);
63906 + read_unlock(&tasklist_lock);
63907 + } else if (curracl->mode & GR_KILLPROC)
63908 + gr_fake_force_sig(SIGKILL, task);
63909 +
63910 + return;
63911 +}
63912 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63913 new file mode 100644
63914 index 0000000..98011b0
63915 --- /dev/null
63916 +++ b/grsecurity/gracl_shm.c
63917 @@ -0,0 +1,40 @@
63918 +#include <linux/kernel.h>
63919 +#include <linux/mm.h>
63920 +#include <linux/sched.h>
63921 +#include <linux/file.h>
63922 +#include <linux/ipc.h>
63923 +#include <linux/gracl.h>
63924 +#include <linux/grsecurity.h>
63925 +#include <linux/grinternal.h>
63926 +
63927 +int
63928 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63929 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63930 +{
63931 + struct task_struct *task;
63932 +
63933 + if (!gr_acl_is_enabled())
63934 + return 1;
63935 +
63936 + rcu_read_lock();
63937 + read_lock(&tasklist_lock);
63938 +
63939 + task = find_task_by_vpid(shm_cprid);
63940 +
63941 + if (unlikely(!task))
63942 + task = find_task_by_vpid(shm_lapid);
63943 +
63944 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63945 + (task_pid_nr(task) == shm_lapid)) &&
63946 + (task->acl->mode & GR_PROTSHM) &&
63947 + (task->acl != current->acl))) {
63948 + read_unlock(&tasklist_lock);
63949 + rcu_read_unlock();
63950 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63951 + return 0;
63952 + }
63953 + read_unlock(&tasklist_lock);
63954 + rcu_read_unlock();
63955 +
63956 + return 1;
63957 +}
63958 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63959 new file mode 100644
63960 index 0000000..bc0be01
63961 --- /dev/null
63962 +++ b/grsecurity/grsec_chdir.c
63963 @@ -0,0 +1,19 @@
63964 +#include <linux/kernel.h>
63965 +#include <linux/sched.h>
63966 +#include <linux/fs.h>
63967 +#include <linux/file.h>
63968 +#include <linux/grsecurity.h>
63969 +#include <linux/grinternal.h>
63970 +
63971 +void
63972 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63973 +{
63974 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63975 + if ((grsec_enable_chdir && grsec_enable_group &&
63976 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63977 + !grsec_enable_group)) {
63978 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63979 + }
63980 +#endif
63981 + return;
63982 +}
63983 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63984 new file mode 100644
63985 index 0000000..8b4c803
63986 --- /dev/null
63987 +++ b/grsecurity/grsec_chroot.c
63988 @@ -0,0 +1,370 @@
63989 +#include <linux/kernel.h>
63990 +#include <linux/module.h>
63991 +#include <linux/sched.h>
63992 +#include <linux/file.h>
63993 +#include <linux/fs.h>
63994 +#include <linux/mount.h>
63995 +#include <linux/types.h>
63996 +#include "../fs/mount.h"
63997 +#include <linux/grsecurity.h>
63998 +#include <linux/grinternal.h>
63999 +
64000 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64001 +static int gr_init_ran;
64002 +#endif
64003 +
64004 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
64005 +{
64006 +#ifdef CONFIG_GRKERNSEC
64007 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64008 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64009 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64010 + && gr_init_ran
64011 +#endif
64012 + )
64013 + task->gr_is_chrooted = 1;
64014 + else {
64015 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64016 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64017 + gr_init_ran = 1;
64018 +#endif
64019 + task->gr_is_chrooted = 0;
64020 + }
64021 +
64022 + task->gr_chroot_dentry = path->dentry;
64023 +#endif
64024 + return;
64025 +}
64026 +
64027 +void gr_clear_chroot_entries(struct task_struct *task)
64028 +{
64029 +#ifdef CONFIG_GRKERNSEC
64030 + task->gr_is_chrooted = 0;
64031 + task->gr_chroot_dentry = NULL;
64032 +#endif
64033 + return;
64034 +}
64035 +
64036 +int
64037 +gr_handle_chroot_unix(const pid_t pid)
64038 +{
64039 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64040 + struct task_struct *p;
64041 +
64042 + if (unlikely(!grsec_enable_chroot_unix))
64043 + return 1;
64044 +
64045 + if (likely(!proc_is_chrooted(current)))
64046 + return 1;
64047 +
64048 + rcu_read_lock();
64049 + read_lock(&tasklist_lock);
64050 + p = find_task_by_vpid_unrestricted(pid);
64051 + if (unlikely(p && !have_same_root(current, p))) {
64052 + read_unlock(&tasklist_lock);
64053 + rcu_read_unlock();
64054 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64055 + return 0;
64056 + }
64057 + read_unlock(&tasklist_lock);
64058 + rcu_read_unlock();
64059 +#endif
64060 + return 1;
64061 +}
64062 +
64063 +int
64064 +gr_handle_chroot_nice(void)
64065 +{
64066 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64067 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64068 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64069 + return -EPERM;
64070 + }
64071 +#endif
64072 + return 0;
64073 +}
64074 +
64075 +int
64076 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64077 +{
64078 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64079 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64080 + && proc_is_chrooted(current)) {
64081 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64082 + return -EACCES;
64083 + }
64084 +#endif
64085 + return 0;
64086 +}
64087 +
64088 +int
64089 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64090 +{
64091 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64092 + struct task_struct *p;
64093 + int ret = 0;
64094 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64095 + return ret;
64096 +
64097 + read_lock(&tasklist_lock);
64098 + do_each_pid_task(pid, type, p) {
64099 + if (!have_same_root(current, p)) {
64100 + ret = 1;
64101 + goto out;
64102 + }
64103 + } while_each_pid_task(pid, type, p);
64104 +out:
64105 + read_unlock(&tasklist_lock);
64106 + return ret;
64107 +#endif
64108 + return 0;
64109 +}
64110 +
64111 +int
64112 +gr_pid_is_chrooted(struct task_struct *p)
64113 +{
64114 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64115 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64116 + return 0;
64117 +
64118 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64119 + !have_same_root(current, p)) {
64120 + return 1;
64121 + }
64122 +#endif
64123 + return 0;
64124 +}
64125 +
64126 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64127 +
64128 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64129 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64130 +{
64131 + struct path path, currentroot;
64132 + int ret = 0;
64133 +
64134 + path.dentry = (struct dentry *)u_dentry;
64135 + path.mnt = (struct vfsmount *)u_mnt;
64136 + get_fs_root(current->fs, &currentroot);
64137 + if (path_is_under(&path, &currentroot))
64138 + ret = 1;
64139 + path_put(&currentroot);
64140 +
64141 + return ret;
64142 +}
64143 +#endif
64144 +
64145 +int
64146 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64147 +{
64148 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64149 + if (!grsec_enable_chroot_fchdir)
64150 + return 1;
64151 +
64152 + if (!proc_is_chrooted(current))
64153 + return 1;
64154 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64155 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64156 + return 0;
64157 + }
64158 +#endif
64159 + return 1;
64160 +}
64161 +
64162 +int
64163 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64164 + const time_t shm_createtime)
64165 +{
64166 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64167 + struct task_struct *p;
64168 + time_t starttime;
64169 +
64170 + if (unlikely(!grsec_enable_chroot_shmat))
64171 + return 1;
64172 +
64173 + if (likely(!proc_is_chrooted(current)))
64174 + return 1;
64175 +
64176 + rcu_read_lock();
64177 + read_lock(&tasklist_lock);
64178 +
64179 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64180 + starttime = p->start_time.tv_sec;
64181 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64182 + if (have_same_root(current, p)) {
64183 + goto allow;
64184 + } else {
64185 + read_unlock(&tasklist_lock);
64186 + rcu_read_unlock();
64187 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64188 + return 0;
64189 + }
64190 + }
64191 + /* creator exited, pid reuse, fall through to next check */
64192 + }
64193 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64194 + if (unlikely(!have_same_root(current, p))) {
64195 + read_unlock(&tasklist_lock);
64196 + rcu_read_unlock();
64197 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64198 + return 0;
64199 + }
64200 + }
64201 +
64202 +allow:
64203 + read_unlock(&tasklist_lock);
64204 + rcu_read_unlock();
64205 +#endif
64206 + return 1;
64207 +}
64208 +
64209 +void
64210 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64211 +{
64212 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64213 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64214 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64215 +#endif
64216 + return;
64217 +}
64218 +
64219 +int
64220 +gr_handle_chroot_mknod(const struct dentry *dentry,
64221 + const struct vfsmount *mnt, const int mode)
64222 +{
64223 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64224 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64225 + proc_is_chrooted(current)) {
64226 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64227 + return -EPERM;
64228 + }
64229 +#endif
64230 + return 0;
64231 +}
64232 +
64233 +int
64234 +gr_handle_chroot_mount(const struct dentry *dentry,
64235 + const struct vfsmount *mnt, const char *dev_name)
64236 +{
64237 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64238 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64239 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64240 + return -EPERM;
64241 + }
64242 +#endif
64243 + return 0;
64244 +}
64245 +
64246 +int
64247 +gr_handle_chroot_pivot(void)
64248 +{
64249 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64250 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64251 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64252 + return -EPERM;
64253 + }
64254 +#endif
64255 + return 0;
64256 +}
64257 +
64258 +int
64259 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64260 +{
64261 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64262 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64263 + !gr_is_outside_chroot(dentry, mnt)) {
64264 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64265 + return -EPERM;
64266 + }
64267 +#endif
64268 + return 0;
64269 +}
64270 +
64271 +extern const char *captab_log[];
64272 +extern int captab_log_entries;
64273 +
64274 +int
64275 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64276 +{
64277 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64278 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64279 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64280 + if (cap_raised(chroot_caps, cap)) {
64281 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64282 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64283 + }
64284 + return 0;
64285 + }
64286 + }
64287 +#endif
64288 + return 1;
64289 +}
64290 +
64291 +int
64292 +gr_chroot_is_capable(const int cap)
64293 +{
64294 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64295 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64296 +#endif
64297 + return 1;
64298 +}
64299 +
64300 +int
64301 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64302 +{
64303 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64304 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64305 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64306 + if (cap_raised(chroot_caps, cap)) {
64307 + return 0;
64308 + }
64309 + }
64310 +#endif
64311 + return 1;
64312 +}
64313 +
64314 +int
64315 +gr_chroot_is_capable_nolog(const int cap)
64316 +{
64317 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64318 + return gr_task_chroot_is_capable_nolog(current, cap);
64319 +#endif
64320 + return 1;
64321 +}
64322 +
64323 +int
64324 +gr_handle_chroot_sysctl(const int op)
64325 +{
64326 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64327 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64328 + proc_is_chrooted(current))
64329 + return -EACCES;
64330 +#endif
64331 + return 0;
64332 +}
64333 +
64334 +void
64335 +gr_handle_chroot_chdir(struct path *path)
64336 +{
64337 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64338 + if (grsec_enable_chroot_chdir)
64339 + set_fs_pwd(current->fs, path);
64340 +#endif
64341 + return;
64342 +}
64343 +
64344 +int
64345 +gr_handle_chroot_chmod(const struct dentry *dentry,
64346 + const struct vfsmount *mnt, const int mode)
64347 +{
64348 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64349 + /* allow chmod +s on directories, but not files */
64350 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64351 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64352 + proc_is_chrooted(current)) {
64353 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64354 + return -EPERM;
64355 + }
64356 +#endif
64357 + return 0;
64358 +}
64359 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64360 new file mode 100644
64361 index 0000000..207d409
64362 --- /dev/null
64363 +++ b/grsecurity/grsec_disabled.c
64364 @@ -0,0 +1,434 @@
64365 +#include <linux/kernel.h>
64366 +#include <linux/module.h>
64367 +#include <linux/sched.h>
64368 +#include <linux/file.h>
64369 +#include <linux/fs.h>
64370 +#include <linux/kdev_t.h>
64371 +#include <linux/net.h>
64372 +#include <linux/in.h>
64373 +#include <linux/ip.h>
64374 +#include <linux/skbuff.h>
64375 +#include <linux/sysctl.h>
64376 +
64377 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64378 +void
64379 +pax_set_initial_flags(struct linux_binprm *bprm)
64380 +{
64381 + return;
64382 +}
64383 +#endif
64384 +
64385 +#ifdef CONFIG_SYSCTL
64386 +__u32
64387 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64388 +{
64389 + return 0;
64390 +}
64391 +#endif
64392 +
64393 +#ifdef CONFIG_TASKSTATS
64394 +int gr_is_taskstats_denied(int pid)
64395 +{
64396 + return 0;
64397 +}
64398 +#endif
64399 +
64400 +int
64401 +gr_acl_is_enabled(void)
64402 +{
64403 + return 0;
64404 +}
64405 +
64406 +void
64407 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64408 +{
64409 + return;
64410 +}
64411 +
64412 +int
64413 +gr_handle_rawio(const struct inode *inode)
64414 +{
64415 + return 0;
64416 +}
64417 +
64418 +void
64419 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64420 +{
64421 + return;
64422 +}
64423 +
64424 +int
64425 +gr_handle_ptrace(struct task_struct *task, const long request)
64426 +{
64427 + return 0;
64428 +}
64429 +
64430 +int
64431 +gr_handle_proc_ptrace(struct task_struct *task)
64432 +{
64433 + return 0;
64434 +}
64435 +
64436 +int
64437 +gr_set_acls(const int type)
64438 +{
64439 + return 0;
64440 +}
64441 +
64442 +int
64443 +gr_check_hidden_task(const struct task_struct *tsk)
64444 +{
64445 + return 0;
64446 +}
64447 +
64448 +int
64449 +gr_check_protected_task(const struct task_struct *task)
64450 +{
64451 + return 0;
64452 +}
64453 +
64454 +int
64455 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64456 +{
64457 + return 0;
64458 +}
64459 +
64460 +void
64461 +gr_copy_label(struct task_struct *tsk)
64462 +{
64463 + return;
64464 +}
64465 +
64466 +void
64467 +gr_set_pax_flags(struct task_struct *task)
64468 +{
64469 + return;
64470 +}
64471 +
64472 +int
64473 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64474 + const int unsafe_share)
64475 +{
64476 + return 0;
64477 +}
64478 +
64479 +void
64480 +gr_handle_delete(const ino_t ino, const dev_t dev)
64481 +{
64482 + return;
64483 +}
64484 +
64485 +void
64486 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64487 +{
64488 + return;
64489 +}
64490 +
64491 +void
64492 +gr_handle_crash(struct task_struct *task, const int sig)
64493 +{
64494 + return;
64495 +}
64496 +
64497 +int
64498 +gr_check_crash_exec(const struct file *filp)
64499 +{
64500 + return 0;
64501 +}
64502 +
64503 +int
64504 +gr_check_crash_uid(const kuid_t uid)
64505 +{
64506 + return 0;
64507 +}
64508 +
64509 +void
64510 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64511 + struct dentry *old_dentry,
64512 + struct dentry *new_dentry,
64513 + struct vfsmount *mnt, const __u8 replace)
64514 +{
64515 + return;
64516 +}
64517 +
64518 +int
64519 +gr_search_socket(const int family, const int type, const int protocol)
64520 +{
64521 + return 1;
64522 +}
64523 +
64524 +int
64525 +gr_search_connectbind(const int mode, const struct socket *sock,
64526 + const struct sockaddr_in *addr)
64527 +{
64528 + return 0;
64529 +}
64530 +
64531 +void
64532 +gr_handle_alertkill(struct task_struct *task)
64533 +{
64534 + return;
64535 +}
64536 +
64537 +__u32
64538 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64539 +{
64540 + return 1;
64541 +}
64542 +
64543 +__u32
64544 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64545 + const struct vfsmount * mnt)
64546 +{
64547 + return 1;
64548 +}
64549 +
64550 +__u32
64551 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64552 + int acc_mode)
64553 +{
64554 + return 1;
64555 +}
64556 +
64557 +__u32
64558 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64559 +{
64560 + return 1;
64561 +}
64562 +
64563 +__u32
64564 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64565 +{
64566 + return 1;
64567 +}
64568 +
64569 +int
64570 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64571 + unsigned int *vm_flags)
64572 +{
64573 + return 1;
64574 +}
64575 +
64576 +__u32
64577 +gr_acl_handle_truncate(const struct dentry * dentry,
64578 + const struct vfsmount * mnt)
64579 +{
64580 + return 1;
64581 +}
64582 +
64583 +__u32
64584 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64585 +{
64586 + return 1;
64587 +}
64588 +
64589 +__u32
64590 +gr_acl_handle_access(const struct dentry * dentry,
64591 + const struct vfsmount * mnt, const int fmode)
64592 +{
64593 + return 1;
64594 +}
64595 +
64596 +__u32
64597 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64598 + umode_t *mode)
64599 +{
64600 + return 1;
64601 +}
64602 +
64603 +__u32
64604 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64605 +{
64606 + return 1;
64607 +}
64608 +
64609 +__u32
64610 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64611 +{
64612 + return 1;
64613 +}
64614 +
64615 +void
64616 +grsecurity_init(void)
64617 +{
64618 + return;
64619 +}
64620 +
64621 +umode_t gr_acl_umask(void)
64622 +{
64623 + return 0;
64624 +}
64625 +
64626 +__u32
64627 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64628 + const struct dentry * parent_dentry,
64629 + const struct vfsmount * parent_mnt,
64630 + const int mode)
64631 +{
64632 + return 1;
64633 +}
64634 +
64635 +__u32
64636 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64637 + const struct dentry * parent_dentry,
64638 + const struct vfsmount * parent_mnt)
64639 +{
64640 + return 1;
64641 +}
64642 +
64643 +__u32
64644 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64645 + const struct dentry * parent_dentry,
64646 + const struct vfsmount * parent_mnt, const struct filename *from)
64647 +{
64648 + return 1;
64649 +}
64650 +
64651 +__u32
64652 +gr_acl_handle_link(const struct dentry * new_dentry,
64653 + const struct dentry * parent_dentry,
64654 + const struct vfsmount * parent_mnt,
64655 + const struct dentry * old_dentry,
64656 + const struct vfsmount * old_mnt, const struct filename *to)
64657 +{
64658 + return 1;
64659 +}
64660 +
64661 +int
64662 +gr_acl_handle_rename(const struct dentry *new_dentry,
64663 + const struct dentry *parent_dentry,
64664 + const struct vfsmount *parent_mnt,
64665 + const struct dentry *old_dentry,
64666 + const struct inode *old_parent_inode,
64667 + const struct vfsmount *old_mnt, const struct filename *newname)
64668 +{
64669 + return 0;
64670 +}
64671 +
64672 +int
64673 +gr_acl_handle_filldir(const struct file *file, const char *name,
64674 + const int namelen, const ino_t ino)
64675 +{
64676 + return 1;
64677 +}
64678 +
64679 +int
64680 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64681 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64682 +{
64683 + return 1;
64684 +}
64685 +
64686 +int
64687 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64688 +{
64689 + return 0;
64690 +}
64691 +
64692 +int
64693 +gr_search_accept(const struct socket *sock)
64694 +{
64695 + return 0;
64696 +}
64697 +
64698 +int
64699 +gr_search_listen(const struct socket *sock)
64700 +{
64701 + return 0;
64702 +}
64703 +
64704 +int
64705 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64706 +{
64707 + return 0;
64708 +}
64709 +
64710 +__u32
64711 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64712 +{
64713 + return 1;
64714 +}
64715 +
64716 +__u32
64717 +gr_acl_handle_creat(const struct dentry * dentry,
64718 + const struct dentry * p_dentry,
64719 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64720 + const int imode)
64721 +{
64722 + return 1;
64723 +}
64724 +
64725 +void
64726 +gr_acl_handle_exit(void)
64727 +{
64728 + return;
64729 +}
64730 +
64731 +int
64732 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64733 +{
64734 + return 1;
64735 +}
64736 +
64737 +void
64738 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64739 +{
64740 + return;
64741 +}
64742 +
64743 +int
64744 +gr_acl_handle_procpidmem(const struct task_struct *task)
64745 +{
64746 + return 0;
64747 +}
64748 +
64749 +int
64750 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64751 +{
64752 + return 0;
64753 +}
64754 +
64755 +int
64756 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64757 +{
64758 + return 0;
64759 +}
64760 +
64761 +void
64762 +gr_set_kernel_label(struct task_struct *task)
64763 +{
64764 + return;
64765 +}
64766 +
64767 +int
64768 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64769 +{
64770 + return 0;
64771 +}
64772 +
64773 +int
64774 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64775 +{
64776 + return 0;
64777 +}
64778 +
64779 +int gr_acl_enable_at_secure(void)
64780 +{
64781 + return 0;
64782 +}
64783 +
64784 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64785 +{
64786 + return dentry->d_inode->i_sb->s_dev;
64787 +}
64788 +
64789 +void gr_put_exec_file(struct task_struct *task)
64790 +{
64791 + return;
64792 +}
64793 +
64794 +EXPORT_SYMBOL(gr_set_kernel_label);
64795 +#ifdef CONFIG_SECURITY
64796 +EXPORT_SYMBOL(gr_check_user_change);
64797 +EXPORT_SYMBOL(gr_check_group_change);
64798 +#endif
64799 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64800 new file mode 100644
64801 index 0000000..387032b
64802 --- /dev/null
64803 +++ b/grsecurity/grsec_exec.c
64804 @@ -0,0 +1,187 @@
64805 +#include <linux/kernel.h>
64806 +#include <linux/sched.h>
64807 +#include <linux/file.h>
64808 +#include <linux/binfmts.h>
64809 +#include <linux/fs.h>
64810 +#include <linux/types.h>
64811 +#include <linux/grdefs.h>
64812 +#include <linux/grsecurity.h>
64813 +#include <linux/grinternal.h>
64814 +#include <linux/capability.h>
64815 +#include <linux/module.h>
64816 +#include <linux/compat.h>
64817 +
64818 +#include <asm/uaccess.h>
64819 +
64820 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64821 +static char gr_exec_arg_buf[132];
64822 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64823 +#endif
64824 +
64825 +struct user_arg_ptr {
64826 +#ifdef CONFIG_COMPAT
64827 + bool is_compat;
64828 +#endif
64829 + union {
64830 + const char __user *const __user *native;
64831 +#ifdef CONFIG_COMPAT
64832 + const compat_uptr_t __user *compat;
64833 +#endif
64834 + } ptr;
64835 +};
64836 +
64837 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64838 +
64839 +void
64840 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64841 +{
64842 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64843 + char *grarg = gr_exec_arg_buf;
64844 + unsigned int i, x, execlen = 0;
64845 + char c;
64846 +
64847 + if (!((grsec_enable_execlog && grsec_enable_group &&
64848 + in_group_p(grsec_audit_gid))
64849 + || (grsec_enable_execlog && !grsec_enable_group)))
64850 + return;
64851 +
64852 + mutex_lock(&gr_exec_arg_mutex);
64853 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64854 +
64855 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64856 + const char __user *p;
64857 + unsigned int len;
64858 +
64859 + p = get_user_arg_ptr(argv, i);
64860 + if (IS_ERR(p))
64861 + goto log;
64862 +
64863 + len = strnlen_user(p, 128 - execlen);
64864 + if (len > 128 - execlen)
64865 + len = 128 - execlen;
64866 + else if (len > 0)
64867 + len--;
64868 + if (copy_from_user(grarg + execlen, p, len))
64869 + goto log;
64870 +
64871 + /* rewrite unprintable characters */
64872 + for (x = 0; x < len; x++) {
64873 + c = *(grarg + execlen + x);
64874 + if (c < 32 || c > 126)
64875 + *(grarg + execlen + x) = ' ';
64876 + }
64877 +
64878 + execlen += len;
64879 + *(grarg + execlen) = ' ';
64880 + *(grarg + execlen + 1) = '\0';
64881 + execlen++;
64882 + }
64883 +
64884 + log:
64885 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64886 + bprm->file->f_path.mnt, grarg);
64887 + mutex_unlock(&gr_exec_arg_mutex);
64888 +#endif
64889 + return;
64890 +}
64891 +
64892 +#ifdef CONFIG_GRKERNSEC
64893 +extern int gr_acl_is_capable(const int cap);
64894 +extern int gr_acl_is_capable_nolog(const int cap);
64895 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64896 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64897 +extern int gr_chroot_is_capable(const int cap);
64898 +extern int gr_chroot_is_capable_nolog(const int cap);
64899 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64900 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64901 +#endif
64902 +
64903 +const char *captab_log[] = {
64904 + "CAP_CHOWN",
64905 + "CAP_DAC_OVERRIDE",
64906 + "CAP_DAC_READ_SEARCH",
64907 + "CAP_FOWNER",
64908 + "CAP_FSETID",
64909 + "CAP_KILL",
64910 + "CAP_SETGID",
64911 + "CAP_SETUID",
64912 + "CAP_SETPCAP",
64913 + "CAP_LINUX_IMMUTABLE",
64914 + "CAP_NET_BIND_SERVICE",
64915 + "CAP_NET_BROADCAST",
64916 + "CAP_NET_ADMIN",
64917 + "CAP_NET_RAW",
64918 + "CAP_IPC_LOCK",
64919 + "CAP_IPC_OWNER",
64920 + "CAP_SYS_MODULE",
64921 + "CAP_SYS_RAWIO",
64922 + "CAP_SYS_CHROOT",
64923 + "CAP_SYS_PTRACE",
64924 + "CAP_SYS_PACCT",
64925 + "CAP_SYS_ADMIN",
64926 + "CAP_SYS_BOOT",
64927 + "CAP_SYS_NICE",
64928 + "CAP_SYS_RESOURCE",
64929 + "CAP_SYS_TIME",
64930 + "CAP_SYS_TTY_CONFIG",
64931 + "CAP_MKNOD",
64932 + "CAP_LEASE",
64933 + "CAP_AUDIT_WRITE",
64934 + "CAP_AUDIT_CONTROL",
64935 + "CAP_SETFCAP",
64936 + "CAP_MAC_OVERRIDE",
64937 + "CAP_MAC_ADMIN",
64938 + "CAP_SYSLOG",
64939 + "CAP_WAKE_ALARM"
64940 +};
64941 +
64942 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64943 +
64944 +int gr_is_capable(const int cap)
64945 +{
64946 +#ifdef CONFIG_GRKERNSEC
64947 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64948 + return 1;
64949 + return 0;
64950 +#else
64951 + return 1;
64952 +#endif
64953 +}
64954 +
64955 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64956 +{
64957 +#ifdef CONFIG_GRKERNSEC
64958 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64959 + return 1;
64960 + return 0;
64961 +#else
64962 + return 1;
64963 +#endif
64964 +}
64965 +
64966 +int gr_is_capable_nolog(const int cap)
64967 +{
64968 +#ifdef CONFIG_GRKERNSEC
64969 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64970 + return 1;
64971 + return 0;
64972 +#else
64973 + return 1;
64974 +#endif
64975 +}
64976 +
64977 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64978 +{
64979 +#ifdef CONFIG_GRKERNSEC
64980 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64981 + return 1;
64982 + return 0;
64983 +#else
64984 + return 1;
64985 +#endif
64986 +}
64987 +
64988 +EXPORT_SYMBOL(gr_is_capable);
64989 +EXPORT_SYMBOL(gr_is_capable_nolog);
64990 +EXPORT_SYMBOL(gr_task_is_capable);
64991 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64992 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64993 new file mode 100644
64994 index 0000000..06cc6ea
64995 --- /dev/null
64996 +++ b/grsecurity/grsec_fifo.c
64997 @@ -0,0 +1,24 @@
64998 +#include <linux/kernel.h>
64999 +#include <linux/sched.h>
65000 +#include <linux/fs.h>
65001 +#include <linux/file.h>
65002 +#include <linux/grinternal.h>
65003 +
65004 +int
65005 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65006 + const struct dentry *dir, const int flag, const int acc_mode)
65007 +{
65008 +#ifdef CONFIG_GRKERNSEC_FIFO
65009 + const struct cred *cred = current_cred();
65010 +
65011 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65012 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65013 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65014 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65015 + if (!inode_permission(dentry->d_inode, acc_mode))
65016 + 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));
65017 + return -EACCES;
65018 + }
65019 +#endif
65020 + return 0;
65021 +}
65022 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65023 new file mode 100644
65024 index 0000000..8ca18bf
65025 --- /dev/null
65026 +++ b/grsecurity/grsec_fork.c
65027 @@ -0,0 +1,23 @@
65028 +#include <linux/kernel.h>
65029 +#include <linux/sched.h>
65030 +#include <linux/grsecurity.h>
65031 +#include <linux/grinternal.h>
65032 +#include <linux/errno.h>
65033 +
65034 +void
65035 +gr_log_forkfail(const int retval)
65036 +{
65037 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65038 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65039 + switch (retval) {
65040 + case -EAGAIN:
65041 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65042 + break;
65043 + case -ENOMEM:
65044 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65045 + break;
65046 + }
65047 + }
65048 +#endif
65049 + return;
65050 +}
65051 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65052 new file mode 100644
65053 index 0000000..a862e9f
65054 --- /dev/null
65055 +++ b/grsecurity/grsec_init.c
65056 @@ -0,0 +1,283 @@
65057 +#include <linux/kernel.h>
65058 +#include <linux/sched.h>
65059 +#include <linux/mm.h>
65060 +#include <linux/gracl.h>
65061 +#include <linux/slab.h>
65062 +#include <linux/vmalloc.h>
65063 +#include <linux/percpu.h>
65064 +#include <linux/module.h>
65065 +
65066 +int grsec_enable_ptrace_readexec;
65067 +int grsec_enable_setxid;
65068 +int grsec_enable_symlinkown;
65069 +kgid_t grsec_symlinkown_gid;
65070 +int grsec_enable_brute;
65071 +int grsec_enable_link;
65072 +int grsec_enable_dmesg;
65073 +int grsec_enable_harden_ptrace;
65074 +int grsec_enable_fifo;
65075 +int grsec_enable_execlog;
65076 +int grsec_enable_signal;
65077 +int grsec_enable_forkfail;
65078 +int grsec_enable_audit_ptrace;
65079 +int grsec_enable_time;
65080 +int grsec_enable_audit_textrel;
65081 +int grsec_enable_group;
65082 +kgid_t grsec_audit_gid;
65083 +int grsec_enable_chdir;
65084 +int grsec_enable_mount;
65085 +int grsec_enable_rofs;
65086 +int grsec_enable_chroot_findtask;
65087 +int grsec_enable_chroot_mount;
65088 +int grsec_enable_chroot_shmat;
65089 +int grsec_enable_chroot_fchdir;
65090 +int grsec_enable_chroot_double;
65091 +int grsec_enable_chroot_pivot;
65092 +int grsec_enable_chroot_chdir;
65093 +int grsec_enable_chroot_chmod;
65094 +int grsec_enable_chroot_mknod;
65095 +int grsec_enable_chroot_nice;
65096 +int grsec_enable_chroot_execlog;
65097 +int grsec_enable_chroot_caps;
65098 +int grsec_enable_chroot_sysctl;
65099 +int grsec_enable_chroot_unix;
65100 +int grsec_enable_tpe;
65101 +kgid_t grsec_tpe_gid;
65102 +int grsec_enable_blackhole;
65103 +#ifdef CONFIG_IPV6_MODULE
65104 +EXPORT_SYMBOL(grsec_enable_blackhole);
65105 +#endif
65106 +int grsec_lastack_retries;
65107 +int grsec_enable_tpe_all;
65108 +int grsec_enable_tpe_invert;
65109 +int grsec_enable_socket_all;
65110 +kgid_t grsec_socket_all_gid;
65111 +int grsec_enable_socket_client;
65112 +kgid_t grsec_socket_client_gid;
65113 +int grsec_enable_socket_server;
65114 +kgid_t grsec_socket_server_gid;
65115 +int grsec_resource_logging;
65116 +int grsec_disable_privio;
65117 +int grsec_enable_log_rwxmaps;
65118 +int grsec_lock;
65119 +
65120 +DEFINE_SPINLOCK(grsec_alert_lock);
65121 +unsigned long grsec_alert_wtime = 0;
65122 +unsigned long grsec_alert_fyet = 0;
65123 +
65124 +DEFINE_SPINLOCK(grsec_audit_lock);
65125 +
65126 +DEFINE_RWLOCK(grsec_exec_file_lock);
65127 +
65128 +char *gr_shared_page[4];
65129 +
65130 +char *gr_alert_log_fmt;
65131 +char *gr_audit_log_fmt;
65132 +char *gr_alert_log_buf;
65133 +char *gr_audit_log_buf;
65134 +
65135 +extern struct gr_arg *gr_usermode;
65136 +extern unsigned char *gr_system_salt;
65137 +extern unsigned char *gr_system_sum;
65138 +
65139 +void __init
65140 +grsecurity_init(void)
65141 +{
65142 + int j;
65143 + /* create the per-cpu shared pages */
65144 +
65145 +#ifdef CONFIG_X86
65146 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65147 +#endif
65148 +
65149 + for (j = 0; j < 4; j++) {
65150 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65151 + if (gr_shared_page[j] == NULL) {
65152 + panic("Unable to allocate grsecurity shared page");
65153 + return;
65154 + }
65155 + }
65156 +
65157 + /* allocate log buffers */
65158 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65159 + if (!gr_alert_log_fmt) {
65160 + panic("Unable to allocate grsecurity alert log format buffer");
65161 + return;
65162 + }
65163 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65164 + if (!gr_audit_log_fmt) {
65165 + panic("Unable to allocate grsecurity audit log format buffer");
65166 + return;
65167 + }
65168 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65169 + if (!gr_alert_log_buf) {
65170 + panic("Unable to allocate grsecurity alert log buffer");
65171 + return;
65172 + }
65173 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65174 + if (!gr_audit_log_buf) {
65175 + panic("Unable to allocate grsecurity audit log buffer");
65176 + return;
65177 + }
65178 +
65179 + /* allocate memory for authentication structure */
65180 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65181 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65182 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65183 +
65184 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65185 + panic("Unable to allocate grsecurity authentication structure");
65186 + return;
65187 + }
65188 +
65189 +
65190 +#ifdef CONFIG_GRKERNSEC_IO
65191 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65192 + grsec_disable_privio = 1;
65193 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65194 + grsec_disable_privio = 1;
65195 +#else
65196 + grsec_disable_privio = 0;
65197 +#endif
65198 +#endif
65199 +
65200 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65201 + /* for backward compatibility, tpe_invert always defaults to on if
65202 + enabled in the kernel
65203 + */
65204 + grsec_enable_tpe_invert = 1;
65205 +#endif
65206 +
65207 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65208 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65209 + grsec_lock = 1;
65210 +#endif
65211 +
65212 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65213 + grsec_enable_audit_textrel = 1;
65214 +#endif
65215 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65216 + grsec_enable_log_rwxmaps = 1;
65217 +#endif
65218 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65219 + grsec_enable_group = 1;
65220 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65221 +#endif
65222 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65223 + grsec_enable_ptrace_readexec = 1;
65224 +#endif
65225 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65226 + grsec_enable_chdir = 1;
65227 +#endif
65228 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65229 + grsec_enable_harden_ptrace = 1;
65230 +#endif
65231 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65232 + grsec_enable_mount = 1;
65233 +#endif
65234 +#ifdef CONFIG_GRKERNSEC_LINK
65235 + grsec_enable_link = 1;
65236 +#endif
65237 +#ifdef CONFIG_GRKERNSEC_BRUTE
65238 + grsec_enable_brute = 1;
65239 +#endif
65240 +#ifdef CONFIG_GRKERNSEC_DMESG
65241 + grsec_enable_dmesg = 1;
65242 +#endif
65243 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65244 + grsec_enable_blackhole = 1;
65245 + grsec_lastack_retries = 4;
65246 +#endif
65247 +#ifdef CONFIG_GRKERNSEC_FIFO
65248 + grsec_enable_fifo = 1;
65249 +#endif
65250 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65251 + grsec_enable_execlog = 1;
65252 +#endif
65253 +#ifdef CONFIG_GRKERNSEC_SETXID
65254 + grsec_enable_setxid = 1;
65255 +#endif
65256 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65257 + grsec_enable_signal = 1;
65258 +#endif
65259 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65260 + grsec_enable_forkfail = 1;
65261 +#endif
65262 +#ifdef CONFIG_GRKERNSEC_TIME
65263 + grsec_enable_time = 1;
65264 +#endif
65265 +#ifdef CONFIG_GRKERNSEC_RESLOG
65266 + grsec_resource_logging = 1;
65267 +#endif
65268 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65269 + grsec_enable_chroot_findtask = 1;
65270 +#endif
65271 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65272 + grsec_enable_chroot_unix = 1;
65273 +#endif
65274 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65275 + grsec_enable_chroot_mount = 1;
65276 +#endif
65277 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65278 + grsec_enable_chroot_fchdir = 1;
65279 +#endif
65280 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65281 + grsec_enable_chroot_shmat = 1;
65282 +#endif
65283 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65284 + grsec_enable_audit_ptrace = 1;
65285 +#endif
65286 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65287 + grsec_enable_chroot_double = 1;
65288 +#endif
65289 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65290 + grsec_enable_chroot_pivot = 1;
65291 +#endif
65292 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65293 + grsec_enable_chroot_chdir = 1;
65294 +#endif
65295 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65296 + grsec_enable_chroot_chmod = 1;
65297 +#endif
65298 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65299 + grsec_enable_chroot_mknod = 1;
65300 +#endif
65301 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65302 + grsec_enable_chroot_nice = 1;
65303 +#endif
65304 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65305 + grsec_enable_chroot_execlog = 1;
65306 +#endif
65307 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65308 + grsec_enable_chroot_caps = 1;
65309 +#endif
65310 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65311 + grsec_enable_chroot_sysctl = 1;
65312 +#endif
65313 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65314 + grsec_enable_symlinkown = 1;
65315 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65316 +#endif
65317 +#ifdef CONFIG_GRKERNSEC_TPE
65318 + grsec_enable_tpe = 1;
65319 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65320 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65321 + grsec_enable_tpe_all = 1;
65322 +#endif
65323 +#endif
65324 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65325 + grsec_enable_socket_all = 1;
65326 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65327 +#endif
65328 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65329 + grsec_enable_socket_client = 1;
65330 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65331 +#endif
65332 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65333 + grsec_enable_socket_server = 1;
65334 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65335 +#endif
65336 +#endif
65337 +
65338 + return;
65339 +}
65340 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65341 new file mode 100644
65342 index 0000000..5e05e20
65343 --- /dev/null
65344 +++ b/grsecurity/grsec_link.c
65345 @@ -0,0 +1,58 @@
65346 +#include <linux/kernel.h>
65347 +#include <linux/sched.h>
65348 +#include <linux/fs.h>
65349 +#include <linux/file.h>
65350 +#include <linux/grinternal.h>
65351 +
65352 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65353 +{
65354 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65355 + const struct inode *link_inode = link->dentry->d_inode;
65356 +
65357 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65358 + /* ignore root-owned links, e.g. /proc/self */
65359 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65360 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65361 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65362 + return 1;
65363 + }
65364 +#endif
65365 + return 0;
65366 +}
65367 +
65368 +int
65369 +gr_handle_follow_link(const struct inode *parent,
65370 + const struct inode *inode,
65371 + const struct dentry *dentry, const struct vfsmount *mnt)
65372 +{
65373 +#ifdef CONFIG_GRKERNSEC_LINK
65374 + const struct cred *cred = current_cred();
65375 +
65376 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65377 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65378 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65379 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65380 + return -EACCES;
65381 + }
65382 +#endif
65383 + return 0;
65384 +}
65385 +
65386 +int
65387 +gr_handle_hardlink(const struct dentry *dentry,
65388 + const struct vfsmount *mnt,
65389 + struct inode *inode, const int mode, const struct filename *to)
65390 +{
65391 +#ifdef CONFIG_GRKERNSEC_LINK
65392 + const struct cred *cred = current_cred();
65393 +
65394 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65395 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65396 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65397 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65398 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65399 + return -EPERM;
65400 + }
65401 +#endif
65402 + return 0;
65403 +}
65404 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65405 new file mode 100644
65406 index 0000000..7c06085
65407 --- /dev/null
65408 +++ b/grsecurity/grsec_log.c
65409 @@ -0,0 +1,326 @@
65410 +#include <linux/kernel.h>
65411 +#include <linux/sched.h>
65412 +#include <linux/file.h>
65413 +#include <linux/tty.h>
65414 +#include <linux/fs.h>
65415 +#include <linux/grinternal.h>
65416 +
65417 +#ifdef CONFIG_TREE_PREEMPT_RCU
65418 +#define DISABLE_PREEMPT() preempt_disable()
65419 +#define ENABLE_PREEMPT() preempt_enable()
65420 +#else
65421 +#define DISABLE_PREEMPT()
65422 +#define ENABLE_PREEMPT()
65423 +#endif
65424 +
65425 +#define BEGIN_LOCKS(x) \
65426 + DISABLE_PREEMPT(); \
65427 + rcu_read_lock(); \
65428 + read_lock(&tasklist_lock); \
65429 + read_lock(&grsec_exec_file_lock); \
65430 + if (x != GR_DO_AUDIT) \
65431 + spin_lock(&grsec_alert_lock); \
65432 + else \
65433 + spin_lock(&grsec_audit_lock)
65434 +
65435 +#define END_LOCKS(x) \
65436 + if (x != GR_DO_AUDIT) \
65437 + spin_unlock(&grsec_alert_lock); \
65438 + else \
65439 + spin_unlock(&grsec_audit_lock); \
65440 + read_unlock(&grsec_exec_file_lock); \
65441 + read_unlock(&tasklist_lock); \
65442 + rcu_read_unlock(); \
65443 + ENABLE_PREEMPT(); \
65444 + if (x == GR_DONT_AUDIT) \
65445 + gr_handle_alertkill(current)
65446 +
65447 +enum {
65448 + FLOODING,
65449 + NO_FLOODING
65450 +};
65451 +
65452 +extern char *gr_alert_log_fmt;
65453 +extern char *gr_audit_log_fmt;
65454 +extern char *gr_alert_log_buf;
65455 +extern char *gr_audit_log_buf;
65456 +
65457 +static int gr_log_start(int audit)
65458 +{
65459 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65460 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65461 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65462 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65463 + unsigned long curr_secs = get_seconds();
65464 +
65465 + if (audit == GR_DO_AUDIT)
65466 + goto set_fmt;
65467 +
65468 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65469 + grsec_alert_wtime = curr_secs;
65470 + grsec_alert_fyet = 0;
65471 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65472 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65473 + grsec_alert_fyet++;
65474 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65475 + grsec_alert_wtime = curr_secs;
65476 + grsec_alert_fyet++;
65477 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65478 + return FLOODING;
65479 + }
65480 + else return FLOODING;
65481 +
65482 +set_fmt:
65483 +#endif
65484 + memset(buf, 0, PAGE_SIZE);
65485 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65486 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65487 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65488 + } else if (current->signal->curr_ip) {
65489 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65490 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65491 + } else if (gr_acl_is_enabled()) {
65492 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65493 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65494 + } else {
65495 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65496 + strcpy(buf, fmt);
65497 + }
65498 +
65499 + return NO_FLOODING;
65500 +}
65501 +
65502 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65503 + __attribute__ ((format (printf, 2, 0)));
65504 +
65505 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65506 +{
65507 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65508 + unsigned int len = strlen(buf);
65509 +
65510 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65511 +
65512 + return;
65513 +}
65514 +
65515 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65516 + __attribute__ ((format (printf, 2, 3)));
65517 +
65518 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65519 +{
65520 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65521 + unsigned int len = strlen(buf);
65522 + va_list ap;
65523 +
65524 + va_start(ap, msg);
65525 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65526 + va_end(ap);
65527 +
65528 + return;
65529 +}
65530 +
65531 +static void gr_log_end(int audit, int append_default)
65532 +{
65533 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65534 + if (append_default) {
65535 + struct task_struct *task = current;
65536 + struct task_struct *parent = task->real_parent;
65537 + const struct cred *cred = __task_cred(task);
65538 + const struct cred *pcred = __task_cred(parent);
65539 + unsigned int len = strlen(buf);
65540 +
65541 + 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));
65542 + }
65543 +
65544 + printk("%s\n", buf);
65545 +
65546 + return;
65547 +}
65548 +
65549 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65550 +{
65551 + int logtype;
65552 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65553 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65554 + void *voidptr = NULL;
65555 + int num1 = 0, num2 = 0;
65556 + unsigned long ulong1 = 0, ulong2 = 0;
65557 + struct dentry *dentry = NULL;
65558 + struct vfsmount *mnt = NULL;
65559 + struct file *file = NULL;
65560 + struct task_struct *task = NULL;
65561 + const struct cred *cred, *pcred;
65562 + va_list ap;
65563 +
65564 + BEGIN_LOCKS(audit);
65565 + logtype = gr_log_start(audit);
65566 + if (logtype == FLOODING) {
65567 + END_LOCKS(audit);
65568 + return;
65569 + }
65570 + va_start(ap, argtypes);
65571 + switch (argtypes) {
65572 + case GR_TTYSNIFF:
65573 + task = va_arg(ap, struct task_struct *);
65574 + 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));
65575 + break;
65576 + case GR_SYSCTL_HIDDEN:
65577 + str1 = va_arg(ap, char *);
65578 + gr_log_middle_varargs(audit, msg, result, str1);
65579 + break;
65580 + case GR_RBAC:
65581 + dentry = va_arg(ap, struct dentry *);
65582 + mnt = va_arg(ap, struct vfsmount *);
65583 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65584 + break;
65585 + case GR_RBAC_STR:
65586 + dentry = va_arg(ap, struct dentry *);
65587 + mnt = va_arg(ap, struct vfsmount *);
65588 + str1 = va_arg(ap, char *);
65589 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65590 + break;
65591 + case GR_STR_RBAC:
65592 + str1 = va_arg(ap, char *);
65593 + dentry = va_arg(ap, struct dentry *);
65594 + mnt = va_arg(ap, struct vfsmount *);
65595 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65596 + break;
65597 + case GR_RBAC_MODE2:
65598 + dentry = va_arg(ap, struct dentry *);
65599 + mnt = va_arg(ap, struct vfsmount *);
65600 + str1 = va_arg(ap, char *);
65601 + str2 = va_arg(ap, char *);
65602 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65603 + break;
65604 + case GR_RBAC_MODE3:
65605 + dentry = va_arg(ap, struct dentry *);
65606 + mnt = va_arg(ap, struct vfsmount *);
65607 + str1 = va_arg(ap, char *);
65608 + str2 = va_arg(ap, char *);
65609 + str3 = va_arg(ap, char *);
65610 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65611 + break;
65612 + case GR_FILENAME:
65613 + dentry = va_arg(ap, struct dentry *);
65614 + mnt = va_arg(ap, struct vfsmount *);
65615 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65616 + break;
65617 + case GR_STR_FILENAME:
65618 + str1 = va_arg(ap, char *);
65619 + dentry = va_arg(ap, struct dentry *);
65620 + mnt = va_arg(ap, struct vfsmount *);
65621 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65622 + break;
65623 + case GR_FILENAME_STR:
65624 + dentry = va_arg(ap, struct dentry *);
65625 + mnt = va_arg(ap, struct vfsmount *);
65626 + str1 = va_arg(ap, char *);
65627 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65628 + break;
65629 + case GR_FILENAME_TWO_INT:
65630 + dentry = va_arg(ap, struct dentry *);
65631 + mnt = va_arg(ap, struct vfsmount *);
65632 + num1 = va_arg(ap, int);
65633 + num2 = va_arg(ap, int);
65634 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65635 + break;
65636 + case GR_FILENAME_TWO_INT_STR:
65637 + dentry = va_arg(ap, struct dentry *);
65638 + mnt = va_arg(ap, struct vfsmount *);
65639 + num1 = va_arg(ap, int);
65640 + num2 = va_arg(ap, int);
65641 + str1 = va_arg(ap, char *);
65642 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65643 + break;
65644 + case GR_TEXTREL:
65645 + file = va_arg(ap, struct file *);
65646 + ulong1 = va_arg(ap, unsigned long);
65647 + ulong2 = va_arg(ap, unsigned long);
65648 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65649 + break;
65650 + case GR_PTRACE:
65651 + task = va_arg(ap, struct task_struct *);
65652 + 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));
65653 + break;
65654 + case GR_RESOURCE:
65655 + task = va_arg(ap, struct task_struct *);
65656 + cred = __task_cred(task);
65657 + pcred = __task_cred(task->real_parent);
65658 + ulong1 = va_arg(ap, unsigned long);
65659 + str1 = va_arg(ap, char *);
65660 + ulong2 = va_arg(ap, unsigned long);
65661 + 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));
65662 + break;
65663 + case GR_CAP:
65664 + task = va_arg(ap, struct task_struct *);
65665 + cred = __task_cred(task);
65666 + pcred = __task_cred(task->real_parent);
65667 + str1 = va_arg(ap, char *);
65668 + 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));
65669 + break;
65670 + case GR_SIG:
65671 + str1 = va_arg(ap, char *);
65672 + voidptr = va_arg(ap, void *);
65673 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65674 + break;
65675 + case GR_SIG2:
65676 + task = va_arg(ap, struct task_struct *);
65677 + cred = __task_cred(task);
65678 + pcred = __task_cred(task->real_parent);
65679 + num1 = va_arg(ap, int);
65680 + 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));
65681 + break;
65682 + case GR_CRASH1:
65683 + task = va_arg(ap, struct task_struct *);
65684 + cred = __task_cred(task);
65685 + pcred = __task_cred(task->real_parent);
65686 + ulong1 = va_arg(ap, unsigned long);
65687 + 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);
65688 + break;
65689 + case GR_CRASH2:
65690 + task = va_arg(ap, struct task_struct *);
65691 + cred = __task_cred(task);
65692 + pcred = __task_cred(task->real_parent);
65693 + ulong1 = va_arg(ap, unsigned long);
65694 + 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);
65695 + break;
65696 + case GR_RWXMAP:
65697 + file = va_arg(ap, struct file *);
65698 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65699 + break;
65700 + case GR_PSACCT:
65701 + {
65702 + unsigned int wday, cday;
65703 + __u8 whr, chr;
65704 + __u8 wmin, cmin;
65705 + __u8 wsec, csec;
65706 + char cur_tty[64] = { 0 };
65707 + char parent_tty[64] = { 0 };
65708 +
65709 + task = va_arg(ap, struct task_struct *);
65710 + wday = va_arg(ap, unsigned int);
65711 + cday = va_arg(ap, unsigned int);
65712 + whr = va_arg(ap, int);
65713 + chr = va_arg(ap, int);
65714 + wmin = va_arg(ap, int);
65715 + cmin = va_arg(ap, int);
65716 + wsec = va_arg(ap, int);
65717 + csec = va_arg(ap, int);
65718 + ulong1 = va_arg(ap, unsigned long);
65719 + cred = __task_cred(task);
65720 + pcred = __task_cred(task->real_parent);
65721 +
65722 + 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));
65723 + }
65724 + break;
65725 + default:
65726 + gr_log_middle(audit, msg, ap);
65727 + }
65728 + va_end(ap);
65729 + // these don't need DEFAULTSECARGS printed on the end
65730 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65731 + gr_log_end(audit, 0);
65732 + else
65733 + gr_log_end(audit, 1);
65734 + END_LOCKS(audit);
65735 +}
65736 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65737 new file mode 100644
65738 index 0000000..f536303
65739 --- /dev/null
65740 +++ b/grsecurity/grsec_mem.c
65741 @@ -0,0 +1,40 @@
65742 +#include <linux/kernel.h>
65743 +#include <linux/sched.h>
65744 +#include <linux/mm.h>
65745 +#include <linux/mman.h>
65746 +#include <linux/grinternal.h>
65747 +
65748 +void
65749 +gr_handle_ioperm(void)
65750 +{
65751 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65752 + return;
65753 +}
65754 +
65755 +void
65756 +gr_handle_iopl(void)
65757 +{
65758 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65759 + return;
65760 +}
65761 +
65762 +void
65763 +gr_handle_mem_readwrite(u64 from, u64 to)
65764 +{
65765 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65766 + return;
65767 +}
65768 +
65769 +void
65770 +gr_handle_vm86(void)
65771 +{
65772 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65773 + return;
65774 +}
65775 +
65776 +void
65777 +gr_log_badprocpid(const char *entry)
65778 +{
65779 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65780 + return;
65781 +}
65782 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65783 new file mode 100644
65784 index 0000000..2131422
65785 --- /dev/null
65786 +++ b/grsecurity/grsec_mount.c
65787 @@ -0,0 +1,62 @@
65788 +#include <linux/kernel.h>
65789 +#include <linux/sched.h>
65790 +#include <linux/mount.h>
65791 +#include <linux/grsecurity.h>
65792 +#include <linux/grinternal.h>
65793 +
65794 +void
65795 +gr_log_remount(const char *devname, const int retval)
65796 +{
65797 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65798 + if (grsec_enable_mount && (retval >= 0))
65799 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65800 +#endif
65801 + return;
65802 +}
65803 +
65804 +void
65805 +gr_log_unmount(const char *devname, const int retval)
65806 +{
65807 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65808 + if (grsec_enable_mount && (retval >= 0))
65809 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65810 +#endif
65811 + return;
65812 +}
65813 +
65814 +void
65815 +gr_log_mount(const char *from, const char *to, const int retval)
65816 +{
65817 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65818 + if (grsec_enable_mount && (retval >= 0))
65819 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65820 +#endif
65821 + return;
65822 +}
65823 +
65824 +int
65825 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65826 +{
65827 +#ifdef CONFIG_GRKERNSEC_ROFS
65828 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65829 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65830 + return -EPERM;
65831 + } else
65832 + return 0;
65833 +#endif
65834 + return 0;
65835 +}
65836 +
65837 +int
65838 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65839 +{
65840 +#ifdef CONFIG_GRKERNSEC_ROFS
65841 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65842 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65843 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65844 + return -EPERM;
65845 + } else
65846 + return 0;
65847 +#endif
65848 + return 0;
65849 +}
65850 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65851 new file mode 100644
65852 index 0000000..a3b12a0
65853 --- /dev/null
65854 +++ b/grsecurity/grsec_pax.c
65855 @@ -0,0 +1,36 @@
65856 +#include <linux/kernel.h>
65857 +#include <linux/sched.h>
65858 +#include <linux/mm.h>
65859 +#include <linux/file.h>
65860 +#include <linux/grinternal.h>
65861 +#include <linux/grsecurity.h>
65862 +
65863 +void
65864 +gr_log_textrel(struct vm_area_struct * vma)
65865 +{
65866 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65867 + if (grsec_enable_audit_textrel)
65868 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65869 +#endif
65870 + return;
65871 +}
65872 +
65873 +void
65874 +gr_log_rwxmmap(struct file *file)
65875 +{
65876 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65877 + if (grsec_enable_log_rwxmaps)
65878 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65879 +#endif
65880 + return;
65881 +}
65882 +
65883 +void
65884 +gr_log_rwxmprotect(struct file *file)
65885 +{
65886 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65887 + if (grsec_enable_log_rwxmaps)
65888 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65889 +#endif
65890 + return;
65891 +}
65892 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65893 new file mode 100644
65894 index 0000000..f7f29aa
65895 --- /dev/null
65896 +++ b/grsecurity/grsec_ptrace.c
65897 @@ -0,0 +1,30 @@
65898 +#include <linux/kernel.h>
65899 +#include <linux/sched.h>
65900 +#include <linux/grinternal.h>
65901 +#include <linux/security.h>
65902 +
65903 +void
65904 +gr_audit_ptrace(struct task_struct *task)
65905 +{
65906 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65907 + if (grsec_enable_audit_ptrace)
65908 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65909 +#endif
65910 + return;
65911 +}
65912 +
65913 +int
65914 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65915 +{
65916 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65917 + const struct dentry *dentry = file->f_path.dentry;
65918 + const struct vfsmount *mnt = file->f_path.mnt;
65919 +
65920 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65921 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65922 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65923 + return -EACCES;
65924 + }
65925 +#endif
65926 + return 0;
65927 +}
65928 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65929 new file mode 100644
65930 index 0000000..e09715a
65931 --- /dev/null
65932 +++ b/grsecurity/grsec_sig.c
65933 @@ -0,0 +1,222 @@
65934 +#include <linux/kernel.h>
65935 +#include <linux/sched.h>
65936 +#include <linux/delay.h>
65937 +#include <linux/grsecurity.h>
65938 +#include <linux/grinternal.h>
65939 +#include <linux/hardirq.h>
65940 +
65941 +char *signames[] = {
65942 + [SIGSEGV] = "Segmentation fault",
65943 + [SIGILL] = "Illegal instruction",
65944 + [SIGABRT] = "Abort",
65945 + [SIGBUS] = "Invalid alignment/Bus error"
65946 +};
65947 +
65948 +void
65949 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65950 +{
65951 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65952 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65953 + (sig == SIGABRT) || (sig == SIGBUS))) {
65954 + if (task_pid_nr(t) == task_pid_nr(current)) {
65955 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65956 + } else {
65957 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65958 + }
65959 + }
65960 +#endif
65961 + return;
65962 +}
65963 +
65964 +int
65965 +gr_handle_signal(const struct task_struct *p, const int sig)
65966 +{
65967 +#ifdef CONFIG_GRKERNSEC
65968 + /* ignore the 0 signal for protected task checks */
65969 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65970 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65971 + return -EPERM;
65972 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65973 + return -EPERM;
65974 + }
65975 +#endif
65976 + return 0;
65977 +}
65978 +
65979 +#ifdef CONFIG_GRKERNSEC
65980 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65981 +
65982 +int gr_fake_force_sig(int sig, struct task_struct *t)
65983 +{
65984 + unsigned long int flags;
65985 + int ret, blocked, ignored;
65986 + struct k_sigaction *action;
65987 +
65988 + spin_lock_irqsave(&t->sighand->siglock, flags);
65989 + action = &t->sighand->action[sig-1];
65990 + ignored = action->sa.sa_handler == SIG_IGN;
65991 + blocked = sigismember(&t->blocked, sig);
65992 + if (blocked || ignored) {
65993 + action->sa.sa_handler = SIG_DFL;
65994 + if (blocked) {
65995 + sigdelset(&t->blocked, sig);
65996 + recalc_sigpending_and_wake(t);
65997 + }
65998 + }
65999 + if (action->sa.sa_handler == SIG_DFL)
66000 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66001 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66002 +
66003 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66004 +
66005 + return ret;
66006 +}
66007 +#endif
66008 +
66009 +#ifdef CONFIG_GRKERNSEC_BRUTE
66010 +#define GR_USER_BAN_TIME (15 * 60)
66011 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66012 +
66013 +static int __get_dumpable(unsigned long mm_flags)
66014 +{
66015 + int ret;
66016 +
66017 + ret = mm_flags & MMF_DUMPABLE_MASK;
66018 + return (ret >= 2) ? 2 : ret;
66019 +}
66020 +#endif
66021 +
66022 +void gr_handle_brute_attach(unsigned long mm_flags)
66023 +{
66024 +#ifdef CONFIG_GRKERNSEC_BRUTE
66025 + struct task_struct *p = current;
66026 + kuid_t uid = GLOBAL_ROOT_UID;
66027 + int daemon = 0;
66028 +
66029 + if (!grsec_enable_brute)
66030 + return;
66031 +
66032 + rcu_read_lock();
66033 + read_lock(&tasklist_lock);
66034 + read_lock(&grsec_exec_file_lock);
66035 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
66036 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66037 + p->real_parent->brute = 1;
66038 + daemon = 1;
66039 + } else {
66040 + const struct cred *cred = __task_cred(p), *cred2;
66041 + struct task_struct *tsk, *tsk2;
66042 +
66043 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66044 + struct user_struct *user;
66045 +
66046 + uid = cred->uid;
66047 +
66048 + /* this is put upon execution past expiration */
66049 + user = find_user(uid);
66050 + if (user == NULL)
66051 + goto unlock;
66052 + user->banned = 1;
66053 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
66054 + if (user->ban_expires == ~0UL)
66055 + user->ban_expires--;
66056 +
66057 + do_each_thread(tsk2, tsk) {
66058 + cred2 = __task_cred(tsk);
66059 + if (tsk != p && uid_eq(cred2->uid, uid))
66060 + gr_fake_force_sig(SIGKILL, tsk);
66061 + } while_each_thread(tsk2, tsk);
66062 + }
66063 + }
66064 +unlock:
66065 + read_unlock(&grsec_exec_file_lock);
66066 + read_unlock(&tasklist_lock);
66067 + rcu_read_unlock();
66068 +
66069 + if (gr_is_global_nonroot(uid))
66070 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
66071 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
66072 + else if (daemon)
66073 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66074 +
66075 +#endif
66076 + return;
66077 +}
66078 +
66079 +void gr_handle_brute_check(void)
66080 +{
66081 +#ifdef CONFIG_GRKERNSEC_BRUTE
66082 + struct task_struct *p = current;
66083 +
66084 + if (unlikely(p->brute)) {
66085 + if (!grsec_enable_brute)
66086 + p->brute = 0;
66087 + else if (time_before(get_seconds(), p->brute_expires))
66088 + msleep(30 * 1000);
66089 + }
66090 +#endif
66091 + return;
66092 +}
66093 +
66094 +void gr_handle_kernel_exploit(void)
66095 +{
66096 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66097 + const struct cred *cred;
66098 + struct task_struct *tsk, *tsk2;
66099 + struct user_struct *user;
66100 + kuid_t uid;
66101 +
66102 + if (in_irq() || in_serving_softirq() || in_nmi())
66103 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66104 +
66105 + uid = current_uid();
66106 +
66107 + if (gr_is_global_root(uid))
66108 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66109 + else {
66110 + /* kill all the processes of this user, hold a reference
66111 + to their creds struct, and prevent them from creating
66112 + another process until system reset
66113 + */
66114 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66115 + GR_GLOBAL_UID(uid));
66116 + /* we intentionally leak this ref */
66117 + user = get_uid(current->cred->user);
66118 + if (user) {
66119 + user->banned = 1;
66120 + user->ban_expires = ~0UL;
66121 + }
66122 +
66123 + read_lock(&tasklist_lock);
66124 + do_each_thread(tsk2, tsk) {
66125 + cred = __task_cred(tsk);
66126 + if (uid_eq(cred->uid, uid))
66127 + gr_fake_force_sig(SIGKILL, tsk);
66128 + } while_each_thread(tsk2, tsk);
66129 + read_unlock(&tasklist_lock);
66130 + }
66131 +#endif
66132 +}
66133 +
66134 +int __gr_process_user_ban(struct user_struct *user)
66135 +{
66136 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66137 + if (unlikely(user->banned)) {
66138 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66139 + user->banned = 0;
66140 + user->ban_expires = 0;
66141 + free_uid(user);
66142 + } else
66143 + return -EPERM;
66144 + }
66145 +#endif
66146 + return 0;
66147 +}
66148 +
66149 +int gr_process_user_ban(void)
66150 +{
66151 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66152 + return __gr_process_user_ban(current->cred->user);
66153 +#endif
66154 + return 0;
66155 +}
66156 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66157 new file mode 100644
66158 index 0000000..4030d57
66159 --- /dev/null
66160 +++ b/grsecurity/grsec_sock.c
66161 @@ -0,0 +1,244 @@
66162 +#include <linux/kernel.h>
66163 +#include <linux/module.h>
66164 +#include <linux/sched.h>
66165 +#include <linux/file.h>
66166 +#include <linux/net.h>
66167 +#include <linux/in.h>
66168 +#include <linux/ip.h>
66169 +#include <net/sock.h>
66170 +#include <net/inet_sock.h>
66171 +#include <linux/grsecurity.h>
66172 +#include <linux/grinternal.h>
66173 +#include <linux/gracl.h>
66174 +
66175 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66176 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66177 +
66178 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66179 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66180 +
66181 +#ifdef CONFIG_UNIX_MODULE
66182 +EXPORT_SYMBOL(gr_acl_handle_unix);
66183 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66184 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66185 +EXPORT_SYMBOL(gr_handle_create);
66186 +#endif
66187 +
66188 +#ifdef CONFIG_GRKERNSEC
66189 +#define gr_conn_table_size 32749
66190 +struct conn_table_entry {
66191 + struct conn_table_entry *next;
66192 + struct signal_struct *sig;
66193 +};
66194 +
66195 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66196 +DEFINE_SPINLOCK(gr_conn_table_lock);
66197 +
66198 +extern const char * gr_socktype_to_name(unsigned char type);
66199 +extern const char * gr_proto_to_name(unsigned char proto);
66200 +extern const char * gr_sockfamily_to_name(unsigned char family);
66201 +
66202 +static __inline__ int
66203 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66204 +{
66205 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66206 +}
66207 +
66208 +static __inline__ int
66209 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66210 + __u16 sport, __u16 dport)
66211 +{
66212 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66213 + sig->gr_sport == sport && sig->gr_dport == dport))
66214 + return 1;
66215 + else
66216 + return 0;
66217 +}
66218 +
66219 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66220 +{
66221 + struct conn_table_entry **match;
66222 + unsigned int index;
66223 +
66224 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66225 + sig->gr_sport, sig->gr_dport,
66226 + gr_conn_table_size);
66227 +
66228 + newent->sig = sig;
66229 +
66230 + match = &gr_conn_table[index];
66231 + newent->next = *match;
66232 + *match = newent;
66233 +
66234 + return;
66235 +}
66236 +
66237 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66238 +{
66239 + struct conn_table_entry *match, *last = NULL;
66240 + unsigned int index;
66241 +
66242 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66243 + sig->gr_sport, sig->gr_dport,
66244 + gr_conn_table_size);
66245 +
66246 + match = gr_conn_table[index];
66247 + while (match && !conn_match(match->sig,
66248 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66249 + sig->gr_dport)) {
66250 + last = match;
66251 + match = match->next;
66252 + }
66253 +
66254 + if (match) {
66255 + if (last)
66256 + last->next = match->next;
66257 + else
66258 + gr_conn_table[index] = NULL;
66259 + kfree(match);
66260 + }
66261 +
66262 + return;
66263 +}
66264 +
66265 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66266 + __u16 sport, __u16 dport)
66267 +{
66268 + struct conn_table_entry *match;
66269 + unsigned int index;
66270 +
66271 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66272 +
66273 + match = gr_conn_table[index];
66274 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66275 + match = match->next;
66276 +
66277 + if (match)
66278 + return match->sig;
66279 + else
66280 + return NULL;
66281 +}
66282 +
66283 +#endif
66284 +
66285 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66286 +{
66287 +#ifdef CONFIG_GRKERNSEC
66288 + struct signal_struct *sig = task->signal;
66289 + struct conn_table_entry *newent;
66290 +
66291 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66292 + if (newent == NULL)
66293 + return;
66294 + /* no bh lock needed since we are called with bh disabled */
66295 + spin_lock(&gr_conn_table_lock);
66296 + gr_del_task_from_ip_table_nolock(sig);
66297 + sig->gr_saddr = inet->inet_rcv_saddr;
66298 + sig->gr_daddr = inet->inet_daddr;
66299 + sig->gr_sport = inet->inet_sport;
66300 + sig->gr_dport = inet->inet_dport;
66301 + gr_add_to_task_ip_table_nolock(sig, newent);
66302 + spin_unlock(&gr_conn_table_lock);
66303 +#endif
66304 + return;
66305 +}
66306 +
66307 +void gr_del_task_from_ip_table(struct task_struct *task)
66308 +{
66309 +#ifdef CONFIG_GRKERNSEC
66310 + spin_lock_bh(&gr_conn_table_lock);
66311 + gr_del_task_from_ip_table_nolock(task->signal);
66312 + spin_unlock_bh(&gr_conn_table_lock);
66313 +#endif
66314 + return;
66315 +}
66316 +
66317 +void
66318 +gr_attach_curr_ip(const struct sock *sk)
66319 +{
66320 +#ifdef CONFIG_GRKERNSEC
66321 + struct signal_struct *p, *set;
66322 + const struct inet_sock *inet = inet_sk(sk);
66323 +
66324 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66325 + return;
66326 +
66327 + set = current->signal;
66328 +
66329 + spin_lock_bh(&gr_conn_table_lock);
66330 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66331 + inet->inet_dport, inet->inet_sport);
66332 + if (unlikely(p != NULL)) {
66333 + set->curr_ip = p->curr_ip;
66334 + set->used_accept = 1;
66335 + gr_del_task_from_ip_table_nolock(p);
66336 + spin_unlock_bh(&gr_conn_table_lock);
66337 + return;
66338 + }
66339 + spin_unlock_bh(&gr_conn_table_lock);
66340 +
66341 + set->curr_ip = inet->inet_daddr;
66342 + set->used_accept = 1;
66343 +#endif
66344 + return;
66345 +}
66346 +
66347 +int
66348 +gr_handle_sock_all(const int family, const int type, const int protocol)
66349 +{
66350 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66351 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66352 + (family != AF_UNIX)) {
66353 + if (family == AF_INET)
66354 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66355 + else
66356 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66357 + return -EACCES;
66358 + }
66359 +#endif
66360 + return 0;
66361 +}
66362 +
66363 +int
66364 +gr_handle_sock_server(const struct sockaddr *sck)
66365 +{
66366 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66367 + if (grsec_enable_socket_server &&
66368 + in_group_p(grsec_socket_server_gid) &&
66369 + sck && (sck->sa_family != AF_UNIX) &&
66370 + (sck->sa_family != AF_LOCAL)) {
66371 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66372 + return -EACCES;
66373 + }
66374 +#endif
66375 + return 0;
66376 +}
66377 +
66378 +int
66379 +gr_handle_sock_server_other(const struct sock *sck)
66380 +{
66381 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66382 + if (grsec_enable_socket_server &&
66383 + in_group_p(grsec_socket_server_gid) &&
66384 + sck && (sck->sk_family != AF_UNIX) &&
66385 + (sck->sk_family != AF_LOCAL)) {
66386 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66387 + return -EACCES;
66388 + }
66389 +#endif
66390 + return 0;
66391 +}
66392 +
66393 +int
66394 +gr_handle_sock_client(const struct sockaddr *sck)
66395 +{
66396 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66397 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66398 + sck && (sck->sa_family != AF_UNIX) &&
66399 + (sck->sa_family != AF_LOCAL)) {
66400 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66401 + return -EACCES;
66402 + }
66403 +#endif
66404 + return 0;
66405 +}
66406 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66407 new file mode 100644
66408 index 0000000..f55ef0f
66409 --- /dev/null
66410 +++ b/grsecurity/grsec_sysctl.c
66411 @@ -0,0 +1,469 @@
66412 +#include <linux/kernel.h>
66413 +#include <linux/sched.h>
66414 +#include <linux/sysctl.h>
66415 +#include <linux/grsecurity.h>
66416 +#include <linux/grinternal.h>
66417 +
66418 +int
66419 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66420 +{
66421 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66422 + if (dirname == NULL || name == NULL)
66423 + return 0;
66424 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66425 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66426 + return -EACCES;
66427 + }
66428 +#endif
66429 + return 0;
66430 +}
66431 +
66432 +#ifdef CONFIG_GRKERNSEC_ROFS
66433 +static int __maybe_unused one = 1;
66434 +#endif
66435 +
66436 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66437 +struct ctl_table grsecurity_table[] = {
66438 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66439 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66440 +#ifdef CONFIG_GRKERNSEC_IO
66441 + {
66442 + .procname = "disable_priv_io",
66443 + .data = &grsec_disable_privio,
66444 + .maxlen = sizeof(int),
66445 + .mode = 0600,
66446 + .proc_handler = &proc_dointvec,
66447 + },
66448 +#endif
66449 +#endif
66450 +#ifdef CONFIG_GRKERNSEC_LINK
66451 + {
66452 + .procname = "linking_restrictions",
66453 + .data = &grsec_enable_link,
66454 + .maxlen = sizeof(int),
66455 + .mode = 0600,
66456 + .proc_handler = &proc_dointvec,
66457 + },
66458 +#endif
66459 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66460 + {
66461 + .procname = "enforce_symlinksifowner",
66462 + .data = &grsec_enable_symlinkown,
66463 + .maxlen = sizeof(int),
66464 + .mode = 0600,
66465 + .proc_handler = &proc_dointvec,
66466 + },
66467 + {
66468 + .procname = "symlinkown_gid",
66469 + .data = &grsec_symlinkown_gid,
66470 + .maxlen = sizeof(int),
66471 + .mode = 0600,
66472 + .proc_handler = &proc_dointvec,
66473 + },
66474 +#endif
66475 +#ifdef CONFIG_GRKERNSEC_BRUTE
66476 + {
66477 + .procname = "deter_bruteforce",
66478 + .data = &grsec_enable_brute,
66479 + .maxlen = sizeof(int),
66480 + .mode = 0600,
66481 + .proc_handler = &proc_dointvec,
66482 + },
66483 +#endif
66484 +#ifdef CONFIG_GRKERNSEC_FIFO
66485 + {
66486 + .procname = "fifo_restrictions",
66487 + .data = &grsec_enable_fifo,
66488 + .maxlen = sizeof(int),
66489 + .mode = 0600,
66490 + .proc_handler = &proc_dointvec,
66491 + },
66492 +#endif
66493 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66494 + {
66495 + .procname = "ptrace_readexec",
66496 + .data = &grsec_enable_ptrace_readexec,
66497 + .maxlen = sizeof(int),
66498 + .mode = 0600,
66499 + .proc_handler = &proc_dointvec,
66500 + },
66501 +#endif
66502 +#ifdef CONFIG_GRKERNSEC_SETXID
66503 + {
66504 + .procname = "consistent_setxid",
66505 + .data = &grsec_enable_setxid,
66506 + .maxlen = sizeof(int),
66507 + .mode = 0600,
66508 + .proc_handler = &proc_dointvec,
66509 + },
66510 +#endif
66511 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66512 + {
66513 + .procname = "ip_blackhole",
66514 + .data = &grsec_enable_blackhole,
66515 + .maxlen = sizeof(int),
66516 + .mode = 0600,
66517 + .proc_handler = &proc_dointvec,
66518 + },
66519 + {
66520 + .procname = "lastack_retries",
66521 + .data = &grsec_lastack_retries,
66522 + .maxlen = sizeof(int),
66523 + .mode = 0600,
66524 + .proc_handler = &proc_dointvec,
66525 + },
66526 +#endif
66527 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66528 + {
66529 + .procname = "exec_logging",
66530 + .data = &grsec_enable_execlog,
66531 + .maxlen = sizeof(int),
66532 + .mode = 0600,
66533 + .proc_handler = &proc_dointvec,
66534 + },
66535 +#endif
66536 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66537 + {
66538 + .procname = "rwxmap_logging",
66539 + .data = &grsec_enable_log_rwxmaps,
66540 + .maxlen = sizeof(int),
66541 + .mode = 0600,
66542 + .proc_handler = &proc_dointvec,
66543 + },
66544 +#endif
66545 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66546 + {
66547 + .procname = "signal_logging",
66548 + .data = &grsec_enable_signal,
66549 + .maxlen = sizeof(int),
66550 + .mode = 0600,
66551 + .proc_handler = &proc_dointvec,
66552 + },
66553 +#endif
66554 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66555 + {
66556 + .procname = "forkfail_logging",
66557 + .data = &grsec_enable_forkfail,
66558 + .maxlen = sizeof(int),
66559 + .mode = 0600,
66560 + .proc_handler = &proc_dointvec,
66561 + },
66562 +#endif
66563 +#ifdef CONFIG_GRKERNSEC_TIME
66564 + {
66565 + .procname = "timechange_logging",
66566 + .data = &grsec_enable_time,
66567 + .maxlen = sizeof(int),
66568 + .mode = 0600,
66569 + .proc_handler = &proc_dointvec,
66570 + },
66571 +#endif
66572 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66573 + {
66574 + .procname = "chroot_deny_shmat",
66575 + .data = &grsec_enable_chroot_shmat,
66576 + .maxlen = sizeof(int),
66577 + .mode = 0600,
66578 + .proc_handler = &proc_dointvec,
66579 + },
66580 +#endif
66581 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66582 + {
66583 + .procname = "chroot_deny_unix",
66584 + .data = &grsec_enable_chroot_unix,
66585 + .maxlen = sizeof(int),
66586 + .mode = 0600,
66587 + .proc_handler = &proc_dointvec,
66588 + },
66589 +#endif
66590 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66591 + {
66592 + .procname = "chroot_deny_mount",
66593 + .data = &grsec_enable_chroot_mount,
66594 + .maxlen = sizeof(int),
66595 + .mode = 0600,
66596 + .proc_handler = &proc_dointvec,
66597 + },
66598 +#endif
66599 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66600 + {
66601 + .procname = "chroot_deny_fchdir",
66602 + .data = &grsec_enable_chroot_fchdir,
66603 + .maxlen = sizeof(int),
66604 + .mode = 0600,
66605 + .proc_handler = &proc_dointvec,
66606 + },
66607 +#endif
66608 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66609 + {
66610 + .procname = "chroot_deny_chroot",
66611 + .data = &grsec_enable_chroot_double,
66612 + .maxlen = sizeof(int),
66613 + .mode = 0600,
66614 + .proc_handler = &proc_dointvec,
66615 + },
66616 +#endif
66617 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66618 + {
66619 + .procname = "chroot_deny_pivot",
66620 + .data = &grsec_enable_chroot_pivot,
66621 + .maxlen = sizeof(int),
66622 + .mode = 0600,
66623 + .proc_handler = &proc_dointvec,
66624 + },
66625 +#endif
66626 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66627 + {
66628 + .procname = "chroot_enforce_chdir",
66629 + .data = &grsec_enable_chroot_chdir,
66630 + .maxlen = sizeof(int),
66631 + .mode = 0600,
66632 + .proc_handler = &proc_dointvec,
66633 + },
66634 +#endif
66635 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66636 + {
66637 + .procname = "chroot_deny_chmod",
66638 + .data = &grsec_enable_chroot_chmod,
66639 + .maxlen = sizeof(int),
66640 + .mode = 0600,
66641 + .proc_handler = &proc_dointvec,
66642 + },
66643 +#endif
66644 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66645 + {
66646 + .procname = "chroot_deny_mknod",
66647 + .data = &grsec_enable_chroot_mknod,
66648 + .maxlen = sizeof(int),
66649 + .mode = 0600,
66650 + .proc_handler = &proc_dointvec,
66651 + },
66652 +#endif
66653 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66654 + {
66655 + .procname = "chroot_restrict_nice",
66656 + .data = &grsec_enable_chroot_nice,
66657 + .maxlen = sizeof(int),
66658 + .mode = 0600,
66659 + .proc_handler = &proc_dointvec,
66660 + },
66661 +#endif
66662 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66663 + {
66664 + .procname = "chroot_execlog",
66665 + .data = &grsec_enable_chroot_execlog,
66666 + .maxlen = sizeof(int),
66667 + .mode = 0600,
66668 + .proc_handler = &proc_dointvec,
66669 + },
66670 +#endif
66671 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66672 + {
66673 + .procname = "chroot_caps",
66674 + .data = &grsec_enable_chroot_caps,
66675 + .maxlen = sizeof(int),
66676 + .mode = 0600,
66677 + .proc_handler = &proc_dointvec,
66678 + },
66679 +#endif
66680 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66681 + {
66682 + .procname = "chroot_deny_sysctl",
66683 + .data = &grsec_enable_chroot_sysctl,
66684 + .maxlen = sizeof(int),
66685 + .mode = 0600,
66686 + .proc_handler = &proc_dointvec,
66687 + },
66688 +#endif
66689 +#ifdef CONFIG_GRKERNSEC_TPE
66690 + {
66691 + .procname = "tpe",
66692 + .data = &grsec_enable_tpe,
66693 + .maxlen = sizeof(int),
66694 + .mode = 0600,
66695 + .proc_handler = &proc_dointvec,
66696 + },
66697 + {
66698 + .procname = "tpe_gid",
66699 + .data = &grsec_tpe_gid,
66700 + .maxlen = sizeof(int),
66701 + .mode = 0600,
66702 + .proc_handler = &proc_dointvec,
66703 + },
66704 +#endif
66705 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66706 + {
66707 + .procname = "tpe_invert",
66708 + .data = &grsec_enable_tpe_invert,
66709 + .maxlen = sizeof(int),
66710 + .mode = 0600,
66711 + .proc_handler = &proc_dointvec,
66712 + },
66713 +#endif
66714 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66715 + {
66716 + .procname = "tpe_restrict_all",
66717 + .data = &grsec_enable_tpe_all,
66718 + .maxlen = sizeof(int),
66719 + .mode = 0600,
66720 + .proc_handler = &proc_dointvec,
66721 + },
66722 +#endif
66723 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66724 + {
66725 + .procname = "socket_all",
66726 + .data = &grsec_enable_socket_all,
66727 + .maxlen = sizeof(int),
66728 + .mode = 0600,
66729 + .proc_handler = &proc_dointvec,
66730 + },
66731 + {
66732 + .procname = "socket_all_gid",
66733 + .data = &grsec_socket_all_gid,
66734 + .maxlen = sizeof(int),
66735 + .mode = 0600,
66736 + .proc_handler = &proc_dointvec,
66737 + },
66738 +#endif
66739 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66740 + {
66741 + .procname = "socket_client",
66742 + .data = &grsec_enable_socket_client,
66743 + .maxlen = sizeof(int),
66744 + .mode = 0600,
66745 + .proc_handler = &proc_dointvec,
66746 + },
66747 + {
66748 + .procname = "socket_client_gid",
66749 + .data = &grsec_socket_client_gid,
66750 + .maxlen = sizeof(int),
66751 + .mode = 0600,
66752 + .proc_handler = &proc_dointvec,
66753 + },
66754 +#endif
66755 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66756 + {
66757 + .procname = "socket_server",
66758 + .data = &grsec_enable_socket_server,
66759 + .maxlen = sizeof(int),
66760 + .mode = 0600,
66761 + .proc_handler = &proc_dointvec,
66762 + },
66763 + {
66764 + .procname = "socket_server_gid",
66765 + .data = &grsec_socket_server_gid,
66766 + .maxlen = sizeof(int),
66767 + .mode = 0600,
66768 + .proc_handler = &proc_dointvec,
66769 + },
66770 +#endif
66771 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66772 + {
66773 + .procname = "audit_group",
66774 + .data = &grsec_enable_group,
66775 + .maxlen = sizeof(int),
66776 + .mode = 0600,
66777 + .proc_handler = &proc_dointvec,
66778 + },
66779 + {
66780 + .procname = "audit_gid",
66781 + .data = &grsec_audit_gid,
66782 + .maxlen = sizeof(int),
66783 + .mode = 0600,
66784 + .proc_handler = &proc_dointvec,
66785 + },
66786 +#endif
66787 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66788 + {
66789 + .procname = "audit_chdir",
66790 + .data = &grsec_enable_chdir,
66791 + .maxlen = sizeof(int),
66792 + .mode = 0600,
66793 + .proc_handler = &proc_dointvec,
66794 + },
66795 +#endif
66796 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66797 + {
66798 + .procname = "audit_mount",
66799 + .data = &grsec_enable_mount,
66800 + .maxlen = sizeof(int),
66801 + .mode = 0600,
66802 + .proc_handler = &proc_dointvec,
66803 + },
66804 +#endif
66805 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66806 + {
66807 + .procname = "audit_textrel",
66808 + .data = &grsec_enable_audit_textrel,
66809 + .maxlen = sizeof(int),
66810 + .mode = 0600,
66811 + .proc_handler = &proc_dointvec,
66812 + },
66813 +#endif
66814 +#ifdef CONFIG_GRKERNSEC_DMESG
66815 + {
66816 + .procname = "dmesg",
66817 + .data = &grsec_enable_dmesg,
66818 + .maxlen = sizeof(int),
66819 + .mode = 0600,
66820 + .proc_handler = &proc_dointvec,
66821 + },
66822 +#endif
66823 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66824 + {
66825 + .procname = "chroot_findtask",
66826 + .data = &grsec_enable_chroot_findtask,
66827 + .maxlen = sizeof(int),
66828 + .mode = 0600,
66829 + .proc_handler = &proc_dointvec,
66830 + },
66831 +#endif
66832 +#ifdef CONFIG_GRKERNSEC_RESLOG
66833 + {
66834 + .procname = "resource_logging",
66835 + .data = &grsec_resource_logging,
66836 + .maxlen = sizeof(int),
66837 + .mode = 0600,
66838 + .proc_handler = &proc_dointvec,
66839 + },
66840 +#endif
66841 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66842 + {
66843 + .procname = "audit_ptrace",
66844 + .data = &grsec_enable_audit_ptrace,
66845 + .maxlen = sizeof(int),
66846 + .mode = 0600,
66847 + .proc_handler = &proc_dointvec,
66848 + },
66849 +#endif
66850 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66851 + {
66852 + .procname = "harden_ptrace",
66853 + .data = &grsec_enable_harden_ptrace,
66854 + .maxlen = sizeof(int),
66855 + .mode = 0600,
66856 + .proc_handler = &proc_dointvec,
66857 + },
66858 +#endif
66859 + {
66860 + .procname = "grsec_lock",
66861 + .data = &grsec_lock,
66862 + .maxlen = sizeof(int),
66863 + .mode = 0600,
66864 + .proc_handler = &proc_dointvec,
66865 + },
66866 +#endif
66867 +#ifdef CONFIG_GRKERNSEC_ROFS
66868 + {
66869 + .procname = "romount_protect",
66870 + .data = &grsec_enable_rofs,
66871 + .maxlen = sizeof(int),
66872 + .mode = 0600,
66873 + .proc_handler = &proc_dointvec_minmax,
66874 + .extra1 = &one,
66875 + .extra2 = &one,
66876 + },
66877 +#endif
66878 + { }
66879 +};
66880 +#endif
66881 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66882 new file mode 100644
66883 index 0000000..0dc13c3
66884 --- /dev/null
66885 +++ b/grsecurity/grsec_time.c
66886 @@ -0,0 +1,16 @@
66887 +#include <linux/kernel.h>
66888 +#include <linux/sched.h>
66889 +#include <linux/grinternal.h>
66890 +#include <linux/module.h>
66891 +
66892 +void
66893 +gr_log_timechange(void)
66894 +{
66895 +#ifdef CONFIG_GRKERNSEC_TIME
66896 + if (grsec_enable_time)
66897 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66898 +#endif
66899 + return;
66900 +}
66901 +
66902 +EXPORT_SYMBOL(gr_log_timechange);
66903 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66904 new file mode 100644
66905 index 0000000..ee57dcf
66906 --- /dev/null
66907 +++ b/grsecurity/grsec_tpe.c
66908 @@ -0,0 +1,73 @@
66909 +#include <linux/kernel.h>
66910 +#include <linux/sched.h>
66911 +#include <linux/file.h>
66912 +#include <linux/fs.h>
66913 +#include <linux/grinternal.h>
66914 +
66915 +extern int gr_acl_tpe_check(void);
66916 +
66917 +int
66918 +gr_tpe_allow(const struct file *file)
66919 +{
66920 +#ifdef CONFIG_GRKERNSEC
66921 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66922 + const struct cred *cred = current_cred();
66923 + char *msg = NULL;
66924 + char *msg2 = NULL;
66925 +
66926 + // never restrict root
66927 + if (gr_is_global_root(cred->uid))
66928 + return 1;
66929 +
66930 + if (grsec_enable_tpe) {
66931 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66932 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66933 + msg = "not being in trusted group";
66934 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66935 + msg = "being in untrusted group";
66936 +#else
66937 + if (in_group_p(grsec_tpe_gid))
66938 + msg = "being in untrusted group";
66939 +#endif
66940 + }
66941 + if (!msg && gr_acl_tpe_check())
66942 + msg = "being in untrusted role";
66943 +
66944 + // not in any affected group/role
66945 + if (!msg)
66946 + goto next_check;
66947 +
66948 + if (gr_is_global_nonroot(inode->i_uid))
66949 + msg2 = "file in non-root-owned directory";
66950 + else if (inode->i_mode & S_IWOTH)
66951 + msg2 = "file in world-writable directory";
66952 + else if (inode->i_mode & S_IWGRP)
66953 + msg2 = "file in group-writable directory";
66954 +
66955 + if (msg && msg2) {
66956 + char fullmsg[70] = {0};
66957 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66958 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66959 + return 0;
66960 + }
66961 + msg = NULL;
66962 +next_check:
66963 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66964 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66965 + return 1;
66966 +
66967 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66968 + msg = "directory not owned by user";
66969 + else if (inode->i_mode & S_IWOTH)
66970 + msg = "file in world-writable directory";
66971 + else if (inode->i_mode & S_IWGRP)
66972 + msg = "file in group-writable directory";
66973 +
66974 + if (msg) {
66975 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66976 + return 0;
66977 + }
66978 +#endif
66979 +#endif
66980 + return 1;
66981 +}
66982 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66983 new file mode 100644
66984 index 0000000..9f7b1ac
66985 --- /dev/null
66986 +++ b/grsecurity/grsum.c
66987 @@ -0,0 +1,61 @@
66988 +#include <linux/err.h>
66989 +#include <linux/kernel.h>
66990 +#include <linux/sched.h>
66991 +#include <linux/mm.h>
66992 +#include <linux/scatterlist.h>
66993 +#include <linux/crypto.h>
66994 +#include <linux/gracl.h>
66995 +
66996 +
66997 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66998 +#error "crypto and sha256 must be built into the kernel"
66999 +#endif
67000 +
67001 +int
67002 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67003 +{
67004 + char *p;
67005 + struct crypto_hash *tfm;
67006 + struct hash_desc desc;
67007 + struct scatterlist sg;
67008 + unsigned char temp_sum[GR_SHA_LEN];
67009 + volatile int retval = 0;
67010 + volatile int dummy = 0;
67011 + unsigned int i;
67012 +
67013 + sg_init_table(&sg, 1);
67014 +
67015 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67016 + if (IS_ERR(tfm)) {
67017 + /* should never happen, since sha256 should be built in */
67018 + return 1;
67019 + }
67020 +
67021 + desc.tfm = tfm;
67022 + desc.flags = 0;
67023 +
67024 + crypto_hash_init(&desc);
67025 +
67026 + p = salt;
67027 + sg_set_buf(&sg, p, GR_SALT_LEN);
67028 + crypto_hash_update(&desc, &sg, sg.length);
67029 +
67030 + p = entry->pw;
67031 + sg_set_buf(&sg, p, strlen(p));
67032 +
67033 + crypto_hash_update(&desc, &sg, sg.length);
67034 +
67035 + crypto_hash_final(&desc, temp_sum);
67036 +
67037 + memset(entry->pw, 0, GR_PW_LEN);
67038 +
67039 + for (i = 0; i < GR_SHA_LEN; i++)
67040 + if (sum[i] != temp_sum[i])
67041 + retval = 1;
67042 + else
67043 + dummy = 1; // waste a cycle
67044 +
67045 + crypto_free_hash(tfm);
67046 +
67047 + return retval;
67048 +}
67049 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67050 index 77ff547..181834f 100644
67051 --- a/include/asm-generic/4level-fixup.h
67052 +++ b/include/asm-generic/4level-fixup.h
67053 @@ -13,8 +13,10 @@
67054 #define pmd_alloc(mm, pud, address) \
67055 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67056 NULL: pmd_offset(pud, address))
67057 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67058
67059 #define pud_alloc(mm, pgd, address) (pgd)
67060 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67061 #define pud_offset(pgd, start) (pgd)
67062 #define pud_none(pud) 0
67063 #define pud_bad(pud) 0
67064 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67065 index b7babf0..04ad282 100644
67066 --- a/include/asm-generic/atomic-long.h
67067 +++ b/include/asm-generic/atomic-long.h
67068 @@ -22,6 +22,12 @@
67069
67070 typedef atomic64_t atomic_long_t;
67071
67072 +#ifdef CONFIG_PAX_REFCOUNT
67073 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67074 +#else
67075 +typedef atomic64_t atomic_long_unchecked_t;
67076 +#endif
67077 +
67078 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67079
67080 static inline long atomic_long_read(atomic_long_t *l)
67081 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67082 return (long)atomic64_read(v);
67083 }
67084
67085 +#ifdef CONFIG_PAX_REFCOUNT
67086 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67087 +{
67088 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67089 +
67090 + return (long)atomic64_read_unchecked(v);
67091 +}
67092 +#endif
67093 +
67094 static inline void atomic_long_set(atomic_long_t *l, long i)
67095 {
67096 atomic64_t *v = (atomic64_t *)l;
67097 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67098 atomic64_set(v, i);
67099 }
67100
67101 +#ifdef CONFIG_PAX_REFCOUNT
67102 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67103 +{
67104 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67105 +
67106 + atomic64_set_unchecked(v, i);
67107 +}
67108 +#endif
67109 +
67110 static inline void atomic_long_inc(atomic_long_t *l)
67111 {
67112 atomic64_t *v = (atomic64_t *)l;
67113 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67114 atomic64_inc(v);
67115 }
67116
67117 +#ifdef CONFIG_PAX_REFCOUNT
67118 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67119 +{
67120 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67121 +
67122 + atomic64_inc_unchecked(v);
67123 +}
67124 +#endif
67125 +
67126 static inline void atomic_long_dec(atomic_long_t *l)
67127 {
67128 atomic64_t *v = (atomic64_t *)l;
67129 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67130 atomic64_dec(v);
67131 }
67132
67133 +#ifdef CONFIG_PAX_REFCOUNT
67134 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67135 +{
67136 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67137 +
67138 + atomic64_dec_unchecked(v);
67139 +}
67140 +#endif
67141 +
67142 static inline void atomic_long_add(long i, atomic_long_t *l)
67143 {
67144 atomic64_t *v = (atomic64_t *)l;
67145 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67146 atomic64_add(i, v);
67147 }
67148
67149 +#ifdef CONFIG_PAX_REFCOUNT
67150 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67151 +{
67152 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67153 +
67154 + atomic64_add_unchecked(i, v);
67155 +}
67156 +#endif
67157 +
67158 static inline void atomic_long_sub(long i, atomic_long_t *l)
67159 {
67160 atomic64_t *v = (atomic64_t *)l;
67161 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67162 atomic64_sub(i, v);
67163 }
67164
67165 +#ifdef CONFIG_PAX_REFCOUNT
67166 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67167 +{
67168 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67169 +
67170 + atomic64_sub_unchecked(i, v);
67171 +}
67172 +#endif
67173 +
67174 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67175 {
67176 atomic64_t *v = (atomic64_t *)l;
67177 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67178 return (long)atomic64_add_return(i, v);
67179 }
67180
67181 +#ifdef CONFIG_PAX_REFCOUNT
67182 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67183 +{
67184 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67185 +
67186 + return (long)atomic64_add_return_unchecked(i, v);
67187 +}
67188 +#endif
67189 +
67190 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67191 {
67192 atomic64_t *v = (atomic64_t *)l;
67193 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67194 return (long)atomic64_inc_return(v);
67195 }
67196
67197 +#ifdef CONFIG_PAX_REFCOUNT
67198 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67199 +{
67200 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67201 +
67202 + return (long)atomic64_inc_return_unchecked(v);
67203 +}
67204 +#endif
67205 +
67206 static inline long atomic_long_dec_return(atomic_long_t *l)
67207 {
67208 atomic64_t *v = (atomic64_t *)l;
67209 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67210
67211 typedef atomic_t atomic_long_t;
67212
67213 +#ifdef CONFIG_PAX_REFCOUNT
67214 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67215 +#else
67216 +typedef atomic_t atomic_long_unchecked_t;
67217 +#endif
67218 +
67219 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67220 static inline long atomic_long_read(atomic_long_t *l)
67221 {
67222 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67223 return (long)atomic_read(v);
67224 }
67225
67226 +#ifdef CONFIG_PAX_REFCOUNT
67227 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67228 +{
67229 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67230 +
67231 + return (long)atomic_read_unchecked(v);
67232 +}
67233 +#endif
67234 +
67235 static inline void atomic_long_set(atomic_long_t *l, long i)
67236 {
67237 atomic_t *v = (atomic_t *)l;
67238 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67239 atomic_set(v, i);
67240 }
67241
67242 +#ifdef CONFIG_PAX_REFCOUNT
67243 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67244 +{
67245 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67246 +
67247 + atomic_set_unchecked(v, i);
67248 +}
67249 +#endif
67250 +
67251 static inline void atomic_long_inc(atomic_long_t *l)
67252 {
67253 atomic_t *v = (atomic_t *)l;
67254 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67255 atomic_inc(v);
67256 }
67257
67258 +#ifdef CONFIG_PAX_REFCOUNT
67259 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67260 +{
67261 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67262 +
67263 + atomic_inc_unchecked(v);
67264 +}
67265 +#endif
67266 +
67267 static inline void atomic_long_dec(atomic_long_t *l)
67268 {
67269 atomic_t *v = (atomic_t *)l;
67270 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67271 atomic_dec(v);
67272 }
67273
67274 +#ifdef CONFIG_PAX_REFCOUNT
67275 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67276 +{
67277 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67278 +
67279 + atomic_dec_unchecked(v);
67280 +}
67281 +#endif
67282 +
67283 static inline void atomic_long_add(long i, atomic_long_t *l)
67284 {
67285 atomic_t *v = (atomic_t *)l;
67286 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67287 atomic_add(i, v);
67288 }
67289
67290 +#ifdef CONFIG_PAX_REFCOUNT
67291 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67292 +{
67293 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67294 +
67295 + atomic_add_unchecked(i, v);
67296 +}
67297 +#endif
67298 +
67299 static inline void atomic_long_sub(long i, atomic_long_t *l)
67300 {
67301 atomic_t *v = (atomic_t *)l;
67302 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67303 atomic_sub(i, v);
67304 }
67305
67306 +#ifdef CONFIG_PAX_REFCOUNT
67307 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67308 +{
67309 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67310 +
67311 + atomic_sub_unchecked(i, v);
67312 +}
67313 +#endif
67314 +
67315 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67316 {
67317 atomic_t *v = (atomic_t *)l;
67318 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67319 return (long)atomic_add_return(i, v);
67320 }
67321
67322 +#ifdef CONFIG_PAX_REFCOUNT
67323 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67324 +{
67325 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67326 +
67327 + return (long)atomic_add_return_unchecked(i, v);
67328 +}
67329 +
67330 +#endif
67331 +
67332 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67333 {
67334 atomic_t *v = (atomic_t *)l;
67335 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67336 return (long)atomic_inc_return(v);
67337 }
67338
67339 +#ifdef CONFIG_PAX_REFCOUNT
67340 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67341 +{
67342 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67343 +
67344 + return (long)atomic_inc_return_unchecked(v);
67345 +}
67346 +#endif
67347 +
67348 static inline long atomic_long_dec_return(atomic_long_t *l)
67349 {
67350 atomic_t *v = (atomic_t *)l;
67351 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67352
67353 #endif /* BITS_PER_LONG == 64 */
67354
67355 +#ifdef CONFIG_PAX_REFCOUNT
67356 +static inline void pax_refcount_needs_these_functions(void)
67357 +{
67358 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67359 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67360 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67361 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67362 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67363 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67364 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67365 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67366 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67367 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67368 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67369 +#ifdef CONFIG_X86
67370 + atomic_clear_mask_unchecked(0, NULL);
67371 + atomic_set_mask_unchecked(0, NULL);
67372 +#endif
67373 +
67374 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67375 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67376 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67377 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67378 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67379 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67380 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67381 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67382 +}
67383 +#else
67384 +#define atomic_read_unchecked(v) atomic_read(v)
67385 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67386 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67387 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67388 +#define atomic_inc_unchecked(v) atomic_inc(v)
67389 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67390 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67391 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67392 +#define atomic_dec_unchecked(v) atomic_dec(v)
67393 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67394 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67395 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67396 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67397 +
67398 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67399 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67400 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67401 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67402 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67403 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67404 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67405 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67406 +#endif
67407 +
67408 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67409 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67410 index 1ced641..c896ee8 100644
67411 --- a/include/asm-generic/atomic.h
67412 +++ b/include/asm-generic/atomic.h
67413 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67414 * Atomically clears the bits set in @mask from @v
67415 */
67416 #ifndef atomic_clear_mask
67417 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67418 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67419 {
67420 unsigned long flags;
67421
67422 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67423 index b18ce4f..2ee2843 100644
67424 --- a/include/asm-generic/atomic64.h
67425 +++ b/include/asm-generic/atomic64.h
67426 @@ -16,6 +16,8 @@ typedef struct {
67427 long long counter;
67428 } atomic64_t;
67429
67430 +typedef atomic64_t atomic64_unchecked_t;
67431 +
67432 #define ATOMIC64_INIT(i) { (i) }
67433
67434 extern long long atomic64_read(const atomic64_t *v);
67435 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67436 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67437 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67438
67439 +#define atomic64_read_unchecked(v) atomic64_read(v)
67440 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67441 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67442 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67443 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67444 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67445 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67446 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67447 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67448 +
67449 #endif /* _ASM_GENERIC_ATOMIC64_H */
67450 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67451 index 1bfcfe5..e04c5c9 100644
67452 --- a/include/asm-generic/cache.h
67453 +++ b/include/asm-generic/cache.h
67454 @@ -6,7 +6,7 @@
67455 * cache lines need to provide their own cache.h.
67456 */
67457
67458 -#define L1_CACHE_SHIFT 5
67459 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67460 +#define L1_CACHE_SHIFT 5UL
67461 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67462
67463 #endif /* __ASM_GENERIC_CACHE_H */
67464 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67465 index 0d68a1e..b74a761 100644
67466 --- a/include/asm-generic/emergency-restart.h
67467 +++ b/include/asm-generic/emergency-restart.h
67468 @@ -1,7 +1,7 @@
67469 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67470 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67471
67472 -static inline void machine_emergency_restart(void)
67473 +static inline __noreturn void machine_emergency_restart(void)
67474 {
67475 machine_restart(NULL);
67476 }
67477 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67478 index 90f99c7..00ce236 100644
67479 --- a/include/asm-generic/kmap_types.h
67480 +++ b/include/asm-generic/kmap_types.h
67481 @@ -2,9 +2,9 @@
67482 #define _ASM_GENERIC_KMAP_TYPES_H
67483
67484 #ifdef __WITH_KM_FENCE
67485 -# define KM_TYPE_NR 41
67486 +# define KM_TYPE_NR 42
67487 #else
67488 -# define KM_TYPE_NR 20
67489 +# define KM_TYPE_NR 21
67490 #endif
67491
67492 #endif
67493 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67494 index 9ceb03b..62b0b8f 100644
67495 --- a/include/asm-generic/local.h
67496 +++ b/include/asm-generic/local.h
67497 @@ -23,24 +23,37 @@ typedef struct
67498 atomic_long_t a;
67499 } local_t;
67500
67501 +typedef struct {
67502 + atomic_long_unchecked_t a;
67503 +} local_unchecked_t;
67504 +
67505 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67506
67507 #define local_read(l) atomic_long_read(&(l)->a)
67508 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67509 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67510 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67511 #define local_inc(l) atomic_long_inc(&(l)->a)
67512 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67513 #define local_dec(l) atomic_long_dec(&(l)->a)
67514 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67515 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67516 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67517 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67518 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67519
67520 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67521 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67522 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67523 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67524 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67525 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67526 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67527 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67528 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67529
67530 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67531 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67532 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67533 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67534 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67535 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67536 index 725612b..9cc513a 100644
67537 --- a/include/asm-generic/pgtable-nopmd.h
67538 +++ b/include/asm-generic/pgtable-nopmd.h
67539 @@ -1,14 +1,19 @@
67540 #ifndef _PGTABLE_NOPMD_H
67541 #define _PGTABLE_NOPMD_H
67542
67543 -#ifndef __ASSEMBLY__
67544 -
67545 #include <asm-generic/pgtable-nopud.h>
67546
67547 -struct mm_struct;
67548 -
67549 #define __PAGETABLE_PMD_FOLDED
67550
67551 +#define PMD_SHIFT PUD_SHIFT
67552 +#define PTRS_PER_PMD 1
67553 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67554 +#define PMD_MASK (~(PMD_SIZE-1))
67555 +
67556 +#ifndef __ASSEMBLY__
67557 +
67558 +struct mm_struct;
67559 +
67560 /*
67561 * Having the pmd type consist of a pud gets the size right, and allows
67562 * us to conceptually access the pud entry that this pmd is folded into
67563 @@ -16,11 +21,6 @@ struct mm_struct;
67564 */
67565 typedef struct { pud_t pud; } pmd_t;
67566
67567 -#define PMD_SHIFT PUD_SHIFT
67568 -#define PTRS_PER_PMD 1
67569 -#define PMD_SIZE (1UL << PMD_SHIFT)
67570 -#define PMD_MASK (~(PMD_SIZE-1))
67571 -
67572 /*
67573 * The "pud_xxx()" functions here are trivial for a folded two-level
67574 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67575 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67576 index 810431d..0ec4804f 100644
67577 --- a/include/asm-generic/pgtable-nopud.h
67578 +++ b/include/asm-generic/pgtable-nopud.h
67579 @@ -1,10 +1,15 @@
67580 #ifndef _PGTABLE_NOPUD_H
67581 #define _PGTABLE_NOPUD_H
67582
67583 -#ifndef __ASSEMBLY__
67584 -
67585 #define __PAGETABLE_PUD_FOLDED
67586
67587 +#define PUD_SHIFT PGDIR_SHIFT
67588 +#define PTRS_PER_PUD 1
67589 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67590 +#define PUD_MASK (~(PUD_SIZE-1))
67591 +
67592 +#ifndef __ASSEMBLY__
67593 +
67594 /*
67595 * Having the pud type consist of a pgd gets the size right, and allows
67596 * us to conceptually access the pgd entry that this pud is folded into
67597 @@ -12,11 +17,6 @@
67598 */
67599 typedef struct { pgd_t pgd; } pud_t;
67600
67601 -#define PUD_SHIFT PGDIR_SHIFT
67602 -#define PTRS_PER_PUD 1
67603 -#define PUD_SIZE (1UL << PUD_SHIFT)
67604 -#define PUD_MASK (~(PUD_SIZE-1))
67605 -
67606 /*
67607 * The "pgd_xxx()" functions here are trivial for a folded two-level
67608 * setup: the pud is never bad, and a pud always exists (as it's folded
67609 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67610 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67611
67612 #define pgd_populate(mm, pgd, pud) do { } while (0)
67613 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67614 /*
67615 * (puds are folded into pgds so this doesn't get actually called,
67616 * but the define is needed for a generic inline function.)
67617 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67618 index f50a87d..3860a22 100644
67619 --- a/include/asm-generic/pgtable.h
67620 +++ b/include/asm-generic/pgtable.h
67621 @@ -698,6 +698,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67622 }
67623 #endif /* CONFIG_NUMA_BALANCING */
67624
67625 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67626 +static inline unsigned long pax_open_kernel(void) { return 0; }
67627 +#endif
67628 +
67629 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67630 +static inline unsigned long pax_close_kernel(void) { return 0; }
67631 +#endif
67632 +
67633 #endif /* CONFIG_MMU */
67634
67635 #endif /* !__ASSEMBLY__ */
67636 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67637 index d1ea7ce..b1ebf2a 100644
67638 --- a/include/asm-generic/vmlinux.lds.h
67639 +++ b/include/asm-generic/vmlinux.lds.h
67640 @@ -218,6 +218,7 @@
67641 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67642 VMLINUX_SYMBOL(__start_rodata) = .; \
67643 *(.rodata) *(.rodata.*) \
67644 + *(.data..read_only) \
67645 *(__vermagic) /* Kernel version magic */ \
67646 . = ALIGN(8); \
67647 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67648 @@ -725,17 +726,18 @@
67649 * section in the linker script will go there too. @phdr should have
67650 * a leading colon.
67651 *
67652 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67653 + * Note that this macros defines per_cpu_load as an absolute symbol.
67654 * If there is no need to put the percpu section at a predetermined
67655 * address, use PERCPU_SECTION.
67656 */
67657 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67658 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67659 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67660 + per_cpu_load = .; \
67661 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67662 - LOAD_OFFSET) { \
67663 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67664 PERCPU_INPUT(cacheline) \
67665 } phdr \
67666 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67667 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67668
67669 /**
67670 * PERCPU_SECTION - define output section for percpu area, simple version
67671 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67672 index 418d270..bfd2794 100644
67673 --- a/include/crypto/algapi.h
67674 +++ b/include/crypto/algapi.h
67675 @@ -34,7 +34,7 @@ struct crypto_type {
67676 unsigned int maskclear;
67677 unsigned int maskset;
67678 unsigned int tfmsize;
67679 -};
67680 +} __do_const;
67681
67682 struct crypto_instance {
67683 struct crypto_alg alg;
67684 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67685 index fad21c9..ab858bc 100644
67686 --- a/include/drm/drmP.h
67687 +++ b/include/drm/drmP.h
67688 @@ -72,6 +72,7 @@
67689 #include <linux/workqueue.h>
67690 #include <linux/poll.h>
67691 #include <asm/pgalloc.h>
67692 +#include <asm/local.h>
67693 #include <drm/drm.h>
67694 #include <drm/drm_sarea.h>
67695
67696 @@ -293,10 +294,12 @@ do { \
67697 * \param cmd command.
67698 * \param arg argument.
67699 */
67700 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67701 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67702 + struct drm_file *file_priv);
67703 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67704 struct drm_file *file_priv);
67705
67706 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67707 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67708 unsigned long arg);
67709
67710 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67711 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67712 struct drm_ioctl_desc {
67713 unsigned int cmd;
67714 int flags;
67715 - drm_ioctl_t *func;
67716 + drm_ioctl_t func;
67717 unsigned int cmd_drv;
67718 -};
67719 +} __do_const;
67720
67721 /**
67722 * Creates a driver or general drm_ioctl_desc array entry for the given
67723 @@ -995,7 +998,7 @@ struct drm_info_list {
67724 int (*show)(struct seq_file*, void*); /** show callback */
67725 u32 driver_features; /**< Required driver features for this entry */
67726 void *data;
67727 -};
67728 +} __do_const;
67729
67730 /**
67731 * debugfs node structure. This structure represents a debugfs file.
67732 @@ -1068,7 +1071,7 @@ struct drm_device {
67733
67734 /** \name Usage Counters */
67735 /*@{ */
67736 - int open_count; /**< Outstanding files open */
67737 + local_t open_count; /**< Outstanding files open */
67738 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67739 atomic_t vma_count; /**< Outstanding vma areas open */
67740 int buf_use; /**< Buffers in use -- cannot alloc */
67741 @@ -1079,7 +1082,7 @@ struct drm_device {
67742 /*@{ */
67743 unsigned long counters;
67744 enum drm_stat_type types[15];
67745 - atomic_t counts[15];
67746 + atomic_unchecked_t counts[15];
67747 /*@} */
67748
67749 struct list_head filelist;
67750 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67751 index f43d556..94d9343 100644
67752 --- a/include/drm/drm_crtc_helper.h
67753 +++ b/include/drm/drm_crtc_helper.h
67754 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67755 struct drm_connector *connector);
67756 /* disable encoder when not in use - more explicit than dpms off */
67757 void (*disable)(struct drm_encoder *encoder);
67758 -};
67759 +} __no_const;
67760
67761 /**
67762 * drm_connector_helper_funcs - helper operations for connectors
67763 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67764 index 72dcbe8..8db58d7 100644
67765 --- a/include/drm/ttm/ttm_memory.h
67766 +++ b/include/drm/ttm/ttm_memory.h
67767 @@ -48,7 +48,7 @@
67768
67769 struct ttm_mem_shrink {
67770 int (*do_shrink) (struct ttm_mem_shrink *);
67771 -};
67772 +} __no_const;
67773
67774 /**
67775 * struct ttm_mem_global - Global memory accounting structure.
67776 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67777 index 4b840e8..155d235 100644
67778 --- a/include/keys/asymmetric-subtype.h
67779 +++ b/include/keys/asymmetric-subtype.h
67780 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67781 /* Verify the signature on a key of this subtype (optional) */
67782 int (*verify_signature)(const struct key *key,
67783 const struct public_key_signature *sig);
67784 -};
67785 +} __do_const;
67786
67787 /**
67788 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67789 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67790 index c1da539..1dcec55 100644
67791 --- a/include/linux/atmdev.h
67792 +++ b/include/linux/atmdev.h
67793 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67794 #endif
67795
67796 struct k_atm_aal_stats {
67797 -#define __HANDLE_ITEM(i) atomic_t i
67798 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67799 __AAL_STAT_ITEMS
67800 #undef __HANDLE_ITEM
67801 };
67802 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67803 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67804 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67805 struct module *owner;
67806 -};
67807 +} __do_const ;
67808
67809 struct atmphy_ops {
67810 int (*start)(struct atm_dev *dev);
67811 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67812 index 0530b98..96a8ac0 100644
67813 --- a/include/linux/binfmts.h
67814 +++ b/include/linux/binfmts.h
67815 @@ -73,8 +73,9 @@ struct linux_binfmt {
67816 int (*load_binary)(struct linux_binprm *);
67817 int (*load_shlib)(struct file *);
67818 int (*core_dump)(struct coredump_params *cprm);
67819 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67820 unsigned long min_coredump; /* minimal dump size */
67821 -};
67822 +} __do_const;
67823
67824 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67825
67826 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67827 index f94bc83..62b9cfe 100644
67828 --- a/include/linux/blkdev.h
67829 +++ b/include/linux/blkdev.h
67830 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67831 /* this callback is with swap_lock and sometimes page table lock held */
67832 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67833 struct module *owner;
67834 -};
67835 +} __do_const;
67836
67837 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67838 unsigned long);
67839 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67840 index 7c2e030..b72475d 100644
67841 --- a/include/linux/blktrace_api.h
67842 +++ b/include/linux/blktrace_api.h
67843 @@ -23,7 +23,7 @@ struct blk_trace {
67844 struct dentry *dir;
67845 struct dentry *dropped_file;
67846 struct dentry *msg_file;
67847 - atomic_t dropped;
67848 + atomic_unchecked_t dropped;
67849 };
67850
67851 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67852 diff --git a/include/linux/cache.h b/include/linux/cache.h
67853 index 4c57065..4307975 100644
67854 --- a/include/linux/cache.h
67855 +++ b/include/linux/cache.h
67856 @@ -16,6 +16,10 @@
67857 #define __read_mostly
67858 #endif
67859
67860 +#ifndef __read_only
67861 +#define __read_only __read_mostly
67862 +#endif
67863 +
67864 #ifndef ____cacheline_aligned
67865 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67866 #endif
67867 diff --git a/include/linux/capability.h b/include/linux/capability.h
67868 index d9a4f7f4..19f77d6 100644
67869 --- a/include/linux/capability.h
67870 +++ b/include/linux/capability.h
67871 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67872 extern bool nsown_capable(int cap);
67873 extern bool inode_capable(const struct inode *inode, int cap);
67874 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67875 +extern bool capable_nolog(int cap);
67876 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67877 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67878
67879 /* audit system wants to get cap info from files as well */
67880 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67881
67882 +extern int is_privileged_binary(const struct dentry *dentry);
67883 +
67884 #endif /* !_LINUX_CAPABILITY_H */
67885 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67886 index 8609d57..86e4d79 100644
67887 --- a/include/linux/cdrom.h
67888 +++ b/include/linux/cdrom.h
67889 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67890
67891 /* driver specifications */
67892 const int capability; /* capability flags */
67893 - int n_minors; /* number of active minor devices */
67894 /* handle uniform packets for scsi type devices (scsi,atapi) */
67895 int (*generic_packet) (struct cdrom_device_info *,
67896 struct packet_command *);
67897 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67898 index 42e55de..1cd0e66 100644
67899 --- a/include/linux/cleancache.h
67900 +++ b/include/linux/cleancache.h
67901 @@ -31,7 +31,7 @@ struct cleancache_ops {
67902 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67903 void (*invalidate_inode)(int, struct cleancache_filekey);
67904 void (*invalidate_fs)(int);
67905 -};
67906 +} __no_const;
67907
67908 extern struct cleancache_ops
67909 cleancache_register_ops(struct cleancache_ops *ops);
67910 diff --git a/include/linux/compat.h b/include/linux/compat.h
67911 index dec7e2d..45db13f 100644
67912 --- a/include/linux/compat.h
67913 +++ b/include/linux/compat.h
67914 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67915 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67916 int version, void __user *uptr);
67917 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67918 - void __user *uptr);
67919 + void __user *uptr) __intentional_overflow(0);
67920 #else
67921 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67922 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67923 compat_ssize_t msgsz, int msgflg);
67924 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67925 compat_ssize_t msgsz, long msgtyp, int msgflg);
67926 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67927 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67928 #endif
67929 long compat_sys_msgctl(int first, int second, void __user *uptr);
67930 long compat_sys_shmctl(int first, int second, void __user *uptr);
67931 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67932 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67933 compat_ulong_t addr, compat_ulong_t data);
67934 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67935 - compat_long_t addr, compat_long_t data);
67936 + compat_ulong_t addr, compat_ulong_t data);
67937
67938 /*
67939 * epoll (fs/eventpoll.c) compat bits follow ...
67940 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67941 index 662fd1b..e801992 100644
67942 --- a/include/linux/compiler-gcc4.h
67943 +++ b/include/linux/compiler-gcc4.h
67944 @@ -34,6 +34,21 @@
67945 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67946
67947 #if __GNUC_MINOR__ >= 5
67948 +
67949 +#ifdef CONSTIFY_PLUGIN
67950 +#define __no_const __attribute__((no_const))
67951 +#define __do_const __attribute__((do_const))
67952 +#endif
67953 +
67954 +#ifdef SIZE_OVERFLOW_PLUGIN
67955 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67956 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67957 +#endif
67958 +
67959 +#ifdef LATENT_ENTROPY_PLUGIN
67960 +#define __latent_entropy __attribute__((latent_entropy))
67961 +#endif
67962 +
67963 /*
67964 * Mark a position in code as unreachable. This can be used to
67965 * suppress control flow warnings after asm blocks that transfer
67966 @@ -49,6 +64,11 @@
67967 #define __noclone __attribute__((__noclone__))
67968
67969 #endif
67970 +
67971 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67972 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67973 +#define __bos0(ptr) __bos((ptr), 0)
67974 +#define __bos1(ptr) __bos((ptr), 1)
67975 #endif
67976
67977 #if __GNUC_MINOR__ >= 6
67978 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67979 index dd852b7..1ad5fba 100644
67980 --- a/include/linux/compiler.h
67981 +++ b/include/linux/compiler.h
67982 @@ -5,11 +5,14 @@
67983
67984 #ifdef __CHECKER__
67985 # define __user __attribute__((noderef, address_space(1)))
67986 +# define __force_user __force __user
67987 # define __kernel __attribute__((address_space(0)))
67988 +# define __force_kernel __force __kernel
67989 # define __safe __attribute__((safe))
67990 # define __force __attribute__((force))
67991 # define __nocast __attribute__((nocast))
67992 # define __iomem __attribute__((noderef, address_space(2)))
67993 +# define __force_iomem __force __iomem
67994 # define __must_hold(x) __attribute__((context(x,1,1)))
67995 # define __acquires(x) __attribute__((context(x,0,1)))
67996 # define __releases(x) __attribute__((context(x,1,0)))
67997 @@ -17,20 +20,37 @@
67998 # define __release(x) __context__(x,-1)
67999 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68000 # define __percpu __attribute__((noderef, address_space(3)))
68001 +# define __force_percpu __force __percpu
68002 #ifdef CONFIG_SPARSE_RCU_POINTER
68003 # define __rcu __attribute__((noderef, address_space(4)))
68004 +# define __force_rcu __force __rcu
68005 #else
68006 # define __rcu
68007 +# define __force_rcu
68008 #endif
68009 extern void __chk_user_ptr(const volatile void __user *);
68010 extern void __chk_io_ptr(const volatile void __iomem *);
68011 #else
68012 -# define __user
68013 -# define __kernel
68014 +# ifdef CHECKER_PLUGIN
68015 +//# define __user
68016 +//# define __force_user
68017 +//# define __kernel
68018 +//# define __force_kernel
68019 +# else
68020 +# ifdef STRUCTLEAK_PLUGIN
68021 +# define __user __attribute__((user))
68022 +# else
68023 +# define __user
68024 +# endif
68025 +# define __force_user
68026 +# define __kernel
68027 +# define __force_kernel
68028 +# endif
68029 # define __safe
68030 # define __force
68031 # define __nocast
68032 # define __iomem
68033 +# define __force_iomem
68034 # define __chk_user_ptr(x) (void)0
68035 # define __chk_io_ptr(x) (void)0
68036 # define __builtin_warning(x, y...) (1)
68037 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68038 # define __release(x) (void)0
68039 # define __cond_lock(x,c) (c)
68040 # define __percpu
68041 +# define __force_percpu
68042 # define __rcu
68043 +# define __force_rcu
68044 #endif
68045
68046 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68047 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68048 # define __attribute_const__ /* unimplemented */
68049 #endif
68050
68051 +#ifndef __no_const
68052 +# define __no_const
68053 +#endif
68054 +
68055 +#ifndef __do_const
68056 +# define __do_const
68057 +#endif
68058 +
68059 +#ifndef __size_overflow
68060 +# define __size_overflow(...)
68061 +#endif
68062 +
68063 +#ifndef __intentional_overflow
68064 +# define __intentional_overflow(...)
68065 +#endif
68066 +
68067 +#ifndef __latent_entropy
68068 +# define __latent_entropy
68069 +#endif
68070 +
68071 /*
68072 * Tell gcc if a function is cold. The compiler will assume any path
68073 * directly leading to the call is unlikely.
68074 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68075 #define __cold
68076 #endif
68077
68078 +#ifndef __alloc_size
68079 +#define __alloc_size(...)
68080 +#endif
68081 +
68082 +#ifndef __bos
68083 +#define __bos(ptr, arg)
68084 +#endif
68085 +
68086 +#ifndef __bos0
68087 +#define __bos0(ptr)
68088 +#endif
68089 +
68090 +#ifndef __bos1
68091 +#define __bos1(ptr)
68092 +#endif
68093 +
68094 /* Simple shorthand for a section definition */
68095 #ifndef __section
68096 # define __section(S) __attribute__ ((__section__(#S)))
68097 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68098 * use is to mediate communication between process-level code and irq/NMI
68099 * handlers, all running on the same CPU.
68100 */
68101 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68102 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68103 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68104
68105 #endif /* __LINUX_COMPILER_H */
68106 diff --git a/include/linux/completion.h b/include/linux/completion.h
68107 index 51494e6..0fd1b61 100644
68108 --- a/include/linux/completion.h
68109 +++ b/include/linux/completion.h
68110 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68111
68112 extern void wait_for_completion(struct completion *);
68113 extern int wait_for_completion_interruptible(struct completion *x);
68114 -extern int wait_for_completion_killable(struct completion *x);
68115 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68116 extern unsigned long wait_for_completion_timeout(struct completion *x,
68117 unsigned long timeout);
68118 extern long wait_for_completion_interruptible_timeout(
68119 - struct completion *x, unsigned long timeout);
68120 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68121 extern long wait_for_completion_killable_timeout(
68122 - struct completion *x, unsigned long timeout);
68123 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68124 extern bool try_wait_for_completion(struct completion *x);
68125 extern bool completion_done(struct completion *x);
68126
68127 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68128 index 34025df..d94bbbc 100644
68129 --- a/include/linux/configfs.h
68130 +++ b/include/linux/configfs.h
68131 @@ -125,7 +125,7 @@ struct configfs_attribute {
68132 const char *ca_name;
68133 struct module *ca_owner;
68134 umode_t ca_mode;
68135 -};
68136 +} __do_const;
68137
68138 /*
68139 * Users often need to create attribute structures for their configurable
68140 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68141 index ce7a074..01ab8ac 100644
68142 --- a/include/linux/cpu.h
68143 +++ b/include/linux/cpu.h
68144 @@ -115,7 +115,7 @@ enum {
68145 /* Need to know about CPUs going up/down? */
68146 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68147 #define cpu_notifier(fn, pri) { \
68148 - static struct notifier_block fn##_nb __cpuinitdata = \
68149 + static struct notifier_block fn##_nb = \
68150 { .notifier_call = fn, .priority = pri }; \
68151 register_cpu_notifier(&fn##_nb); \
68152 }
68153 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68154 index a55b88e..fba90c5 100644
68155 --- a/include/linux/cpufreq.h
68156 +++ b/include/linux/cpufreq.h
68157 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68158 int (*suspend) (struct cpufreq_policy *policy);
68159 int (*resume) (struct cpufreq_policy *policy);
68160 struct freq_attr **attr;
68161 -};
68162 +} __do_const;
68163
68164 /* flags */
68165
68166 @@ -299,6 +299,7 @@ struct global_attr {
68167 ssize_t (*store)(struct kobject *a, struct attribute *b,
68168 const char *c, size_t count);
68169 };
68170 +typedef struct global_attr __no_const global_attr_no_const;
68171
68172 #define define_one_global_ro(_name) \
68173 static struct global_attr _name = \
68174 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68175 index 24cd1037..20a63aae 100644
68176 --- a/include/linux/cpuidle.h
68177 +++ b/include/linux/cpuidle.h
68178 @@ -54,7 +54,8 @@ struct cpuidle_state {
68179 int index);
68180
68181 int (*enter_dead) (struct cpuidle_device *dev, int index);
68182 -};
68183 +} __do_const;
68184 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68185
68186 /* Idle State Flags */
68187 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68188 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68189 void (*reflect) (struct cpuidle_device *dev, int index);
68190
68191 struct module *owner;
68192 -};
68193 +} __do_const;
68194
68195 #ifdef CONFIG_CPU_IDLE
68196
68197 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68198 index 0325602..5e9feff 100644
68199 --- a/include/linux/cpumask.h
68200 +++ b/include/linux/cpumask.h
68201 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68202 }
68203
68204 /* Valid inputs for n are -1 and 0. */
68205 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68206 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68207 {
68208 return n+1;
68209 }
68210
68211 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68212 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68213 {
68214 return n+1;
68215 }
68216
68217 -static inline unsigned int cpumask_next_and(int n,
68218 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68219 const struct cpumask *srcp,
68220 const struct cpumask *andp)
68221 {
68222 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68223 *
68224 * Returns >= nr_cpu_ids if no further cpus set.
68225 */
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 /* -1 is a legal arg here. */
68230 if (n != -1)
68231 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68232 *
68233 * Returns >= nr_cpu_ids if no further cpus unset.
68234 */
68235 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68236 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68237 {
68238 /* -1 is a legal arg here. */
68239 if (n != -1)
68240 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68241 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68242 }
68243
68244 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68245 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68246 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68247
68248 /**
68249 diff --git a/include/linux/cred.h b/include/linux/cred.h
68250 index 04421e8..6bce4ef 100644
68251 --- a/include/linux/cred.h
68252 +++ b/include/linux/cred.h
68253 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68254 static inline void validate_process_creds(void)
68255 {
68256 }
68257 +static inline void validate_task_creds(struct task_struct *task)
68258 +{
68259 +}
68260 #endif
68261
68262 /**
68263 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68264 index b92eadf..b4ecdc1 100644
68265 --- a/include/linux/crypto.h
68266 +++ b/include/linux/crypto.h
68267 @@ -373,7 +373,7 @@ struct cipher_tfm {
68268 const u8 *key, unsigned int keylen);
68269 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68270 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68271 -};
68272 +} __no_const;
68273
68274 struct hash_tfm {
68275 int (*init)(struct hash_desc *desc);
68276 @@ -394,13 +394,13 @@ struct compress_tfm {
68277 int (*cot_decompress)(struct crypto_tfm *tfm,
68278 const u8 *src, unsigned int slen,
68279 u8 *dst, unsigned int *dlen);
68280 -};
68281 +} __no_const;
68282
68283 struct rng_tfm {
68284 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68285 unsigned int dlen);
68286 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68287 -};
68288 +} __no_const;
68289
68290 #define crt_ablkcipher crt_u.ablkcipher
68291 #define crt_aead crt_u.aead
68292 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68293 index 8acfe31..6ffccd63 100644
68294 --- a/include/linux/ctype.h
68295 +++ b/include/linux/ctype.h
68296 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68297 * Fast implementation of tolower() for internal usage. Do not use in your
68298 * code.
68299 */
68300 -static inline char _tolower(const char c)
68301 +static inline unsigned char _tolower(const unsigned char c)
68302 {
68303 return c | 0x20;
68304 }
68305 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68306 index 7925bf0..d5143d2 100644
68307 --- a/include/linux/decompress/mm.h
68308 +++ b/include/linux/decompress/mm.h
68309 @@ -77,7 +77,7 @@ static void free(void *where)
68310 * warnings when not needed (indeed large_malloc / large_free are not
68311 * needed by inflate */
68312
68313 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68314 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68315 #define free(a) kfree(a)
68316
68317 #define large_malloc(a) vmalloc(a)
68318 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68319 index e83ef39..33e0eb3 100644
68320 --- a/include/linux/devfreq.h
68321 +++ b/include/linux/devfreq.h
68322 @@ -114,7 +114,7 @@ struct devfreq_governor {
68323 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68324 int (*event_handler)(struct devfreq *devfreq,
68325 unsigned int event, void *data);
68326 -};
68327 +} __do_const;
68328
68329 /**
68330 * struct devfreq - Device devfreq structure
68331 diff --git a/include/linux/device.h b/include/linux/device.h
68332 index 43dcda9..7a1fb65 100644
68333 --- a/include/linux/device.h
68334 +++ b/include/linux/device.h
68335 @@ -294,7 +294,7 @@ struct subsys_interface {
68336 struct list_head node;
68337 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68338 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68339 -};
68340 +} __do_const;
68341
68342 int subsys_interface_register(struct subsys_interface *sif);
68343 void subsys_interface_unregister(struct subsys_interface *sif);
68344 @@ -474,7 +474,7 @@ struct device_type {
68345 void (*release)(struct device *dev);
68346
68347 const struct dev_pm_ops *pm;
68348 -};
68349 +} __do_const;
68350
68351 /* interface for exporting device attributes */
68352 struct device_attribute {
68353 @@ -484,11 +484,12 @@ struct device_attribute {
68354 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68355 const char *buf, size_t count);
68356 };
68357 +typedef struct device_attribute __no_const device_attribute_no_const;
68358
68359 struct dev_ext_attribute {
68360 struct device_attribute attr;
68361 void *var;
68362 -};
68363 +} __do_const;
68364
68365 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68366 char *buf);
68367 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68368 index 94af418..b1ca7a2 100644
68369 --- a/include/linux/dma-mapping.h
68370 +++ b/include/linux/dma-mapping.h
68371 @@ -54,7 +54,7 @@ struct dma_map_ops {
68372 u64 (*get_required_mask)(struct device *dev);
68373 #endif
68374 int is_phys;
68375 -};
68376 +} __do_const;
68377
68378 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68379
68380 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68381 index d3201e4..8281e63 100644
68382 --- a/include/linux/dmaengine.h
68383 +++ b/include/linux/dmaengine.h
68384 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68385 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68386 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68387
68388 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68389 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68390 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68391 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68392 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68393 struct dma_pinned_list *pinned_list, struct page *page,
68394 unsigned int offset, size_t len);
68395
68396 diff --git a/include/linux/efi.h b/include/linux/efi.h
68397 index 7a9498a..155713d 100644
68398 --- a/include/linux/efi.h
68399 +++ b/include/linux/efi.h
68400 @@ -733,6 +733,7 @@ struct efivar_operations {
68401 efi_set_variable_t *set_variable;
68402 efi_query_variable_info_t *query_variable_info;
68403 };
68404 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68405
68406 struct efivars {
68407 /*
68408 diff --git a/include/linux/elf.h b/include/linux/elf.h
68409 index 8c9048e..16a4665 100644
68410 --- a/include/linux/elf.h
68411 +++ b/include/linux/elf.h
68412 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68413 #define elf_note elf32_note
68414 #define elf_addr_t Elf32_Off
68415 #define Elf_Half Elf32_Half
68416 +#define elf_dyn Elf32_Dyn
68417
68418 #else
68419
68420 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68421 #define elf_note elf64_note
68422 #define elf_addr_t Elf64_Off
68423 #define Elf_Half Elf64_Half
68424 +#define elf_dyn Elf64_Dyn
68425
68426 #endif
68427
68428 diff --git a/include/linux/err.h b/include/linux/err.h
68429 index f2edce2..cc2082c 100644
68430 --- a/include/linux/err.h
68431 +++ b/include/linux/err.h
68432 @@ -19,12 +19,12 @@
68433
68434 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68435
68436 -static inline void * __must_check ERR_PTR(long error)
68437 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68438 {
68439 return (void *) error;
68440 }
68441
68442 -static inline long __must_check PTR_ERR(const void *ptr)
68443 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68444 {
68445 return (long) ptr;
68446 }
68447 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68448 index fcb51c8..bdafcf6 100644
68449 --- a/include/linux/extcon.h
68450 +++ b/include/linux/extcon.h
68451 @@ -134,7 +134,7 @@ struct extcon_dev {
68452 /* /sys/class/extcon/.../mutually_exclusive/... */
68453 struct attribute_group attr_g_muex;
68454 struct attribute **attrs_muex;
68455 - struct device_attribute *d_attrs_muex;
68456 + device_attribute_no_const *d_attrs_muex;
68457 };
68458
68459 /**
68460 diff --git a/include/linux/fb.h b/include/linux/fb.h
68461 index c7a9571..02eeffe 100644
68462 --- a/include/linux/fb.h
68463 +++ b/include/linux/fb.h
68464 @@ -302,7 +302,7 @@ struct fb_ops {
68465 /* called at KDB enter and leave time to prepare the console */
68466 int (*fb_debug_enter)(struct fb_info *info);
68467 int (*fb_debug_leave)(struct fb_info *info);
68468 -};
68469 +} __do_const;
68470
68471 #ifdef CONFIG_FB_TILEBLITTING
68472 #define FB_TILE_CURSOR_NONE 0
68473 diff --git a/include/linux/filter.h b/include/linux/filter.h
68474 index c45eabc..baa0be5 100644
68475 --- a/include/linux/filter.h
68476 +++ b/include/linux/filter.h
68477 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68478
68479 struct sk_buff;
68480 struct sock;
68481 +struct bpf_jit_work;
68482
68483 struct sk_filter
68484 {
68485 @@ -27,6 +28,9 @@ struct sk_filter
68486 unsigned int len; /* Number of filter blocks */
68487 unsigned int (*bpf_func)(const struct sk_buff *skb,
68488 const struct sock_filter *filter);
68489 +#ifdef CONFIG_BPF_JIT
68490 + struct bpf_jit_work *work;
68491 +#endif
68492 struct rcu_head rcu;
68493 struct sock_filter insns[0];
68494 };
68495 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68496 index 3044254..9767f41 100644
68497 --- a/include/linux/frontswap.h
68498 +++ b/include/linux/frontswap.h
68499 @@ -11,7 +11,7 @@ struct frontswap_ops {
68500 int (*load)(unsigned, pgoff_t, struct page *);
68501 void (*invalidate_page)(unsigned, pgoff_t);
68502 void (*invalidate_area)(unsigned);
68503 -};
68504 +} __no_const;
68505
68506 extern bool frontswap_enabled;
68507 extern struct frontswap_ops
68508 diff --git a/include/linux/fs.h b/include/linux/fs.h
68509 index 7617ee0..b575199 100644
68510 --- a/include/linux/fs.h
68511 +++ b/include/linux/fs.h
68512 @@ -1541,7 +1541,8 @@ struct file_operations {
68513 long (*fallocate)(struct file *file, int mode, loff_t offset,
68514 loff_t len);
68515 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68516 -};
68517 +} __do_const;
68518 +typedef struct file_operations __no_const file_operations_no_const;
68519
68520 struct inode_operations {
68521 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68522 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68523 inode->i_flags |= S_NOSEC;
68524 }
68525
68526 +static inline bool is_sidechannel_device(const struct inode *inode)
68527 +{
68528 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68529 + umode_t mode = inode->i_mode;
68530 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68531 +#else
68532 + return false;
68533 +#endif
68534 +}
68535 +
68536 #endif /* _LINUX_FS_H */
68537 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68538 index 324f931..f292b65 100644
68539 --- a/include/linux/fs_struct.h
68540 +++ b/include/linux/fs_struct.h
68541 @@ -6,7 +6,7 @@
68542 #include <linux/seqlock.h>
68543
68544 struct fs_struct {
68545 - int users;
68546 + atomic_t users;
68547 spinlock_t lock;
68548 seqcount_t seq;
68549 int umask;
68550 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68551 index 5dfa0aa..6acf322 100644
68552 --- a/include/linux/fscache-cache.h
68553 +++ b/include/linux/fscache-cache.h
68554 @@ -112,7 +112,7 @@ struct fscache_operation {
68555 fscache_operation_release_t release;
68556 };
68557
68558 -extern atomic_t fscache_op_debug_id;
68559 +extern atomic_unchecked_t fscache_op_debug_id;
68560 extern void fscache_op_work_func(struct work_struct *work);
68561
68562 extern void fscache_enqueue_operation(struct fscache_operation *);
68563 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68564 INIT_WORK(&op->work, fscache_op_work_func);
68565 atomic_set(&op->usage, 1);
68566 op->state = FSCACHE_OP_ST_INITIALISED;
68567 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68568 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68569 op->processor = processor;
68570 op->release = release;
68571 INIT_LIST_HEAD(&op->pend_link);
68572 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68573 index 7a08623..4c07b0f 100644
68574 --- a/include/linux/fscache.h
68575 +++ b/include/linux/fscache.h
68576 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68577 * - this is mandatory for any object that may have data
68578 */
68579 void (*now_uncached)(void *cookie_netfs_data);
68580 -};
68581 +} __do_const;
68582
68583 /*
68584 * fscache cached network filesystem type
68585 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68586 index 0fbfb46..508eb0d 100644
68587 --- a/include/linux/fsnotify.h
68588 +++ b/include/linux/fsnotify.h
68589 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68590 struct inode *inode = path->dentry->d_inode;
68591 __u32 mask = FS_ACCESS;
68592
68593 + if (is_sidechannel_device(inode))
68594 + return;
68595 +
68596 if (S_ISDIR(inode->i_mode))
68597 mask |= FS_ISDIR;
68598
68599 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68600 struct inode *inode = path->dentry->d_inode;
68601 __u32 mask = FS_MODIFY;
68602
68603 + if (is_sidechannel_device(inode))
68604 + return;
68605 +
68606 if (S_ISDIR(inode->i_mode))
68607 mask |= FS_ISDIR;
68608
68609 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68610 */
68611 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68612 {
68613 - return kstrdup(name, GFP_KERNEL);
68614 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68615 }
68616
68617 /*
68618 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68619 index a3d4895..ddd2a50 100644
68620 --- a/include/linux/ftrace_event.h
68621 +++ b/include/linux/ftrace_event.h
68622 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68623 extern int trace_add_event_call(struct ftrace_event_call *call);
68624 extern void trace_remove_event_call(struct ftrace_event_call *call);
68625
68626 -#define is_signed_type(type) (((type)(-1)) < 0)
68627 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68628
68629 int trace_set_clr_event(const char *system, const char *event, int set);
68630
68631 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68632 index 79b8bba..86b539e 100644
68633 --- a/include/linux/genhd.h
68634 +++ b/include/linux/genhd.h
68635 @@ -194,7 +194,7 @@ struct gendisk {
68636 struct kobject *slave_dir;
68637
68638 struct timer_rand_state *random;
68639 - atomic_t sync_io; /* RAID */
68640 + atomic_unchecked_t sync_io; /* RAID */
68641 struct disk_events *ev;
68642 #ifdef CONFIG_BLK_DEV_INTEGRITY
68643 struct blk_integrity *integrity;
68644 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68645 index 023bc34..b02b46a 100644
68646 --- a/include/linux/genl_magic_func.h
68647 +++ b/include/linux/genl_magic_func.h
68648 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68649 },
68650
68651 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68652 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68653 +static struct genl_ops ZZZ_genl_ops[] = {
68654 #include GENL_MAGIC_INCLUDE_FILE
68655 };
68656
68657 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68658 index 0f615eb..5c3832f 100644
68659 --- a/include/linux/gfp.h
68660 +++ b/include/linux/gfp.h
68661 @@ -35,6 +35,13 @@ struct vm_area_struct;
68662 #define ___GFP_NO_KSWAPD 0x400000u
68663 #define ___GFP_OTHER_NODE 0x800000u
68664 #define ___GFP_WRITE 0x1000000u
68665 +
68666 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68667 +#define ___GFP_USERCOPY 0x2000000u
68668 +#else
68669 +#define ___GFP_USERCOPY 0
68670 +#endif
68671 +
68672 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68673
68674 /*
68675 @@ -92,6 +99,7 @@ struct vm_area_struct;
68676 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68677 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68678 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68679 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68680
68681 /*
68682 * This may seem redundant, but it's a way of annotating false positives vs.
68683 @@ -99,7 +107,7 @@ struct vm_area_struct;
68684 */
68685 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68686
68687 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68688 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68689 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68690
68691 /* This equals 0, but use constants in case they ever change */
68692 @@ -153,6 +161,8 @@ struct vm_area_struct;
68693 /* 4GB DMA on some platforms */
68694 #define GFP_DMA32 __GFP_DMA32
68695
68696 +#define GFP_USERCOPY __GFP_USERCOPY
68697 +
68698 /* Convert GFP flags to their corresponding migrate type */
68699 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68700 {
68701 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68702 new file mode 100644
68703 index 0000000..ebe6d72
68704 --- /dev/null
68705 +++ b/include/linux/gracl.h
68706 @@ -0,0 +1,319 @@
68707 +#ifndef GR_ACL_H
68708 +#define GR_ACL_H
68709 +
68710 +#include <linux/grdefs.h>
68711 +#include <linux/resource.h>
68712 +#include <linux/capability.h>
68713 +#include <linux/dcache.h>
68714 +#include <asm/resource.h>
68715 +
68716 +/* Major status information */
68717 +
68718 +#define GR_VERSION "grsecurity 2.9.1"
68719 +#define GRSECURITY_VERSION 0x2901
68720 +
68721 +enum {
68722 + GR_SHUTDOWN = 0,
68723 + GR_ENABLE = 1,
68724 + GR_SPROLE = 2,
68725 + GR_RELOAD = 3,
68726 + GR_SEGVMOD = 4,
68727 + GR_STATUS = 5,
68728 + GR_UNSPROLE = 6,
68729 + GR_PASSSET = 7,
68730 + GR_SPROLEPAM = 8,
68731 +};
68732 +
68733 +/* Password setup definitions
68734 + * kernel/grhash.c */
68735 +enum {
68736 + GR_PW_LEN = 128,
68737 + GR_SALT_LEN = 16,
68738 + GR_SHA_LEN = 32,
68739 +};
68740 +
68741 +enum {
68742 + GR_SPROLE_LEN = 64,
68743 +};
68744 +
68745 +enum {
68746 + GR_NO_GLOB = 0,
68747 + GR_REG_GLOB,
68748 + GR_CREATE_GLOB
68749 +};
68750 +
68751 +#define GR_NLIMITS 32
68752 +
68753 +/* Begin Data Structures */
68754 +
68755 +struct sprole_pw {
68756 + unsigned char *rolename;
68757 + unsigned char salt[GR_SALT_LEN];
68758 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68759 +};
68760 +
68761 +struct name_entry {
68762 + __u32 key;
68763 + ino_t inode;
68764 + dev_t device;
68765 + char *name;
68766 + __u16 len;
68767 + __u8 deleted;
68768 + struct name_entry *prev;
68769 + struct name_entry *next;
68770 +};
68771 +
68772 +struct inodev_entry {
68773 + struct name_entry *nentry;
68774 + struct inodev_entry *prev;
68775 + struct inodev_entry *next;
68776 +};
68777 +
68778 +struct acl_role_db {
68779 + struct acl_role_label **r_hash;
68780 + __u32 r_size;
68781 +};
68782 +
68783 +struct inodev_db {
68784 + struct inodev_entry **i_hash;
68785 + __u32 i_size;
68786 +};
68787 +
68788 +struct name_db {
68789 + struct name_entry **n_hash;
68790 + __u32 n_size;
68791 +};
68792 +
68793 +struct crash_uid {
68794 + uid_t uid;
68795 + unsigned long expires;
68796 +};
68797 +
68798 +struct gr_hash_struct {
68799 + void **table;
68800 + void **nametable;
68801 + void *first;
68802 + __u32 table_size;
68803 + __u32 used_size;
68804 + int type;
68805 +};
68806 +
68807 +/* Userspace Grsecurity ACL data structures */
68808 +
68809 +struct acl_subject_label {
68810 + char *filename;
68811 + ino_t inode;
68812 + dev_t device;
68813 + __u32 mode;
68814 + kernel_cap_t cap_mask;
68815 + kernel_cap_t cap_lower;
68816 + kernel_cap_t cap_invert_audit;
68817 +
68818 + struct rlimit res[GR_NLIMITS];
68819 + __u32 resmask;
68820 +
68821 + __u8 user_trans_type;
68822 + __u8 group_trans_type;
68823 + uid_t *user_transitions;
68824 + gid_t *group_transitions;
68825 + __u16 user_trans_num;
68826 + __u16 group_trans_num;
68827 +
68828 + __u32 sock_families[2];
68829 + __u32 ip_proto[8];
68830 + __u32 ip_type;
68831 + struct acl_ip_label **ips;
68832 + __u32 ip_num;
68833 + __u32 inaddr_any_override;
68834 +
68835 + __u32 crashes;
68836 + unsigned long expires;
68837 +
68838 + struct acl_subject_label *parent_subject;
68839 + struct gr_hash_struct *hash;
68840 + struct acl_subject_label *prev;
68841 + struct acl_subject_label *next;
68842 +
68843 + struct acl_object_label **obj_hash;
68844 + __u32 obj_hash_size;
68845 + __u16 pax_flags;
68846 +};
68847 +
68848 +struct role_allowed_ip {
68849 + __u32 addr;
68850 + __u32 netmask;
68851 +
68852 + struct role_allowed_ip *prev;
68853 + struct role_allowed_ip *next;
68854 +};
68855 +
68856 +struct role_transition {
68857 + char *rolename;
68858 +
68859 + struct role_transition *prev;
68860 + struct role_transition *next;
68861 +};
68862 +
68863 +struct acl_role_label {
68864 + char *rolename;
68865 + uid_t uidgid;
68866 + __u16 roletype;
68867 +
68868 + __u16 auth_attempts;
68869 + unsigned long expires;
68870 +
68871 + struct acl_subject_label *root_label;
68872 + struct gr_hash_struct *hash;
68873 +
68874 + struct acl_role_label *prev;
68875 + struct acl_role_label *next;
68876 +
68877 + struct role_transition *transitions;
68878 + struct role_allowed_ip *allowed_ips;
68879 + uid_t *domain_children;
68880 + __u16 domain_child_num;
68881 +
68882 + umode_t umask;
68883 +
68884 + struct acl_subject_label **subj_hash;
68885 + __u32 subj_hash_size;
68886 +};
68887 +
68888 +struct user_acl_role_db {
68889 + struct acl_role_label **r_table;
68890 + __u32 num_pointers; /* Number of allocations to track */
68891 + __u32 num_roles; /* Number of roles */
68892 + __u32 num_domain_children; /* Number of domain children */
68893 + __u32 num_subjects; /* Number of subjects */
68894 + __u32 num_objects; /* Number of objects */
68895 +};
68896 +
68897 +struct acl_object_label {
68898 + char *filename;
68899 + ino_t inode;
68900 + dev_t device;
68901 + __u32 mode;
68902 +
68903 + struct acl_subject_label *nested;
68904 + struct acl_object_label *globbed;
68905 +
68906 + /* next two structures not used */
68907 +
68908 + struct acl_object_label *prev;
68909 + struct acl_object_label *next;
68910 +};
68911 +
68912 +struct acl_ip_label {
68913 + char *iface;
68914 + __u32 addr;
68915 + __u32 netmask;
68916 + __u16 low, high;
68917 + __u8 mode;
68918 + __u32 type;
68919 + __u32 proto[8];
68920 +
68921 + /* next two structures not used */
68922 +
68923 + struct acl_ip_label *prev;
68924 + struct acl_ip_label *next;
68925 +};
68926 +
68927 +struct gr_arg {
68928 + struct user_acl_role_db role_db;
68929 + unsigned char pw[GR_PW_LEN];
68930 + unsigned char salt[GR_SALT_LEN];
68931 + unsigned char sum[GR_SHA_LEN];
68932 + unsigned char sp_role[GR_SPROLE_LEN];
68933 + struct sprole_pw *sprole_pws;
68934 + dev_t segv_device;
68935 + ino_t segv_inode;
68936 + uid_t segv_uid;
68937 + __u16 num_sprole_pws;
68938 + __u16 mode;
68939 +};
68940 +
68941 +struct gr_arg_wrapper {
68942 + struct gr_arg *arg;
68943 + __u32 version;
68944 + __u32 size;
68945 +};
68946 +
68947 +struct subject_map {
68948 + struct acl_subject_label *user;
68949 + struct acl_subject_label *kernel;
68950 + struct subject_map *prev;
68951 + struct subject_map *next;
68952 +};
68953 +
68954 +struct acl_subj_map_db {
68955 + struct subject_map **s_hash;
68956 + __u32 s_size;
68957 +};
68958 +
68959 +/* End Data Structures Section */
68960 +
68961 +/* Hash functions generated by empirical testing by Brad Spengler
68962 + Makes good use of the low bits of the inode. Generally 0-1 times
68963 + in loop for successful match. 0-3 for unsuccessful match.
68964 + Shift/add algorithm with modulus of table size and an XOR*/
68965 +
68966 +static __inline__ unsigned int
68967 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68968 +{
68969 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68970 +}
68971 +
68972 + static __inline__ unsigned int
68973 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68974 +{
68975 + return ((const unsigned long)userp % sz);
68976 +}
68977 +
68978 +static __inline__ unsigned int
68979 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68980 +{
68981 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68982 +}
68983 +
68984 +static __inline__ unsigned int
68985 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68986 +{
68987 + return full_name_hash((const unsigned char *)name, len) % sz;
68988 +}
68989 +
68990 +#define FOR_EACH_ROLE_START(role) \
68991 + role = role_list; \
68992 + while (role) {
68993 +
68994 +#define FOR_EACH_ROLE_END(role) \
68995 + role = role->prev; \
68996 + }
68997 +
68998 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68999 + subj = NULL; \
69000 + iter = 0; \
69001 + while (iter < role->subj_hash_size) { \
69002 + if (subj == NULL) \
69003 + subj = role->subj_hash[iter]; \
69004 + if (subj == NULL) { \
69005 + iter++; \
69006 + continue; \
69007 + }
69008 +
69009 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69010 + subj = subj->next; \
69011 + if (subj == NULL) \
69012 + iter++; \
69013 + }
69014 +
69015 +
69016 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69017 + subj = role->hash->first; \
69018 + while (subj != NULL) {
69019 +
69020 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69021 + subj = subj->next; \
69022 + }
69023 +
69024 +#endif
69025 +
69026 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69027 new file mode 100644
69028 index 0000000..323ecf2
69029 --- /dev/null
69030 +++ b/include/linux/gralloc.h
69031 @@ -0,0 +1,9 @@
69032 +#ifndef __GRALLOC_H
69033 +#define __GRALLOC_H
69034 +
69035 +void acl_free_all(void);
69036 +int acl_alloc_stack_init(unsigned long size);
69037 +void *acl_alloc(unsigned long len);
69038 +void *acl_alloc_num(unsigned long num, unsigned long len);
69039 +
69040 +#endif
69041 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69042 new file mode 100644
69043 index 0000000..be66033
69044 --- /dev/null
69045 +++ b/include/linux/grdefs.h
69046 @@ -0,0 +1,140 @@
69047 +#ifndef GRDEFS_H
69048 +#define GRDEFS_H
69049 +
69050 +/* Begin grsecurity status declarations */
69051 +
69052 +enum {
69053 + GR_READY = 0x01,
69054 + GR_STATUS_INIT = 0x00 // disabled state
69055 +};
69056 +
69057 +/* Begin ACL declarations */
69058 +
69059 +/* Role flags */
69060 +
69061 +enum {
69062 + GR_ROLE_USER = 0x0001,
69063 + GR_ROLE_GROUP = 0x0002,
69064 + GR_ROLE_DEFAULT = 0x0004,
69065 + GR_ROLE_SPECIAL = 0x0008,
69066 + GR_ROLE_AUTH = 0x0010,
69067 + GR_ROLE_NOPW = 0x0020,
69068 + GR_ROLE_GOD = 0x0040,
69069 + GR_ROLE_LEARN = 0x0080,
69070 + GR_ROLE_TPE = 0x0100,
69071 + GR_ROLE_DOMAIN = 0x0200,
69072 + GR_ROLE_PAM = 0x0400,
69073 + GR_ROLE_PERSIST = 0x0800
69074 +};
69075 +
69076 +/* ACL Subject and Object mode flags */
69077 +enum {
69078 + GR_DELETED = 0x80000000
69079 +};
69080 +
69081 +/* ACL Object-only mode flags */
69082 +enum {
69083 + GR_READ = 0x00000001,
69084 + GR_APPEND = 0x00000002,
69085 + GR_WRITE = 0x00000004,
69086 + GR_EXEC = 0x00000008,
69087 + GR_FIND = 0x00000010,
69088 + GR_INHERIT = 0x00000020,
69089 + GR_SETID = 0x00000040,
69090 + GR_CREATE = 0x00000080,
69091 + GR_DELETE = 0x00000100,
69092 + GR_LINK = 0x00000200,
69093 + GR_AUDIT_READ = 0x00000400,
69094 + GR_AUDIT_APPEND = 0x00000800,
69095 + GR_AUDIT_WRITE = 0x00001000,
69096 + GR_AUDIT_EXEC = 0x00002000,
69097 + GR_AUDIT_FIND = 0x00004000,
69098 + GR_AUDIT_INHERIT= 0x00008000,
69099 + GR_AUDIT_SETID = 0x00010000,
69100 + GR_AUDIT_CREATE = 0x00020000,
69101 + GR_AUDIT_DELETE = 0x00040000,
69102 + GR_AUDIT_LINK = 0x00080000,
69103 + GR_PTRACERD = 0x00100000,
69104 + GR_NOPTRACE = 0x00200000,
69105 + GR_SUPPRESS = 0x00400000,
69106 + GR_NOLEARN = 0x00800000,
69107 + GR_INIT_TRANSFER= 0x01000000
69108 +};
69109 +
69110 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69111 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69112 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69113 +
69114 +/* ACL subject-only mode flags */
69115 +enum {
69116 + GR_KILL = 0x00000001,
69117 + GR_VIEW = 0x00000002,
69118 + GR_PROTECTED = 0x00000004,
69119 + GR_LEARN = 0x00000008,
69120 + GR_OVERRIDE = 0x00000010,
69121 + /* just a placeholder, this mode is only used in userspace */
69122 + GR_DUMMY = 0x00000020,
69123 + GR_PROTSHM = 0x00000040,
69124 + GR_KILLPROC = 0x00000080,
69125 + GR_KILLIPPROC = 0x00000100,
69126 + /* just a placeholder, this mode is only used in userspace */
69127 + GR_NOTROJAN = 0x00000200,
69128 + GR_PROTPROCFD = 0x00000400,
69129 + GR_PROCACCT = 0x00000800,
69130 + GR_RELAXPTRACE = 0x00001000,
69131 + //GR_NESTED = 0x00002000,
69132 + GR_INHERITLEARN = 0x00004000,
69133 + GR_PROCFIND = 0x00008000,
69134 + GR_POVERRIDE = 0x00010000,
69135 + GR_KERNELAUTH = 0x00020000,
69136 + GR_ATSECURE = 0x00040000,
69137 + GR_SHMEXEC = 0x00080000
69138 +};
69139 +
69140 +enum {
69141 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69142 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69143 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69144 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69145 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69146 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69147 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69148 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69149 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69150 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69151 +};
69152 +
69153 +enum {
69154 + GR_ID_USER = 0x01,
69155 + GR_ID_GROUP = 0x02,
69156 +};
69157 +
69158 +enum {
69159 + GR_ID_ALLOW = 0x01,
69160 + GR_ID_DENY = 0x02,
69161 +};
69162 +
69163 +#define GR_CRASH_RES 31
69164 +#define GR_UIDTABLE_MAX 500
69165 +
69166 +/* begin resource learning section */
69167 +enum {
69168 + GR_RLIM_CPU_BUMP = 60,
69169 + GR_RLIM_FSIZE_BUMP = 50000,
69170 + GR_RLIM_DATA_BUMP = 10000,
69171 + GR_RLIM_STACK_BUMP = 1000,
69172 + GR_RLIM_CORE_BUMP = 10000,
69173 + GR_RLIM_RSS_BUMP = 500000,
69174 + GR_RLIM_NPROC_BUMP = 1,
69175 + GR_RLIM_NOFILE_BUMP = 5,
69176 + GR_RLIM_MEMLOCK_BUMP = 50000,
69177 + GR_RLIM_AS_BUMP = 500000,
69178 + GR_RLIM_LOCKS_BUMP = 2,
69179 + GR_RLIM_SIGPENDING_BUMP = 5,
69180 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69181 + GR_RLIM_NICE_BUMP = 1,
69182 + GR_RLIM_RTPRIO_BUMP = 1,
69183 + GR_RLIM_RTTIME_BUMP = 1000000
69184 +};
69185 +
69186 +#endif
69187 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69188 new file mode 100644
69189 index 0000000..9bb6662
69190 --- /dev/null
69191 +++ b/include/linux/grinternal.h
69192 @@ -0,0 +1,215 @@
69193 +#ifndef __GRINTERNAL_H
69194 +#define __GRINTERNAL_H
69195 +
69196 +#ifdef CONFIG_GRKERNSEC
69197 +
69198 +#include <linux/fs.h>
69199 +#include <linux/mnt_namespace.h>
69200 +#include <linux/nsproxy.h>
69201 +#include <linux/gracl.h>
69202 +#include <linux/grdefs.h>
69203 +#include <linux/grmsg.h>
69204 +
69205 +void gr_add_learn_entry(const char *fmt, ...)
69206 + __attribute__ ((format (printf, 1, 2)));
69207 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69208 + const struct vfsmount *mnt);
69209 +__u32 gr_check_create(const struct dentry *new_dentry,
69210 + const struct dentry *parent,
69211 + const struct vfsmount *mnt, const __u32 mode);
69212 +int gr_check_protected_task(const struct task_struct *task);
69213 +__u32 to_gr_audit(const __u32 reqmode);
69214 +int gr_set_acls(const int type);
69215 +int gr_apply_subject_to_task(struct task_struct *task);
69216 +int gr_acl_is_enabled(void);
69217 +char gr_roletype_to_char(void);
69218 +
69219 +void gr_handle_alertkill(struct task_struct *task);
69220 +char *gr_to_filename(const struct dentry *dentry,
69221 + const struct vfsmount *mnt);
69222 +char *gr_to_filename1(const struct dentry *dentry,
69223 + const struct vfsmount *mnt);
69224 +char *gr_to_filename2(const struct dentry *dentry,
69225 + const struct vfsmount *mnt);
69226 +char *gr_to_filename3(const struct dentry *dentry,
69227 + const struct vfsmount *mnt);
69228 +
69229 +extern int grsec_enable_ptrace_readexec;
69230 +extern int grsec_enable_harden_ptrace;
69231 +extern int grsec_enable_link;
69232 +extern int grsec_enable_fifo;
69233 +extern int grsec_enable_execve;
69234 +extern int grsec_enable_shm;
69235 +extern int grsec_enable_execlog;
69236 +extern int grsec_enable_signal;
69237 +extern int grsec_enable_audit_ptrace;
69238 +extern int grsec_enable_forkfail;
69239 +extern int grsec_enable_time;
69240 +extern int grsec_enable_rofs;
69241 +extern int grsec_enable_chroot_shmat;
69242 +extern int grsec_enable_chroot_mount;
69243 +extern int grsec_enable_chroot_double;
69244 +extern int grsec_enable_chroot_pivot;
69245 +extern int grsec_enable_chroot_chdir;
69246 +extern int grsec_enable_chroot_chmod;
69247 +extern int grsec_enable_chroot_mknod;
69248 +extern int grsec_enable_chroot_fchdir;
69249 +extern int grsec_enable_chroot_nice;
69250 +extern int grsec_enable_chroot_execlog;
69251 +extern int grsec_enable_chroot_caps;
69252 +extern int grsec_enable_chroot_sysctl;
69253 +extern int grsec_enable_chroot_unix;
69254 +extern int grsec_enable_symlinkown;
69255 +extern kgid_t grsec_symlinkown_gid;
69256 +extern int grsec_enable_tpe;
69257 +extern kgid_t grsec_tpe_gid;
69258 +extern int grsec_enable_tpe_all;
69259 +extern int grsec_enable_tpe_invert;
69260 +extern int grsec_enable_socket_all;
69261 +extern kgid_t grsec_socket_all_gid;
69262 +extern int grsec_enable_socket_client;
69263 +extern kgid_t grsec_socket_client_gid;
69264 +extern int grsec_enable_socket_server;
69265 +extern kgid_t grsec_socket_server_gid;
69266 +extern kgid_t grsec_audit_gid;
69267 +extern int grsec_enable_group;
69268 +extern int grsec_enable_audit_textrel;
69269 +extern int grsec_enable_log_rwxmaps;
69270 +extern int grsec_enable_mount;
69271 +extern int grsec_enable_chdir;
69272 +extern int grsec_resource_logging;
69273 +extern int grsec_enable_blackhole;
69274 +extern int grsec_lastack_retries;
69275 +extern int grsec_enable_brute;
69276 +extern int grsec_lock;
69277 +
69278 +extern spinlock_t grsec_alert_lock;
69279 +extern unsigned long grsec_alert_wtime;
69280 +extern unsigned long grsec_alert_fyet;
69281 +
69282 +extern spinlock_t grsec_audit_lock;
69283 +
69284 +extern rwlock_t grsec_exec_file_lock;
69285 +
69286 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69287 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69288 + (tsk)->exec_file->f_vfsmnt) : "/")
69289 +
69290 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69291 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69292 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69293 +
69294 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69295 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69296 + (tsk)->exec_file->f_vfsmnt) : "/")
69297 +
69298 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69299 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69300 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69301 +
69302 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69303 +
69304 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69305 +
69306 +#define GR_CHROOT_CAPS {{ \
69307 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69308 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69309 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69310 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69311 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69312 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69313 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69314 +
69315 +#define security_learn(normal_msg,args...) \
69316 +({ \
69317 + read_lock(&grsec_exec_file_lock); \
69318 + gr_add_learn_entry(normal_msg "\n", ## args); \
69319 + read_unlock(&grsec_exec_file_lock); \
69320 +})
69321 +
69322 +enum {
69323 + GR_DO_AUDIT,
69324 + GR_DONT_AUDIT,
69325 + /* used for non-audit messages that we shouldn't kill the task on */
69326 + GR_DONT_AUDIT_GOOD
69327 +};
69328 +
69329 +enum {
69330 + GR_TTYSNIFF,
69331 + GR_RBAC,
69332 + GR_RBAC_STR,
69333 + GR_STR_RBAC,
69334 + GR_RBAC_MODE2,
69335 + GR_RBAC_MODE3,
69336 + GR_FILENAME,
69337 + GR_SYSCTL_HIDDEN,
69338 + GR_NOARGS,
69339 + GR_ONE_INT,
69340 + GR_ONE_INT_TWO_STR,
69341 + GR_ONE_STR,
69342 + GR_STR_INT,
69343 + GR_TWO_STR_INT,
69344 + GR_TWO_INT,
69345 + GR_TWO_U64,
69346 + GR_THREE_INT,
69347 + GR_FIVE_INT_TWO_STR,
69348 + GR_TWO_STR,
69349 + GR_THREE_STR,
69350 + GR_FOUR_STR,
69351 + GR_STR_FILENAME,
69352 + GR_FILENAME_STR,
69353 + GR_FILENAME_TWO_INT,
69354 + GR_FILENAME_TWO_INT_STR,
69355 + GR_TEXTREL,
69356 + GR_PTRACE,
69357 + GR_RESOURCE,
69358 + GR_CAP,
69359 + GR_SIG,
69360 + GR_SIG2,
69361 + GR_CRASH1,
69362 + GR_CRASH2,
69363 + GR_PSACCT,
69364 + GR_RWXMAP
69365 +};
69366 +
69367 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69368 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69369 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69370 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69371 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69372 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69373 +#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)
69374 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69375 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69376 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69377 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69378 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69379 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69380 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69381 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69382 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69383 +#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)
69384 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69385 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69386 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69387 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69388 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69389 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69390 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69391 +#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)
69392 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69393 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69394 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69395 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69396 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69397 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69398 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69399 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69400 +#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)
69401 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69402 +
69403 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69404 +
69405 +#endif
69406 +
69407 +#endif
69408 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69409 new file mode 100644
69410 index 0000000..2bd4c8d
69411 --- /dev/null
69412 +++ b/include/linux/grmsg.h
69413 @@ -0,0 +1,111 @@
69414 +#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"
69415 +#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"
69416 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69417 +#define GR_STOPMOD_MSG "denied modification of module state by "
69418 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69419 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69420 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69421 +#define GR_IOPL_MSG "denied use of iopl() by "
69422 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69423 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69424 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69425 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69426 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69427 +#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"
69428 +#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"
69429 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69430 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69431 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69432 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69433 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69434 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69435 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69436 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69437 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69438 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69439 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69440 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69441 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69442 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69443 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69444 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69445 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69446 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69447 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69448 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69449 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69450 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69451 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69452 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69453 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69454 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69455 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69456 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69457 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69458 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69459 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69460 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69461 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69462 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69463 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69464 +#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"
69465 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69466 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69467 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69468 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69469 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69470 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69471 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69472 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69473 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69474 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69475 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69476 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69477 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69478 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69479 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69480 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69481 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69482 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69483 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69484 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69485 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69486 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69487 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69488 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69489 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69490 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69491 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69492 +#define GR_TIME_MSG "time set by "
69493 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69494 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69495 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69496 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69497 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69498 +#define GR_BIND_MSG "denied bind() by "
69499 +#define GR_CONNECT_MSG "denied connect() by "
69500 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69501 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69502 +#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"
69503 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69504 +#define GR_CAP_ACL_MSG "use of %s denied for "
69505 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69506 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69507 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69508 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69509 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69510 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69511 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69512 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69513 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69514 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69515 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69516 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69517 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69518 +#define GR_VM86_MSG "denied use of vm86 by "
69519 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69520 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69521 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69522 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69523 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69524 +#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 "
69525 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69526 new file mode 100644
69527 index 0000000..8da63a4
69528 --- /dev/null
69529 +++ b/include/linux/grsecurity.h
69530 @@ -0,0 +1,242 @@
69531 +#ifndef GR_SECURITY_H
69532 +#define GR_SECURITY_H
69533 +#include <linux/fs.h>
69534 +#include <linux/fs_struct.h>
69535 +#include <linux/binfmts.h>
69536 +#include <linux/gracl.h>
69537 +
69538 +/* notify of brain-dead configs */
69539 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69540 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69541 +#endif
69542 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69543 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69544 +#endif
69545 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69546 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69547 +#endif
69548 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69549 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69550 +#endif
69551 +
69552 +void gr_handle_brute_attach(unsigned long mm_flags);
69553 +void gr_handle_brute_check(void);
69554 +void gr_handle_kernel_exploit(void);
69555 +int gr_process_user_ban(void);
69556 +
69557 +char gr_roletype_to_char(void);
69558 +
69559 +int gr_acl_enable_at_secure(void);
69560 +
69561 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69562 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69563 +
69564 +void gr_del_task_from_ip_table(struct task_struct *p);
69565 +
69566 +int gr_pid_is_chrooted(struct task_struct *p);
69567 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69568 +int gr_handle_chroot_nice(void);
69569 +int gr_handle_chroot_sysctl(const int op);
69570 +int gr_handle_chroot_setpriority(struct task_struct *p,
69571 + const int niceval);
69572 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69573 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69574 + const struct vfsmount *mnt);
69575 +void gr_handle_chroot_chdir(struct path *path);
69576 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69577 + const struct vfsmount *mnt, const int mode);
69578 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69579 + const struct vfsmount *mnt, const int mode);
69580 +int gr_handle_chroot_mount(const struct dentry *dentry,
69581 + const struct vfsmount *mnt,
69582 + const char *dev_name);
69583 +int gr_handle_chroot_pivot(void);
69584 +int gr_handle_chroot_unix(const pid_t pid);
69585 +
69586 +int gr_handle_rawio(const struct inode *inode);
69587 +
69588 +void gr_handle_ioperm(void);
69589 +void gr_handle_iopl(void);
69590 +
69591 +umode_t gr_acl_umask(void);
69592 +
69593 +int gr_tpe_allow(const struct file *file);
69594 +
69595 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69596 +void gr_clear_chroot_entries(struct task_struct *task);
69597 +
69598 +void gr_log_forkfail(const int retval);
69599 +void gr_log_timechange(void);
69600 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69601 +void gr_log_chdir(const struct dentry *dentry,
69602 + const struct vfsmount *mnt);
69603 +void gr_log_chroot_exec(const struct dentry *dentry,
69604 + const struct vfsmount *mnt);
69605 +void gr_log_remount(const char *devname, const int retval);
69606 +void gr_log_unmount(const char *devname, const int retval);
69607 +void gr_log_mount(const char *from, const char *to, const int retval);
69608 +void gr_log_textrel(struct vm_area_struct *vma);
69609 +void gr_log_rwxmmap(struct file *file);
69610 +void gr_log_rwxmprotect(struct file *file);
69611 +
69612 +int gr_handle_follow_link(const struct inode *parent,
69613 + const struct inode *inode,
69614 + const struct dentry *dentry,
69615 + const struct vfsmount *mnt);
69616 +int gr_handle_fifo(const struct dentry *dentry,
69617 + const struct vfsmount *mnt,
69618 + const struct dentry *dir, const int flag,
69619 + const int acc_mode);
69620 +int gr_handle_hardlink(const struct dentry *dentry,
69621 + const struct vfsmount *mnt,
69622 + struct inode *inode,
69623 + const int mode, const struct filename *to);
69624 +
69625 +int gr_is_capable(const int cap);
69626 +int gr_is_capable_nolog(const int cap);
69627 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69628 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69629 +
69630 +void gr_copy_label(struct task_struct *tsk);
69631 +void gr_handle_crash(struct task_struct *task, const int sig);
69632 +int gr_handle_signal(const struct task_struct *p, const int sig);
69633 +int gr_check_crash_uid(const kuid_t uid);
69634 +int gr_check_protected_task(const struct task_struct *task);
69635 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69636 +int gr_acl_handle_mmap(const struct file *file,
69637 + const unsigned long prot);
69638 +int gr_acl_handle_mprotect(const struct file *file,
69639 + const unsigned long prot);
69640 +int gr_check_hidden_task(const struct task_struct *tsk);
69641 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69642 + const struct vfsmount *mnt);
69643 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69644 + const struct vfsmount *mnt);
69645 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69646 + const struct vfsmount *mnt, const int fmode);
69647 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69648 + const struct vfsmount *mnt, umode_t *mode);
69649 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69650 + const struct vfsmount *mnt);
69651 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69652 + const struct vfsmount *mnt);
69653 +int gr_handle_ptrace(struct task_struct *task, const long request);
69654 +int gr_handle_proc_ptrace(struct task_struct *task);
69655 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69656 + const struct vfsmount *mnt);
69657 +int gr_check_crash_exec(const struct file *filp);
69658 +int gr_acl_is_enabled(void);
69659 +void gr_set_kernel_label(struct task_struct *task);
69660 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69661 + const kgid_t gid);
69662 +int gr_set_proc_label(const struct dentry *dentry,
69663 + const struct vfsmount *mnt,
69664 + const int unsafe_flags);
69665 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69666 + const struct vfsmount *mnt);
69667 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69668 + const struct vfsmount *mnt, int acc_mode);
69669 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69670 + const struct dentry *p_dentry,
69671 + const struct vfsmount *p_mnt,
69672 + int open_flags, int acc_mode, const int imode);
69673 +void gr_handle_create(const struct dentry *dentry,
69674 + const struct vfsmount *mnt);
69675 +void gr_handle_proc_create(const struct dentry *dentry,
69676 + const struct inode *inode);
69677 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69678 + const struct dentry *parent_dentry,
69679 + const struct vfsmount *parent_mnt,
69680 + const int mode);
69681 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69682 + const struct dentry *parent_dentry,
69683 + const struct vfsmount *parent_mnt);
69684 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69685 + const struct vfsmount *mnt);
69686 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69687 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69688 + const struct vfsmount *mnt);
69689 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69690 + const struct dentry *parent_dentry,
69691 + const struct vfsmount *parent_mnt,
69692 + const struct filename *from);
69693 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69694 + const struct dentry *parent_dentry,
69695 + const struct vfsmount *parent_mnt,
69696 + const struct dentry *old_dentry,
69697 + const struct vfsmount *old_mnt, const struct filename *to);
69698 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69699 +int gr_acl_handle_rename(struct dentry *new_dentry,
69700 + struct dentry *parent_dentry,
69701 + const struct vfsmount *parent_mnt,
69702 + struct dentry *old_dentry,
69703 + struct inode *old_parent_inode,
69704 + struct vfsmount *old_mnt, const struct filename *newname);
69705 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69706 + struct dentry *old_dentry,
69707 + struct dentry *new_dentry,
69708 + struct vfsmount *mnt, const __u8 replace);
69709 +__u32 gr_check_link(const struct dentry *new_dentry,
69710 + const struct dentry *parent_dentry,
69711 + const struct vfsmount *parent_mnt,
69712 + const struct dentry *old_dentry,
69713 + const struct vfsmount *old_mnt);
69714 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69715 + const unsigned int namelen, const ino_t ino);
69716 +
69717 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69718 + const struct vfsmount *mnt);
69719 +void gr_acl_handle_exit(void);
69720 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69721 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69722 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69723 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69724 +void gr_audit_ptrace(struct task_struct *task);
69725 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69726 +void gr_put_exec_file(struct task_struct *task);
69727 +
69728 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69729 +
69730 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69731 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69732 + const unsigned long wanted, const int gt);
69733 +#else
69734 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69735 + const unsigned long wanted, const int gt)
69736 +{
69737 +}
69738 +#endif
69739 +
69740 +#ifdef CONFIG_GRKERNSEC_RESLOG
69741 +extern void gr_log_resource(const struct task_struct *task, const int res,
69742 + const unsigned long wanted, const int gt);
69743 +#else
69744 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69745 + const unsigned long wanted, const int gt)
69746 +{
69747 +}
69748 +#endif
69749 +
69750 +#ifdef CONFIG_GRKERNSEC
69751 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69752 +void gr_handle_vm86(void);
69753 +void gr_handle_mem_readwrite(u64 from, u64 to);
69754 +
69755 +void gr_log_badprocpid(const char *entry);
69756 +
69757 +extern int grsec_enable_dmesg;
69758 +extern int grsec_disable_privio;
69759 +
69760 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69761 +extern kgid_t grsec_proc_gid;
69762 +#endif
69763 +
69764 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69765 +extern int grsec_enable_chroot_findtask;
69766 +#endif
69767 +#ifdef CONFIG_GRKERNSEC_SETXID
69768 +extern int grsec_enable_setxid;
69769 +#endif
69770 +#endif
69771 +
69772 +#endif
69773 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69774 new file mode 100644
69775 index 0000000..e7ffaaf
69776 --- /dev/null
69777 +++ b/include/linux/grsock.h
69778 @@ -0,0 +1,19 @@
69779 +#ifndef __GRSOCK_H
69780 +#define __GRSOCK_H
69781 +
69782 +extern void gr_attach_curr_ip(const struct sock *sk);
69783 +extern int gr_handle_sock_all(const int family, const int type,
69784 + const int protocol);
69785 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69786 +extern int gr_handle_sock_server_other(const struct sock *sck);
69787 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69788 +extern int gr_search_connect(struct socket * sock,
69789 + struct sockaddr_in * addr);
69790 +extern int gr_search_bind(struct socket * sock,
69791 + struct sockaddr_in * addr);
69792 +extern int gr_search_listen(struct socket * sock);
69793 +extern int gr_search_accept(struct socket * sock);
69794 +extern int gr_search_socket(const int domain, const int type,
69795 + const int protocol);
69796 +
69797 +#endif
69798 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69799 index ef788b5..ac41b7b 100644
69800 --- a/include/linux/highmem.h
69801 +++ b/include/linux/highmem.h
69802 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69803 kunmap_atomic(kaddr);
69804 }
69805
69806 +static inline void sanitize_highpage(struct page *page)
69807 +{
69808 + void *kaddr;
69809 + unsigned long flags;
69810 +
69811 + local_irq_save(flags);
69812 + kaddr = kmap_atomic(page);
69813 + clear_page(kaddr);
69814 + kunmap_atomic(kaddr);
69815 + local_irq_restore(flags);
69816 +}
69817 +
69818 static inline void zero_user_segments(struct page *page,
69819 unsigned start1, unsigned end1,
69820 unsigned start2, unsigned end2)
69821 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69822 index 1c7b89a..7f52502 100644
69823 --- a/include/linux/hwmon-sysfs.h
69824 +++ b/include/linux/hwmon-sysfs.h
69825 @@ -25,7 +25,8 @@
69826 struct sensor_device_attribute{
69827 struct device_attribute dev_attr;
69828 int index;
69829 -};
69830 +} __do_const;
69831 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69832 #define to_sensor_dev_attr(_dev_attr) \
69833 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69834
69835 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69836 struct device_attribute dev_attr;
69837 u8 index;
69838 u8 nr;
69839 -};
69840 +} __do_const;
69841 #define to_sensor_dev_attr_2(_dev_attr) \
69842 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69843
69844 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69845 index d0c4db7..61b3577 100644
69846 --- a/include/linux/i2c.h
69847 +++ b/include/linux/i2c.h
69848 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69849 /* To determine what the adapter supports */
69850 u32 (*functionality) (struct i2c_adapter *);
69851 };
69852 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69853
69854 /*
69855 * i2c_adapter is the structure used to identify a physical i2c bus along
69856 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69857 index d23c3c2..eb63c81 100644
69858 --- a/include/linux/i2o.h
69859 +++ b/include/linux/i2o.h
69860 @@ -565,7 +565,7 @@ struct i2o_controller {
69861 struct i2o_device *exec; /* Executive */
69862 #if BITS_PER_LONG == 64
69863 spinlock_t context_list_lock; /* lock for context_list */
69864 - atomic_t context_list_counter; /* needed for unique contexts */
69865 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69866 struct list_head context_list; /* list of context id's
69867 and pointers */
69868 #endif
69869 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69870 index aff7ad8..3942bbd 100644
69871 --- a/include/linux/if_pppox.h
69872 +++ b/include/linux/if_pppox.h
69873 @@ -76,7 +76,7 @@ struct pppox_proto {
69874 int (*ioctl)(struct socket *sock, unsigned int cmd,
69875 unsigned long arg);
69876 struct module *owner;
69877 -};
69878 +} __do_const;
69879
69880 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69881 extern void unregister_pppox_proto(int proto_num);
69882 diff --git a/include/linux/init.h b/include/linux/init.h
69883 index 10ed4f4..8e8490d 100644
69884 --- a/include/linux/init.h
69885 +++ b/include/linux/init.h
69886 @@ -39,9 +39,36 @@
69887 * Also note, that this data cannot be "const".
69888 */
69889
69890 +#ifdef MODULE
69891 +#define add_init_latent_entropy
69892 +#define add_devinit_latent_entropy
69893 +#define add_cpuinit_latent_entropy
69894 +#define add_meminit_latent_entropy
69895 +#else
69896 +#define add_init_latent_entropy __latent_entropy
69897 +
69898 +#ifdef CONFIG_HOTPLUG
69899 +#define add_devinit_latent_entropy
69900 +#else
69901 +#define add_devinit_latent_entropy __latent_entropy
69902 +#endif
69903 +
69904 +#ifdef CONFIG_HOTPLUG_CPU
69905 +#define add_cpuinit_latent_entropy
69906 +#else
69907 +#define add_cpuinit_latent_entropy __latent_entropy
69908 +#endif
69909 +
69910 +#ifdef CONFIG_MEMORY_HOTPLUG
69911 +#define add_meminit_latent_entropy
69912 +#else
69913 +#define add_meminit_latent_entropy __latent_entropy
69914 +#endif
69915 +#endif
69916 +
69917 /* These are for everybody (although not all archs will actually
69918 discard it in modules) */
69919 -#define __init __section(.init.text) __cold notrace
69920 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69921 #define __initdata __section(.init.data)
69922 #define __initconst __constsection(.init.rodata)
69923 #define __exitdata __section(.exit.data)
69924 @@ -94,7 +121,7 @@
69925 #define __exit __section(.exit.text) __exitused __cold notrace
69926
69927 /* Used for HOTPLUG_CPU */
69928 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69929 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69930 #define __cpuinitdata __section(.cpuinit.data)
69931 #define __cpuinitconst __constsection(.cpuinit.rodata)
69932 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69933 @@ -102,7 +129,7 @@
69934 #define __cpuexitconst __constsection(.cpuexit.rodata)
69935
69936 /* Used for MEMORY_HOTPLUG */
69937 -#define __meminit __section(.meminit.text) __cold notrace
69938 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69939 #define __meminitdata __section(.meminit.data)
69940 #define __meminitconst __constsection(.meminit.rodata)
69941 #define __memexit __section(.memexit.text) __exitused __cold notrace
69942 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69943 index 6d087c5..401cab8 100644
69944 --- a/include/linux/init_task.h
69945 +++ b/include/linux/init_task.h
69946 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69947
69948 #define INIT_TASK_COMM "swapper"
69949
69950 +#ifdef CONFIG_X86
69951 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69952 +#else
69953 +#define INIT_TASK_THREAD_INFO
69954 +#endif
69955 +
69956 /*
69957 * INIT_TASK is used to set up the first task table, touch at
69958 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69959 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69960 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69961 .comm = INIT_TASK_COMM, \
69962 .thread = INIT_THREAD, \
69963 + INIT_TASK_THREAD_INFO \
69964 .fs = &init_fs, \
69965 .files = &init_files, \
69966 .signal = &init_signals, \
69967 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69968 index 5fa5afe..ac55b25 100644
69969 --- a/include/linux/interrupt.h
69970 +++ b/include/linux/interrupt.h
69971 @@ -430,7 +430,7 @@ enum
69972 /* map softirq index to softirq name. update 'softirq_to_name' in
69973 * kernel/softirq.c when adding a new softirq.
69974 */
69975 -extern char *softirq_to_name[NR_SOFTIRQS];
69976 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69977
69978 /* softirq mask and active fields moved to irq_cpustat_t in
69979 * asm/hardirq.h to get better cache usage. KAO
69980 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69981
69982 struct softirq_action
69983 {
69984 - void (*action)(struct softirq_action *);
69985 -};
69986 + void (*action)(void);
69987 +} __no_const;
69988
69989 asmlinkage void do_softirq(void);
69990 asmlinkage void __do_softirq(void);
69991 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69992 +extern void open_softirq(int nr, void (*action)(void));
69993 extern void softirq_init(void);
69994 extern void __raise_softirq_irqoff(unsigned int nr);
69995
69996 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69997 index f3b99e1..9b73cee 100644
69998 --- a/include/linux/iommu.h
69999 +++ b/include/linux/iommu.h
70000 @@ -101,7 +101,7 @@ struct iommu_ops {
70001 int (*domain_set_attr)(struct iommu_domain *domain,
70002 enum iommu_attr attr, void *data);
70003 unsigned long pgsize_bitmap;
70004 -};
70005 +} __do_const;
70006
70007 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70008 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70009 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70010 index 85ac9b9b..e5759ab 100644
70011 --- a/include/linux/ioport.h
70012 +++ b/include/linux/ioport.h
70013 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70014 int adjust_resource(struct resource *res, resource_size_t start,
70015 resource_size_t size);
70016 resource_size_t resource_alignment(struct resource *res);
70017 -static inline resource_size_t resource_size(const struct resource *res)
70018 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70019 {
70020 return res->end - res->start + 1;
70021 }
70022 diff --git a/include/linux/irq.h b/include/linux/irq.h
70023 index fdf2c4a..5332486 100644
70024 --- a/include/linux/irq.h
70025 +++ b/include/linux/irq.h
70026 @@ -328,7 +328,8 @@ struct irq_chip {
70027 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70028
70029 unsigned long flags;
70030 -};
70031 +} __do_const;
70032 +typedef struct irq_chip __no_const irq_chip_no_const;
70033
70034 /*
70035 * irq_chip specific flags
70036 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70037 index 6883e19..06992b1 100644
70038 --- a/include/linux/kallsyms.h
70039 +++ b/include/linux/kallsyms.h
70040 @@ -15,7 +15,8 @@
70041
70042 struct module;
70043
70044 -#ifdef CONFIG_KALLSYMS
70045 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70046 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70047 /* Lookup the address for a symbol. Returns 0 if not found. */
70048 unsigned long kallsyms_lookup_name(const char *name);
70049
70050 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70051 /* Stupid that this does nothing, but I didn't create this mess. */
70052 #define __print_symbol(fmt, addr)
70053 #endif /*CONFIG_KALLSYMS*/
70054 +#else /* when included by kallsyms.c, vsnprintf.c, or
70055 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70056 +extern void __print_symbol(const char *fmt, unsigned long address);
70057 +extern int sprint_backtrace(char *buffer, unsigned long address);
70058 +extern int sprint_symbol(char *buffer, unsigned long address);
70059 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70060 +const char *kallsyms_lookup(unsigned long addr,
70061 + unsigned long *symbolsize,
70062 + unsigned long *offset,
70063 + char **modname, char *namebuf);
70064 +#endif
70065
70066 /* This macro allows us to keep printk typechecking */
70067 static __printf(1, 2)
70068 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70069 index 518a53a..5e28358 100644
70070 --- a/include/linux/key-type.h
70071 +++ b/include/linux/key-type.h
70072 @@ -125,7 +125,7 @@ struct key_type {
70073 /* internal fields */
70074 struct list_head link; /* link in types list */
70075 struct lock_class_key lock_class; /* key->sem lock class */
70076 -};
70077 +} __do_const;
70078
70079 extern struct key_type key_type_keyring;
70080
70081 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70082 index 4dff0c6..1ca9b72 100644
70083 --- a/include/linux/kgdb.h
70084 +++ b/include/linux/kgdb.h
70085 @@ -53,7 +53,7 @@ extern int kgdb_connected;
70086 extern int kgdb_io_module_registered;
70087
70088 extern atomic_t kgdb_setting_breakpoint;
70089 -extern atomic_t kgdb_cpu_doing_single_step;
70090 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70091
70092 extern struct task_struct *kgdb_usethread;
70093 extern struct task_struct *kgdb_contthread;
70094 @@ -255,7 +255,7 @@ struct kgdb_arch {
70095 void (*correct_hw_break)(void);
70096
70097 void (*enable_nmi)(bool on);
70098 -};
70099 +} __do_const;
70100
70101 /**
70102 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70103 @@ -280,7 +280,7 @@ struct kgdb_io {
70104 void (*pre_exception) (void);
70105 void (*post_exception) (void);
70106 int is_console;
70107 -};
70108 +} __do_const;
70109
70110 extern struct kgdb_arch arch_kgdb_ops;
70111
70112 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70113 index 5398d58..5883a34 100644
70114 --- a/include/linux/kmod.h
70115 +++ b/include/linux/kmod.h
70116 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70117 * usually useless though. */
70118 extern __printf(2, 3)
70119 int __request_module(bool wait, const char *name, ...);
70120 +extern __printf(3, 4)
70121 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70122 #define request_module(mod...) __request_module(true, mod)
70123 #define request_module_nowait(mod...) __request_module(false, mod)
70124 #define try_then_request_module(x, mod...) \
70125 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70126 index 939b112..ed6ed51 100644
70127 --- a/include/linux/kobject.h
70128 +++ b/include/linux/kobject.h
70129 @@ -111,7 +111,7 @@ struct kobj_type {
70130 struct attribute **default_attrs;
70131 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70132 const void *(*namespace)(struct kobject *kobj);
70133 -};
70134 +} __do_const;
70135
70136 struct kobj_uevent_env {
70137 char *envp[UEVENT_NUM_ENVP];
70138 @@ -134,6 +134,7 @@ struct kobj_attribute {
70139 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70140 const char *buf, size_t count);
70141 };
70142 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70143
70144 extern const struct sysfs_ops kobj_sysfs_ops;
70145
70146 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70147 index f66b065..c2c29b4 100644
70148 --- a/include/linux/kobject_ns.h
70149 +++ b/include/linux/kobject_ns.h
70150 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70151 const void *(*netlink_ns)(struct sock *sk);
70152 const void *(*initial_ns)(void);
70153 void (*drop_ns)(void *);
70154 -};
70155 +} __do_const;
70156
70157 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70158 int kobj_ns_type_registered(enum kobj_ns_type type);
70159 diff --git a/include/linux/kref.h b/include/linux/kref.h
70160 index 4972e6e..de4d19b 100644
70161 --- a/include/linux/kref.h
70162 +++ b/include/linux/kref.h
70163 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70164 static inline int kref_sub(struct kref *kref, unsigned int count,
70165 void (*release)(struct kref *kref))
70166 {
70167 - WARN_ON(release == NULL);
70168 + BUG_ON(release == NULL);
70169
70170 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70171 release(kref);
70172 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70173 index ffdf8b7..1f91d0e 100644
70174 --- a/include/linux/kvm_host.h
70175 +++ b/include/linux/kvm_host.h
70176 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70177 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70178 void vcpu_put(struct kvm_vcpu *vcpu);
70179
70180 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70181 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70182 struct module *module);
70183 void kvm_exit(void);
70184
70185 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70186 struct kvm_guest_debug *dbg);
70187 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70188
70189 -int kvm_arch_init(void *opaque);
70190 +int kvm_arch_init(const void *opaque);
70191 void kvm_arch_exit(void);
70192
70193 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70194 diff --git a/include/linux/libata.h b/include/linux/libata.h
70195 index 0621bca..24d6851 100644
70196 --- a/include/linux/libata.h
70197 +++ b/include/linux/libata.h
70198 @@ -916,7 +916,7 @@ struct ata_port_operations {
70199 * fields must be pointers.
70200 */
70201 const struct ata_port_operations *inherits;
70202 -};
70203 +} __do_const;
70204
70205 struct ata_port_info {
70206 unsigned long flags;
70207 diff --git a/include/linux/list.h b/include/linux/list.h
70208 index cc6d2aa..c10ee83 100644
70209 --- a/include/linux/list.h
70210 +++ b/include/linux/list.h
70211 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70212 extern void list_del(struct list_head *entry);
70213 #endif
70214
70215 +extern void __pax_list_add(struct list_head *new,
70216 + struct list_head *prev,
70217 + struct list_head *next);
70218 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70219 +{
70220 + __pax_list_add(new, head, head->next);
70221 +}
70222 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70223 +{
70224 + __pax_list_add(new, head->prev, head);
70225 +}
70226 +extern void pax_list_del(struct list_head *entry);
70227 +
70228 /**
70229 * list_replace - replace old entry by new one
70230 * @old : the element to be replaced
70231 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70232 INIT_LIST_HEAD(entry);
70233 }
70234
70235 +extern void pax_list_del_init(struct list_head *entry);
70236 +
70237 /**
70238 * list_move - delete from one list and add as another's head
70239 * @list: the entry to move
70240 diff --git a/include/linux/math64.h b/include/linux/math64.h
70241 index b8ba855..0148090 100644
70242 --- a/include/linux/math64.h
70243 +++ b/include/linux/math64.h
70244 @@ -14,7 +14,7 @@
70245 * This is commonly provided by 32bit archs to provide an optimized 64bit
70246 * divide.
70247 */
70248 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70249 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70250 {
70251 *remainder = dividend % divisor;
70252 return dividend / divisor;
70253 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70254 #define div64_long(x,y) div_s64((x),(y))
70255
70256 #ifndef div_u64_rem
70257 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70258 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70259 {
70260 *remainder = do_div(dividend, divisor);
70261 return dividend;
70262 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70263 * divide.
70264 */
70265 #ifndef div_u64
70266 -static inline u64 div_u64(u64 dividend, u32 divisor)
70267 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70268 {
70269 u32 remainder;
70270 return div_u64_rem(dividend, divisor, &remainder);
70271 diff --git a/include/linux/mm.h b/include/linux/mm.h
70272 index 9568b90..6cc79f9 100644
70273 --- a/include/linux/mm.h
70274 +++ b/include/linux/mm.h
70275 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70276 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70277 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70278 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70279 +
70280 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70281 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70282 +#endif
70283 +
70284 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70285
70286 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70287 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70288 /* called by access_process_vm when get_user_pages() fails, typically
70289 * for use by special VMAs that can switch between memory and hardware
70290 */
70291 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70292 - void *buf, int len, int write);
70293 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70294 + void *buf, size_t len, int write);
70295 #ifdef CONFIG_NUMA
70296 /*
70297 * set_policy() op must add a reference to any non-NULL @new mempolicy
70298 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70299 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70300 unsigned long size, pgoff_t pgoff);
70301 };
70302 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70303
70304 struct mmu_gather;
70305 struct inode;
70306 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70307 unsigned long *pfn);
70308 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70309 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70310 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70311 - void *buf, int len, int write);
70312 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70313 + void *buf, size_t len, int write);
70314
70315 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70316 loff_t const holebegin, loff_t const holelen)
70317 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70318 }
70319 #endif
70320
70321 -extern int make_pages_present(unsigned long addr, unsigned long end);
70322 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70323 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70324 - void *buf, int len, int write);
70325 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70326 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70327 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70328 + void *buf, size_t len, int write);
70329
70330 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70331 unsigned long start, int len, unsigned int foll_flags,
70332 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70333 int set_page_dirty_lock(struct page *page);
70334 int clear_page_dirty_for_io(struct page *page);
70335
70336 -/* Is the vma a continuation of the stack vma above it? */
70337 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70338 -{
70339 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70340 -}
70341 -
70342 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70343 - unsigned long addr)
70344 -{
70345 - return (vma->vm_flags & VM_GROWSDOWN) &&
70346 - (vma->vm_start == addr) &&
70347 - !vma_growsdown(vma->vm_prev, addr);
70348 -}
70349 -
70350 -/* Is the vma a continuation of the stack vma below it? */
70351 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70352 -{
70353 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70354 -}
70355 -
70356 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70357 - unsigned long addr)
70358 -{
70359 - return (vma->vm_flags & VM_GROWSUP) &&
70360 - (vma->vm_end == addr) &&
70361 - !vma_growsup(vma->vm_next, addr);
70362 -}
70363 -
70364 extern pid_t
70365 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70366
70367 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70368 }
70369 #endif
70370
70371 +#ifdef CONFIG_MMU
70372 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70373 +#else
70374 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70375 +{
70376 + return __pgprot(0);
70377 +}
70378 +#endif
70379 +
70380 int vma_wants_writenotify(struct vm_area_struct *vma);
70381
70382 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70383 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70384 {
70385 return 0;
70386 }
70387 +
70388 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70389 + unsigned long address)
70390 +{
70391 + return 0;
70392 +}
70393 #else
70394 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70395 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70396 #endif
70397
70398 #ifdef __PAGETABLE_PMD_FOLDED
70399 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70400 {
70401 return 0;
70402 }
70403 +
70404 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70405 + unsigned long address)
70406 +{
70407 + return 0;
70408 +}
70409 #else
70410 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70411 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70412 #endif
70413
70414 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70415 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70416 NULL: pud_offset(pgd, address);
70417 }
70418
70419 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70420 +{
70421 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70422 + NULL: pud_offset(pgd, address);
70423 +}
70424 +
70425 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70426 {
70427 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70428 NULL: pmd_offset(pud, address);
70429 }
70430 +
70431 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70432 +{
70433 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70434 + NULL: pmd_offset(pud, address);
70435 +}
70436 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70437
70438 #if USE_SPLIT_PTLOCKS
70439 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70440 unsigned long, unsigned long,
70441 unsigned long, unsigned long);
70442 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70443 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70444
70445 /* These take the mm semaphore themselves */
70446 extern unsigned long vm_brk(unsigned long, unsigned long);
70447 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70448 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70449 struct vm_area_struct **pprev);
70450
70451 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70452 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70453 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70454 +
70455 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70456 NULL if none. Assume start_addr < end_addr. */
70457 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70458 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70459 return vma;
70460 }
70461
70462 -#ifdef CONFIG_MMU
70463 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70464 -#else
70465 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70466 -{
70467 - return __pgprot(0);
70468 -}
70469 -#endif
70470 -
70471 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70472 unsigned long change_prot_numa(struct vm_area_struct *vma,
70473 unsigned long start, unsigned long end);
70474 @@ -1651,6 +1660,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70475 static inline void vm_stat_account(struct mm_struct *mm,
70476 unsigned long flags, struct file *file, long pages)
70477 {
70478 +
70479 +#ifdef CONFIG_PAX_RANDMMAP
70480 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70481 +#endif
70482 +
70483 mm->total_vm += pages;
70484 }
70485 #endif /* CONFIG_PROC_FS */
70486 @@ -1723,7 +1737,7 @@ extern int unpoison_memory(unsigned long pfn);
70487 extern int sysctl_memory_failure_early_kill;
70488 extern int sysctl_memory_failure_recovery;
70489 extern void shake_page(struct page *p, int access);
70490 -extern atomic_long_t mce_bad_pages;
70491 +extern atomic_long_unchecked_t mce_bad_pages;
70492 extern int soft_offline_page(struct page *page, int flags);
70493
70494 extern void dump_page(struct page *page);
70495 @@ -1754,5 +1768,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70496 static inline bool page_is_guard(struct page *page) { return false; }
70497 #endif /* CONFIG_DEBUG_PAGEALLOC */
70498
70499 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70500 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70501 +#else
70502 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70503 +#endif
70504 +
70505 #endif /* __KERNEL__ */
70506 #endif /* _LINUX_MM_H */
70507 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70508 index f8f5162..3aaf20f 100644
70509 --- a/include/linux/mm_types.h
70510 +++ b/include/linux/mm_types.h
70511 @@ -288,6 +288,8 @@ struct vm_area_struct {
70512 #ifdef CONFIG_NUMA
70513 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70514 #endif
70515 +
70516 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70517 };
70518
70519 struct core_thread {
70520 @@ -436,6 +438,24 @@ struct mm_struct {
70521 int first_nid;
70522 #endif
70523 struct uprobes_state uprobes_state;
70524 +
70525 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70526 + unsigned long pax_flags;
70527 +#endif
70528 +
70529 +#ifdef CONFIG_PAX_DLRESOLVE
70530 + unsigned long call_dl_resolve;
70531 +#endif
70532 +
70533 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70534 + unsigned long call_syscall;
70535 +#endif
70536 +
70537 +#ifdef CONFIG_PAX_ASLR
70538 + unsigned long delta_mmap; /* randomized offset */
70539 + unsigned long delta_stack; /* randomized offset */
70540 +#endif
70541 +
70542 };
70543
70544 /* first nid will either be a valid NID or one of these values */
70545 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70546 index c5d5278..f0b68c8 100644
70547 --- a/include/linux/mmiotrace.h
70548 +++ b/include/linux/mmiotrace.h
70549 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70550 /* Called from ioremap.c */
70551 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70552 void __iomem *addr);
70553 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70554 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70555
70556 /* For anyone to insert markers. Remember trailing newline. */
70557 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70558 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70559 {
70560 }
70561
70562 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70563 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70564 {
70565 }
70566
70567 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70568 index 73b64a3..6562925 100644
70569 --- a/include/linux/mmzone.h
70570 +++ b/include/linux/mmzone.h
70571 @@ -412,7 +412,7 @@ struct zone {
70572 unsigned long flags; /* zone flags, see below */
70573
70574 /* Zone statistics */
70575 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70576 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70577
70578 /*
70579 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70580 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70581 index fed3def..c933f99 100644
70582 --- a/include/linux/mod_devicetable.h
70583 +++ b/include/linux/mod_devicetable.h
70584 @@ -12,7 +12,7 @@
70585 typedef unsigned long kernel_ulong_t;
70586 #endif
70587
70588 -#define PCI_ANY_ID (~0)
70589 +#define PCI_ANY_ID ((__u16)~0)
70590
70591 struct pci_device_id {
70592 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70593 @@ -139,7 +139,7 @@ struct usb_device_id {
70594 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70595 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70596
70597 -#define HID_ANY_ID (~0)
70598 +#define HID_ANY_ID (~0U)
70599 #define HID_BUS_ANY 0xffff
70600 #define HID_GROUP_ANY 0x0000
70601
70602 @@ -498,7 +498,7 @@ struct dmi_system_id {
70603 const char *ident;
70604 struct dmi_strmatch matches[4];
70605 void *driver_data;
70606 -};
70607 +} __do_const;
70608 /*
70609 * struct dmi_device_id appears during expansion of
70610 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70611 diff --git a/include/linux/module.h b/include/linux/module.h
70612 index 1375ee3..ced8177 100644
70613 --- a/include/linux/module.h
70614 +++ b/include/linux/module.h
70615 @@ -17,9 +17,11 @@
70616 #include <linux/moduleparam.h>
70617 #include <linux/tracepoint.h>
70618 #include <linux/export.h>
70619 +#include <linux/fs.h>
70620
70621 #include <linux/percpu.h>
70622 #include <asm/module.h>
70623 +#include <asm/pgtable.h>
70624
70625 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70626 #define MODULE_SIG_STRING "~Module signature appended~\n"
70627 @@ -54,12 +56,13 @@ struct module_attribute {
70628 int (*test)(struct module *);
70629 void (*free)(struct module *);
70630 };
70631 +typedef struct module_attribute __no_const module_attribute_no_const;
70632
70633 struct module_version_attribute {
70634 struct module_attribute mattr;
70635 const char *module_name;
70636 const char *version;
70637 -} __attribute__ ((__aligned__(sizeof(void *))));
70638 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70639
70640 extern ssize_t __modver_version_show(struct module_attribute *,
70641 struct module_kobject *, char *);
70642 @@ -232,7 +235,7 @@ struct module
70643
70644 /* Sysfs stuff. */
70645 struct module_kobject mkobj;
70646 - struct module_attribute *modinfo_attrs;
70647 + module_attribute_no_const *modinfo_attrs;
70648 const char *version;
70649 const char *srcversion;
70650 struct kobject *holders_dir;
70651 @@ -281,19 +284,16 @@ struct module
70652 int (*init)(void);
70653
70654 /* If this is non-NULL, vfree after init() returns */
70655 - void *module_init;
70656 + void *module_init_rx, *module_init_rw;
70657
70658 /* Here is the actual code + data, vfree'd on unload. */
70659 - void *module_core;
70660 + void *module_core_rx, *module_core_rw;
70661
70662 /* Here are the sizes of the init and core sections */
70663 - unsigned int init_size, core_size;
70664 + unsigned int init_size_rw, core_size_rw;
70665
70666 /* The size of the executable code in each section. */
70667 - unsigned int init_text_size, core_text_size;
70668 -
70669 - /* Size of RO sections of the module (text+rodata) */
70670 - unsigned int init_ro_size, core_ro_size;
70671 + unsigned int init_size_rx, core_size_rx;
70672
70673 /* Arch-specific module values */
70674 struct mod_arch_specific arch;
70675 @@ -349,6 +349,10 @@ struct module
70676 #ifdef CONFIG_EVENT_TRACING
70677 struct ftrace_event_call **trace_events;
70678 unsigned int num_trace_events;
70679 + struct file_operations trace_id;
70680 + struct file_operations trace_enable;
70681 + struct file_operations trace_format;
70682 + struct file_operations trace_filter;
70683 #endif
70684 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70685 unsigned int num_ftrace_callsites;
70686 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70687 bool is_module_percpu_address(unsigned long addr);
70688 bool is_module_text_address(unsigned long addr);
70689
70690 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70691 +{
70692 +
70693 +#ifdef CONFIG_PAX_KERNEXEC
70694 + if (ktla_ktva(addr) >= (unsigned long)start &&
70695 + ktla_ktva(addr) < (unsigned long)start + size)
70696 + return 1;
70697 +#endif
70698 +
70699 + return ((void *)addr >= start && (void *)addr < start + size);
70700 +}
70701 +
70702 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70703 +{
70704 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70705 +}
70706 +
70707 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70708 +{
70709 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70710 +}
70711 +
70712 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70713 +{
70714 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70715 +}
70716 +
70717 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70718 +{
70719 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70720 +}
70721 +
70722 static inline int within_module_core(unsigned long addr, struct module *mod)
70723 {
70724 - return (unsigned long)mod->module_core <= addr &&
70725 - addr < (unsigned long)mod->module_core + mod->core_size;
70726 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70727 }
70728
70729 static inline int within_module_init(unsigned long addr, struct module *mod)
70730 {
70731 - return (unsigned long)mod->module_init <= addr &&
70732 - addr < (unsigned long)mod->module_init + mod->init_size;
70733 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70734 }
70735
70736 /* Search for module by name: must hold module_mutex. */
70737 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70738 index 560ca53..ef621ef 100644
70739 --- a/include/linux/moduleloader.h
70740 +++ b/include/linux/moduleloader.h
70741 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70742 sections. Returns NULL on failure. */
70743 void *module_alloc(unsigned long size);
70744
70745 +#ifdef CONFIG_PAX_KERNEXEC
70746 +void *module_alloc_exec(unsigned long size);
70747 +#else
70748 +#define module_alloc_exec(x) module_alloc(x)
70749 +#endif
70750 +
70751 /* Free memory returned from module_alloc. */
70752 void module_free(struct module *mod, void *module_region);
70753
70754 +#ifdef CONFIG_PAX_KERNEXEC
70755 +void module_free_exec(struct module *mod, void *module_region);
70756 +#else
70757 +#define module_free_exec(x, y) module_free((x), (y))
70758 +#endif
70759 +
70760 /*
70761 * Apply the given relocation to the (simplified) ELF. Return -error
70762 * or 0.
70763 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70764 unsigned int relsec,
70765 struct module *me)
70766 {
70767 +#ifdef CONFIG_MODULES
70768 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70769 +#endif
70770 return -ENOEXEC;
70771 }
70772 #endif
70773 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70774 unsigned int relsec,
70775 struct module *me)
70776 {
70777 +#ifdef CONFIG_MODULES
70778 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70779 +#endif
70780 return -ENOEXEC;
70781 }
70782 #endif
70783 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70784 index 137b419..fe663ec 100644
70785 --- a/include/linux/moduleparam.h
70786 +++ b/include/linux/moduleparam.h
70787 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70788 * @len is usually just sizeof(string).
70789 */
70790 #define module_param_string(name, string, len, perm) \
70791 - static const struct kparam_string __param_string_##name \
70792 + static const struct kparam_string __param_string_##name __used \
70793 = { len, string }; \
70794 __module_param_call(MODULE_PARAM_PREFIX, name, \
70795 &param_ops_string, \
70796 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70797 */
70798 #define module_param_array_named(name, array, type, nump, perm) \
70799 param_check_##type(name, &(array)[0]); \
70800 - static const struct kparam_array __param_arr_##name \
70801 + static const struct kparam_array __param_arr_##name __used \
70802 = { .max = ARRAY_SIZE(array), .num = nump, \
70803 .ops = &param_ops_##type, \
70804 .elemsize = sizeof(array[0]), .elem = array }; \
70805 diff --git a/include/linux/namei.h b/include/linux/namei.h
70806 index 5a5ff57..5ae5070 100644
70807 --- a/include/linux/namei.h
70808 +++ b/include/linux/namei.h
70809 @@ -19,7 +19,7 @@ struct nameidata {
70810 unsigned seq;
70811 int last_type;
70812 unsigned depth;
70813 - char *saved_names[MAX_NESTED_LINKS + 1];
70814 + const char *saved_names[MAX_NESTED_LINKS + 1];
70815 };
70816
70817 /*
70818 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70819
70820 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70821
70822 -static inline void nd_set_link(struct nameidata *nd, char *path)
70823 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70824 {
70825 nd->saved_names[nd->depth] = path;
70826 }
70827
70828 -static inline char *nd_get_link(struct nameidata *nd)
70829 +static inline const char *nd_get_link(const struct nameidata *nd)
70830 {
70831 return nd->saved_names[nd->depth];
70832 }
70833 diff --git a/include/linux/net.h b/include/linux/net.h
70834 index aa16731..514b875 100644
70835 --- a/include/linux/net.h
70836 +++ b/include/linux/net.h
70837 @@ -183,7 +183,7 @@ struct net_proto_family {
70838 int (*create)(struct net *net, struct socket *sock,
70839 int protocol, int kern);
70840 struct module *owner;
70841 -};
70842 +} __do_const;
70843
70844 struct iovec;
70845 struct kvec;
70846 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70847 index 0e182f9..bd5d452 100644
70848 --- a/include/linux/netdevice.h
70849 +++ b/include/linux/netdevice.h
70850 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70851 u32 pid, u32 seq,
70852 struct net_device *dev);
70853 };
70854 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70855
70856 /*
70857 * The DEVICE structure.
70858 @@ -1078,7 +1079,7 @@ struct net_device {
70859 int iflink;
70860
70861 struct net_device_stats stats;
70862 - atomic_long_t rx_dropped; /* dropped packets by core network
70863 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70864 * Do not use this in drivers.
70865 */
70866
70867 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70868 index ee14284..bc65d63 100644
70869 --- a/include/linux/netfilter.h
70870 +++ b/include/linux/netfilter.h
70871 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70872 #endif
70873 /* Use the module struct to lock set/get code in place */
70874 struct module *owner;
70875 -};
70876 +} __do_const;
70877
70878 /* Function to register/unregister hook points. */
70879 int nf_register_hook(struct nf_hook_ops *reg);
70880 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70881 index 7958e84..ed74d7a 100644
70882 --- a/include/linux/netfilter/ipset/ip_set.h
70883 +++ b/include/linux/netfilter/ipset/ip_set.h
70884 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70885 /* Return true if "b" set is the same as "a"
70886 * according to the create set parameters */
70887 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70888 -};
70889 +} __do_const;
70890
70891 /* The core set type structure */
70892 struct ip_set_type {
70893 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70894 index 4966dde..7d8ce06 100644
70895 --- a/include/linux/netfilter/nfnetlink.h
70896 +++ b/include/linux/netfilter/nfnetlink.h
70897 @@ -16,7 +16,7 @@ struct nfnl_callback {
70898 const struct nlattr * const cda[]);
70899 const struct nla_policy *policy; /* netlink attribute policy */
70900 const u_int16_t attr_count; /* number of nlattr's */
70901 -};
70902 +} __do_const;
70903
70904 struct nfnetlink_subsystem {
70905 const char *name;
70906 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70907 new file mode 100644
70908 index 0000000..33f4af8
70909 --- /dev/null
70910 +++ b/include/linux/netfilter/xt_gradm.h
70911 @@ -0,0 +1,9 @@
70912 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70913 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70914 +
70915 +struct xt_gradm_mtinfo {
70916 + __u16 flags;
70917 + __u16 invflags;
70918 +};
70919 +
70920 +#endif
70921 diff --git a/include/linux/nls.h b/include/linux/nls.h
70922 index 5dc635f..35f5e11 100644
70923 --- a/include/linux/nls.h
70924 +++ b/include/linux/nls.h
70925 @@ -31,7 +31,7 @@ struct nls_table {
70926 const unsigned char *charset2upper;
70927 struct module *owner;
70928 struct nls_table *next;
70929 -};
70930 +} __do_const;
70931
70932 /* this value hold the maximum octet of charset */
70933 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70934 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70935 index d65746e..62e72c2 100644
70936 --- a/include/linux/notifier.h
70937 +++ b/include/linux/notifier.h
70938 @@ -51,7 +51,8 @@ struct notifier_block {
70939 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70940 struct notifier_block __rcu *next;
70941 int priority;
70942 -};
70943 +} __do_const;
70944 +typedef struct notifier_block __no_const notifier_block_no_const;
70945
70946 struct atomic_notifier_head {
70947 spinlock_t lock;
70948 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70949 index a4c5624..79d6d88 100644
70950 --- a/include/linux/oprofile.h
70951 +++ b/include/linux/oprofile.h
70952 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70953 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70954 char const * name, ulong * val);
70955
70956 -/** Create a file for read-only access to an atomic_t. */
70957 +/** Create a file for read-only access to an atomic_unchecked_t. */
70958 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70959 - char const * name, atomic_t * val);
70960 + char const * name, atomic_unchecked_t * val);
70961
70962 /** create a directory */
70963 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70964 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70965 index 45fc162..01a4068 100644
70966 --- a/include/linux/pci_hotplug.h
70967 +++ b/include/linux/pci_hotplug.h
70968 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70969 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70970 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70971 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70972 -};
70973 +} __do_const;
70974 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70975
70976 /**
70977 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70978 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70979 index a280650..2b67b91 100644
70980 --- a/include/linux/perf_event.h
70981 +++ b/include/linux/perf_event.h
70982 @@ -328,8 +328,8 @@ struct perf_event {
70983
70984 enum perf_event_active_state state;
70985 unsigned int attach_state;
70986 - local64_t count;
70987 - atomic64_t child_count;
70988 + local64_t count; /* PaX: fix it one day */
70989 + atomic64_unchecked_t child_count;
70990
70991 /*
70992 * These are the total time in nanoseconds that the event
70993 @@ -380,8 +380,8 @@ struct perf_event {
70994 * These accumulate total time (in nanoseconds) that children
70995 * events have been enabled and running, respectively.
70996 */
70997 - atomic64_t child_total_time_enabled;
70998 - atomic64_t child_total_time_running;
70999 + atomic64_unchecked_t child_total_time_enabled;
71000 + atomic64_unchecked_t child_total_time_running;
71001
71002 /*
71003 * Protect attach/detach and child_list:
71004 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
71005 */
71006 #define perf_cpu_notifier(fn) \
71007 do { \
71008 - static struct notifier_block fn##_nb __cpuinitdata = \
71009 + static struct notifier_block fn##_nb = \
71010 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71011 unsigned long cpu = smp_processor_id(); \
71012 unsigned long flags; \
71013 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71014 index ad1a427..6419649 100644
71015 --- a/include/linux/pipe_fs_i.h
71016 +++ b/include/linux/pipe_fs_i.h
71017 @@ -45,9 +45,9 @@ struct pipe_buffer {
71018 struct pipe_inode_info {
71019 wait_queue_head_t wait;
71020 unsigned int nrbufs, curbuf, buffers;
71021 - unsigned int readers;
71022 - unsigned int writers;
71023 - unsigned int waiting_writers;
71024 + atomic_t readers;
71025 + atomic_t writers;
71026 + atomic_t waiting_writers;
71027 unsigned int r_counter;
71028 unsigned int w_counter;
71029 struct page *tmp_page;
71030 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71031 index 5f28cae..3d23723 100644
71032 --- a/include/linux/platform_data/usb-ehci-s5p.h
71033 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71034 @@ -14,7 +14,7 @@
71035 struct s5p_ehci_platdata {
71036 int (*phy_init)(struct platform_device *pdev, int type);
71037 int (*phy_exit)(struct platform_device *pdev, int type);
71038 -};
71039 +} __no_const;
71040
71041 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71042
71043 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
71044 index c256c59..8ea94c7 100644
71045 --- a/include/linux/platform_data/usb-exynos.h
71046 +++ b/include/linux/platform_data/usb-exynos.h
71047 @@ -14,7 +14,7 @@
71048 struct exynos4_ohci_platdata {
71049 int (*phy_init)(struct platform_device *pdev, int type);
71050 int (*phy_exit)(struct platform_device *pdev, int type);
71051 -};
71052 +} __no_const;
71053
71054 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71055
71056 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71057 index 7c1d252..c5c773e 100644
71058 --- a/include/linux/pm_domain.h
71059 +++ b/include/linux/pm_domain.h
71060 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71061
71062 struct gpd_cpu_data {
71063 unsigned int saved_exit_latency;
71064 - struct cpuidle_state *idle_state;
71065 + cpuidle_state_no_const *idle_state;
71066 };
71067
71068 struct generic_pm_domain {
71069 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71070 index f271860..6b3bec5 100644
71071 --- a/include/linux/pm_runtime.h
71072 +++ b/include/linux/pm_runtime.h
71073 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71074
71075 static inline void pm_runtime_mark_last_busy(struct device *dev)
71076 {
71077 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71078 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71079 }
71080
71081 #else /* !CONFIG_PM_RUNTIME */
71082 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71083 index 195aafc..49a7bc2 100644
71084 --- a/include/linux/pnp.h
71085 +++ b/include/linux/pnp.h
71086 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71087 struct pnp_fixup {
71088 char id[7];
71089 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71090 -};
71091 +} __do_const;
71092
71093 /* config parameters */
71094 #define PNP_CONFIG_NORMAL 0x0001
71095 diff --git a/include/linux/poison.h b/include/linux/poison.h
71096 index 2110a81..13a11bb 100644
71097 --- a/include/linux/poison.h
71098 +++ b/include/linux/poison.h
71099 @@ -19,8 +19,8 @@
71100 * under normal circumstances, used to verify that nobody uses
71101 * non-initialized list entries.
71102 */
71103 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71104 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71105 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71106 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71107
71108 /********** include/linux/timer.h **********/
71109 /*
71110 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71111 index c0f44c2..1572583 100644
71112 --- a/include/linux/power/smartreflex.h
71113 +++ b/include/linux/power/smartreflex.h
71114 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71115 int (*notify)(struct omap_sr *sr, u32 status);
71116 u8 notify_flags;
71117 u8 class_type;
71118 -};
71119 +} __do_const;
71120
71121 /**
71122 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71123 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71124 index 4ea1d37..80f4b33 100644
71125 --- a/include/linux/ppp-comp.h
71126 +++ b/include/linux/ppp-comp.h
71127 @@ -84,7 +84,7 @@ struct compressor {
71128 struct module *owner;
71129 /* Extra skb space needed by the compressor algorithm */
71130 unsigned int comp_extra;
71131 -};
71132 +} __do_const;
71133
71134 /*
71135 * The return value from decompress routine is the length of the
71136 diff --git a/include/linux/printk.h b/include/linux/printk.h
71137 index 9afc01e..92c32e8 100644
71138 --- a/include/linux/printk.h
71139 +++ b/include/linux/printk.h
71140 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71141 extern int printk_needs_cpu(int cpu);
71142 extern void printk_tick(void);
71143
71144 +extern int kptr_restrict;
71145 +
71146 #ifdef CONFIG_PRINTK
71147 asmlinkage __printf(5, 0)
71148 int vprintk_emit(int facility, int level,
71149 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71150
71151 extern int printk_delay_msec;
71152 extern int dmesg_restrict;
71153 -extern int kptr_restrict;
71154
71155 void log_buf_kexec_setup(void);
71156 void __init setup_log_buf(int early);
71157 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71158 index 32676b3..e46f2c0 100644
71159 --- a/include/linux/proc_fs.h
71160 +++ b/include/linux/proc_fs.h
71161 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71162 return proc_create_data(name, mode, parent, proc_fops, NULL);
71163 }
71164
71165 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71166 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71167 +{
71168 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71169 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71170 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71171 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71172 +#else
71173 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71174 +#endif
71175 +}
71176 +
71177 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71178 umode_t mode, struct proc_dir_entry *base,
71179 read_proc_t *read_proc, void * data)
71180 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71181 void (*put)(void *ns);
71182 int (*install)(struct nsproxy *nsproxy, void *ns);
71183 unsigned int (*inum)(void *ns);
71184 -};
71185 +} __do_const;
71186 extern const struct proc_ns_operations netns_operations;
71187 extern const struct proc_ns_operations utsns_operations;
71188 extern const struct proc_ns_operations ipcns_operations;
71189 diff --git a/include/linux/random.h b/include/linux/random.h
71190 index d984608..d6f0042 100644
71191 --- a/include/linux/random.h
71192 +++ b/include/linux/random.h
71193 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71194 u32 prandom_u32_state(struct rnd_state *);
71195 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71196
71197 +static inline unsigned long pax_get_random_long(void)
71198 +{
71199 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71200 +}
71201 +
71202 /*
71203 * Handle minimum values for seeds
71204 */
71205 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71206 index c92dd28..08f4eab 100644
71207 --- a/include/linux/rculist.h
71208 +++ b/include/linux/rculist.h
71209 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71210 struct list_head *prev, struct list_head *next);
71211 #endif
71212
71213 +extern void __pax_list_add_rcu(struct list_head *new,
71214 + struct list_head *prev, struct list_head *next);
71215 +
71216 /**
71217 * list_add_rcu - add a new entry to rcu-protected list
71218 * @new: new entry to be added
71219 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71220 __list_add_rcu(new, head, head->next);
71221 }
71222
71223 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71224 +{
71225 + __pax_list_add_rcu(new, head, head->next);
71226 +}
71227 +
71228 /**
71229 * list_add_tail_rcu - add a new entry to rcu-protected list
71230 * @new: new entry to be added
71231 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71232 __list_add_rcu(new, head->prev, head);
71233 }
71234
71235 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71236 + struct list_head *head)
71237 +{
71238 + __pax_list_add_rcu(new, head->prev, head);
71239 +}
71240 +
71241 /**
71242 * list_del_rcu - deletes entry from list without re-initialization
71243 * @entry: the element to delete from the list.
71244 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71245 entry->prev = LIST_POISON2;
71246 }
71247
71248 +extern void pax_list_del_rcu(struct list_head *entry);
71249 +
71250 /**
71251 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71252 * @n: the element to delete from the hash list.
71253 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71254 index 23b3630..e1bc12b 100644
71255 --- a/include/linux/reboot.h
71256 +++ b/include/linux/reboot.h
71257 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71258 * Architecture-specific implementations of sys_reboot commands.
71259 */
71260
71261 -extern void machine_restart(char *cmd);
71262 -extern void machine_halt(void);
71263 -extern void machine_power_off(void);
71264 +extern void machine_restart(char *cmd) __noreturn;
71265 +extern void machine_halt(void) __noreturn;
71266 +extern void machine_power_off(void) __noreturn;
71267
71268 extern void machine_shutdown(void);
71269 struct pt_regs;
71270 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71271 */
71272
71273 extern void kernel_restart_prepare(char *cmd);
71274 -extern void kernel_restart(char *cmd);
71275 -extern void kernel_halt(void);
71276 -extern void kernel_power_off(void);
71277 +extern void kernel_restart(char *cmd) __noreturn;
71278 +extern void kernel_halt(void) __noreturn;
71279 +extern void kernel_power_off(void) __noreturn;
71280
71281 extern int C_A_D; /* for sysctl */
71282 void ctrl_alt_del(void);
71283 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71284 * Emergency restart, callable from an interrupt handler.
71285 */
71286
71287 -extern void emergency_restart(void);
71288 +extern void emergency_restart(void) __noreturn;
71289 #include <asm/emergency-restart.h>
71290
71291 #endif /* _LINUX_REBOOT_H */
71292 diff --git a/include/linux/regset.h b/include/linux/regset.h
71293 index 8e0c9fe..ac4d221 100644
71294 --- a/include/linux/regset.h
71295 +++ b/include/linux/regset.h
71296 @@ -161,7 +161,8 @@ struct user_regset {
71297 unsigned int align;
71298 unsigned int bias;
71299 unsigned int core_note_type;
71300 -};
71301 +} __do_const;
71302 +typedef struct user_regset __no_const user_regset_no_const;
71303
71304 /**
71305 * struct user_regset_view - available regsets
71306 diff --git a/include/linux/relay.h b/include/linux/relay.h
71307 index 91cacc3..b55ff74 100644
71308 --- a/include/linux/relay.h
71309 +++ b/include/linux/relay.h
71310 @@ -160,7 +160,7 @@ struct rchan_callbacks
71311 * The callback should return 0 if successful, negative if not.
71312 */
71313 int (*remove_buf_file)(struct dentry *dentry);
71314 -};
71315 +} __no_const;
71316
71317 /*
71318 * CONFIG_RELAY kernel API, kernel/relay.c
71319 diff --git a/include/linux/rio.h b/include/linux/rio.h
71320 index a3e7842..d973ca6 100644
71321 --- a/include/linux/rio.h
71322 +++ b/include/linux/rio.h
71323 @@ -339,7 +339,7 @@ struct rio_ops {
71324 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71325 u64 rstart, u32 size, u32 flags);
71326 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71327 -};
71328 +} __no_const;
71329
71330 #define RIO_RESOURCE_MEM 0x00000100
71331 #define RIO_RESOURCE_DOORBELL 0x00000200
71332 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71333 index c20635c..2f5def4 100644
71334 --- a/include/linux/rmap.h
71335 +++ b/include/linux/rmap.h
71336 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71337 void anon_vma_init(void); /* create anon_vma_cachep */
71338 int anon_vma_prepare(struct vm_area_struct *);
71339 void unlink_anon_vmas(struct vm_area_struct *);
71340 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71341 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71342 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71343 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71344
71345 static inline void anon_vma_merge(struct vm_area_struct *vma,
71346 struct vm_area_struct *next)
71347 diff --git a/include/linux/sched.h b/include/linux/sched.h
71348 index f5ad26e..aa97a06 100644
71349 --- a/include/linux/sched.h
71350 +++ b/include/linux/sched.h
71351 @@ -61,6 +61,7 @@ struct bio_list;
71352 struct fs_struct;
71353 struct perf_event_context;
71354 struct blk_plug;
71355 +struct linux_binprm;
71356
71357 /*
71358 * List of flags we want to share for kernel threads,
71359 @@ -328,7 +329,7 @@ extern char __sched_text_start[], __sched_text_end[];
71360 extern int in_sched_functions(unsigned long addr);
71361
71362 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71363 -extern signed long schedule_timeout(signed long timeout);
71364 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71365 extern signed long schedule_timeout_interruptible(signed long timeout);
71366 extern signed long schedule_timeout_killable(signed long timeout);
71367 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71368 @@ -355,10 +356,23 @@ struct user_namespace;
71369 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71370
71371 extern int sysctl_max_map_count;
71372 +extern unsigned long sysctl_heap_stack_gap;
71373
71374 #include <linux/aio.h>
71375
71376 #ifdef CONFIG_MMU
71377 +
71378 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71379 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71380 +#else
71381 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71382 +{
71383 + return 0;
71384 +}
71385 +#endif
71386 +
71387 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71388 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71389 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71390 extern unsigned long
71391 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71392 @@ -640,6 +654,17 @@ struct signal_struct {
71393 #ifdef CONFIG_TASKSTATS
71394 struct taskstats *stats;
71395 #endif
71396 +
71397 +#ifdef CONFIG_GRKERNSEC
71398 + u32 curr_ip;
71399 + u32 saved_ip;
71400 + u32 gr_saddr;
71401 + u32 gr_daddr;
71402 + u16 gr_sport;
71403 + u16 gr_dport;
71404 + u8 used_accept:1;
71405 +#endif
71406 +
71407 #ifdef CONFIG_AUDIT
71408 unsigned audit_tty;
71409 struct tty_audit_buf *tty_audit_buf;
71410 @@ -718,6 +743,11 @@ struct user_struct {
71411 struct key *session_keyring; /* UID's default session keyring */
71412 #endif
71413
71414 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71415 + unsigned int banned;
71416 + unsigned long ban_expires;
71417 +#endif
71418 +
71419 /* Hash table maintenance information */
71420 struct hlist_node uidhash_node;
71421 kuid_t uid;
71422 @@ -1117,7 +1147,7 @@ struct sched_class {
71423 #ifdef CONFIG_FAIR_GROUP_SCHED
71424 void (*task_move_group) (struct task_struct *p, int on_rq);
71425 #endif
71426 -};
71427 +} __do_const;
71428
71429 struct load_weight {
71430 unsigned long weight, inv_weight;
71431 @@ -1361,8 +1391,8 @@ struct task_struct {
71432 struct list_head thread_group;
71433
71434 struct completion *vfork_done; /* for vfork() */
71435 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71436 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71437 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71438 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71439
71440 cputime_t utime, stime, utimescaled, stimescaled;
71441 cputime_t gtime;
71442 @@ -1378,11 +1408,6 @@ struct task_struct {
71443 struct task_cputime cputime_expires;
71444 struct list_head cpu_timers[3];
71445
71446 -/* process credentials */
71447 - const struct cred __rcu *real_cred; /* objective and real subjective task
71448 - * credentials (COW) */
71449 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71450 - * credentials (COW) */
71451 char comm[TASK_COMM_LEN]; /* executable name excluding path
71452 - access with [gs]et_task_comm (which lock
71453 it with task_lock())
71454 @@ -1399,6 +1424,10 @@ struct task_struct {
71455 #endif
71456 /* CPU-specific state of this task */
71457 struct thread_struct thread;
71458 +/* thread_info moved to task_struct */
71459 +#ifdef CONFIG_X86
71460 + struct thread_info tinfo;
71461 +#endif
71462 /* filesystem information */
71463 struct fs_struct *fs;
71464 /* open file information */
71465 @@ -1472,6 +1501,10 @@ struct task_struct {
71466 gfp_t lockdep_reclaim_gfp;
71467 #endif
71468
71469 +/* process credentials */
71470 + const struct cred __rcu *real_cred; /* objective and real subjective task
71471 + * credentials (COW) */
71472 +
71473 /* journalling filesystem info */
71474 void *journal_info;
71475
71476 @@ -1510,6 +1543,10 @@ struct task_struct {
71477 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71478 struct list_head cg_list;
71479 #endif
71480 +
71481 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71482 + * credentials (COW) */
71483 +
71484 #ifdef CONFIG_FUTEX
71485 struct robust_list_head __user *robust_list;
71486 #ifdef CONFIG_COMPAT
71487 @@ -1606,8 +1643,74 @@ struct task_struct {
71488 #ifdef CONFIG_UPROBES
71489 struct uprobe_task *utask;
71490 #endif
71491 +
71492 +#ifdef CONFIG_GRKERNSEC
71493 + /* grsecurity */
71494 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71495 + u64 exec_id;
71496 +#endif
71497 +#ifdef CONFIG_GRKERNSEC_SETXID
71498 + const struct cred *delayed_cred;
71499 +#endif
71500 + struct dentry *gr_chroot_dentry;
71501 + struct acl_subject_label *acl;
71502 + struct acl_role_label *role;
71503 + struct file *exec_file;
71504 + unsigned long brute_expires;
71505 + u16 acl_role_id;
71506 + /* is this the task that authenticated to the special role */
71507 + u8 acl_sp_role;
71508 + u8 is_writable;
71509 + u8 brute;
71510 + u8 gr_is_chrooted;
71511 +#endif
71512 +
71513 };
71514
71515 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71516 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71517 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71518 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71519 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71520 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71521 +
71522 +#ifdef CONFIG_PAX_SOFTMODE
71523 +extern int pax_softmode;
71524 +#endif
71525 +
71526 +extern int pax_check_flags(unsigned long *);
71527 +
71528 +/* if tsk != current then task_lock must be held on it */
71529 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71530 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71531 +{
71532 + if (likely(tsk->mm))
71533 + return tsk->mm->pax_flags;
71534 + else
71535 + return 0UL;
71536 +}
71537 +
71538 +/* if tsk != current then task_lock must be held on it */
71539 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71540 +{
71541 + if (likely(tsk->mm)) {
71542 + tsk->mm->pax_flags = flags;
71543 + return 0;
71544 + }
71545 + return -EINVAL;
71546 +}
71547 +#endif
71548 +
71549 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71550 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71551 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71552 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71553 +#endif
71554 +
71555 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71556 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71557 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71558 +
71559 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71560 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71561
71562 @@ -1697,7 +1800,7 @@ struct pid_namespace;
71563 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71564 struct pid_namespace *ns);
71565
71566 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71567 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71568 {
71569 return tsk->pid;
71570 }
71571 @@ -2156,7 +2259,9 @@ void yield(void);
71572 extern struct exec_domain default_exec_domain;
71573
71574 union thread_union {
71575 +#ifndef CONFIG_X86
71576 struct thread_info thread_info;
71577 +#endif
71578 unsigned long stack[THREAD_SIZE/sizeof(long)];
71579 };
71580
71581 @@ -2189,6 +2294,7 @@ extern struct pid_namespace init_pid_ns;
71582 */
71583
71584 extern struct task_struct *find_task_by_vpid(pid_t nr);
71585 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71586 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71587 struct pid_namespace *ns);
71588
71589 @@ -2345,7 +2451,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71590 extern void exit_itimers(struct signal_struct *);
71591 extern void flush_itimer_signals(void);
71592
71593 -extern void do_group_exit(int);
71594 +extern __noreturn void do_group_exit(int);
71595
71596 extern int allow_signal(int);
71597 extern int disallow_signal(int);
71598 @@ -2536,9 +2642,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71599
71600 #endif
71601
71602 -static inline int object_is_on_stack(void *obj)
71603 +static inline int object_starts_on_stack(void *obj)
71604 {
71605 - void *stack = task_stack_page(current);
71606 + const void *stack = task_stack_page(current);
71607
71608 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71609 }
71610 diff --git a/include/linux/security.h b/include/linux/security.h
71611 index eee7478..290f7ba 100644
71612 --- a/include/linux/security.h
71613 +++ b/include/linux/security.h
71614 @@ -26,6 +26,7 @@
71615 #include <linux/capability.h>
71616 #include <linux/slab.h>
71617 #include <linux/err.h>
71618 +#include <linux/grsecurity.h>
71619
71620 struct linux_binprm;
71621 struct cred;
71622 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71623 index 68a04a3..866e6a1 100644
71624 --- a/include/linux/seq_file.h
71625 +++ b/include/linux/seq_file.h
71626 @@ -26,6 +26,9 @@ struct seq_file {
71627 struct mutex lock;
71628 const struct seq_operations *op;
71629 int poll_event;
71630 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71631 + u64 exec_id;
71632 +#endif
71633 #ifdef CONFIG_USER_NS
71634 struct user_namespace *user_ns;
71635 #endif
71636 @@ -38,6 +41,7 @@ struct seq_operations {
71637 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71638 int (*show) (struct seq_file *m, void *v);
71639 };
71640 +typedef struct seq_operations __no_const seq_operations_no_const;
71641
71642 #define SEQ_SKIP 1
71643
71644 diff --git a/include/linux/shm.h b/include/linux/shm.h
71645 index 429c199..4d42e38 100644
71646 --- a/include/linux/shm.h
71647 +++ b/include/linux/shm.h
71648 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71649
71650 /* The task created the shm object. NULL if the task is dead. */
71651 struct task_struct *shm_creator;
71652 +#ifdef CONFIG_GRKERNSEC
71653 + time_t shm_createtime;
71654 + pid_t shm_lapid;
71655 +#endif
71656 };
71657
71658 /* shm_mode upper byte flags */
71659 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71660 index 9fe54b6..a9de68d 100644
71661 --- a/include/linux/skbuff.h
71662 +++ b/include/linux/skbuff.h
71663 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71664 extern struct sk_buff *__alloc_skb(unsigned int size,
71665 gfp_t priority, int flags, int node);
71666 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71667 -static inline struct sk_buff *alloc_skb(unsigned int size,
71668 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71669 gfp_t priority)
71670 {
71671 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71672 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71673 */
71674 static inline int skb_queue_empty(const struct sk_buff_head *list)
71675 {
71676 - return list->next == (struct sk_buff *)list;
71677 + return list->next == (const struct sk_buff *)list;
71678 }
71679
71680 /**
71681 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71682 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71683 const struct sk_buff *skb)
71684 {
71685 - return skb->next == (struct sk_buff *)list;
71686 + return skb->next == (const struct sk_buff *)list;
71687 }
71688
71689 /**
71690 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71691 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71692 const struct sk_buff *skb)
71693 {
71694 - return skb->prev == (struct sk_buff *)list;
71695 + return skb->prev == (const struct sk_buff *)list;
71696 }
71697
71698 /**
71699 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71700 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71701 */
71702 #ifndef NET_SKB_PAD
71703 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71704 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71705 #endif
71706
71707 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71708 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71709 int noblock, int *err);
71710 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71711 struct poll_table_struct *wait);
71712 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71713 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71714 int offset, struct iovec *to,
71715 int size);
71716 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71717 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71718 nf_bridge_put(skb->nf_bridge);
71719 skb->nf_bridge = NULL;
71720 #endif
71721 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71722 + skb->nf_trace = 0;
71723 +#endif
71724 }
71725
71726 static inline void nf_reset_trace(struct sk_buff *skb)
71727 diff --git a/include/linux/slab.h b/include/linux/slab.h
71728 index 5d168d7..720bff3 100644
71729 --- a/include/linux/slab.h
71730 +++ b/include/linux/slab.h
71731 @@ -12,13 +12,20 @@
71732 #include <linux/gfp.h>
71733 #include <linux/types.h>
71734 #include <linux/workqueue.h>
71735 -
71736 +#include <linux/err.h>
71737
71738 /*
71739 * Flags to pass to kmem_cache_create().
71740 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71741 */
71742 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71743 +
71744 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71745 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71746 +#else
71747 +#define SLAB_USERCOPY 0x00000000UL
71748 +#endif
71749 +
71750 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71751 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71752 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71753 @@ -89,10 +96,13 @@
71754 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71755 * Both make kfree a no-op.
71756 */
71757 -#define ZERO_SIZE_PTR ((void *)16)
71758 +#define ZERO_SIZE_PTR \
71759 +({ \
71760 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71761 + (void *)(-MAX_ERRNO-1L); \
71762 +})
71763
71764 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71765 - (unsigned long)ZERO_SIZE_PTR)
71766 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71767
71768 /*
71769 * Common fields provided in kmem_cache by all slab allocators
71770 @@ -112,7 +122,7 @@ struct kmem_cache {
71771 unsigned int align; /* Alignment as calculated */
71772 unsigned long flags; /* Active flags on the slab */
71773 const char *name; /* Slab name for sysfs */
71774 - int refcount; /* Use counter */
71775 + atomic_t refcount; /* Use counter */
71776 void (*ctor)(void *); /* Called on object slot creation */
71777 struct list_head list; /* List of all slab caches on the system */
71778 };
71779 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71780 void kfree(const void *);
71781 void kzfree(const void *);
71782 size_t ksize(const void *);
71783 +const char *check_heap_object(const void *ptr, unsigned long n);
71784 +bool is_usercopy_object(const void *ptr);
71785
71786 /*
71787 * Allocator specific definitions. These are mainly used to establish optimized
71788 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71789 * for general use, and so are not documented here. For a full list of
71790 * potential flags, always refer to linux/gfp.h.
71791 */
71792 +
71793 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71794 {
71795 if (size != 0 && n > SIZE_MAX / size)
71796 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71797 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71798 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71799 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71800 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71801 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71802 #define kmalloc_track_caller(size, flags) \
71803 __kmalloc_track_caller(size, flags, _RET_IP_)
71804 #else
71805 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71806 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71807 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71808 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71809 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71810 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71811 #define kmalloc_node_track_caller(size, flags, node) \
71812 __kmalloc_node_track_caller(size, flags, node, \
71813 _RET_IP_)
71814 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71815 index 8bb6e0e..8eb0dbe 100644
71816 --- a/include/linux/slab_def.h
71817 +++ b/include/linux/slab_def.h
71818 @@ -52,7 +52,7 @@ struct kmem_cache {
71819 /* 4) cache creation/removal */
71820 const char *name;
71821 struct list_head list;
71822 - int refcount;
71823 + atomic_t refcount;
71824 int object_size;
71825 int align;
71826
71827 @@ -68,10 +68,10 @@ struct kmem_cache {
71828 unsigned long node_allocs;
71829 unsigned long node_frees;
71830 unsigned long node_overflow;
71831 - atomic_t allochit;
71832 - atomic_t allocmiss;
71833 - atomic_t freehit;
71834 - atomic_t freemiss;
71835 + atomic_unchecked_t allochit;
71836 + atomic_unchecked_t allocmiss;
71837 + atomic_unchecked_t freehit;
71838 + atomic_unchecked_t freemiss;
71839
71840 /*
71841 * If debugging is enabled, then the allocator can add additional
71842 @@ -111,11 +111,16 @@ struct cache_sizes {
71843 #ifdef CONFIG_ZONE_DMA
71844 struct kmem_cache *cs_dmacachep;
71845 #endif
71846 +
71847 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71848 + struct kmem_cache *cs_usercopycachep;
71849 +#endif
71850 +
71851 };
71852 extern struct cache_sizes malloc_sizes[];
71853
71854 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71855 -void *__kmalloc(size_t size, gfp_t flags);
71856 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71857
71858 #ifdef CONFIG_TRACING
71859 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71860 @@ -152,6 +157,13 @@ found:
71861 cachep = malloc_sizes[i].cs_dmacachep;
71862 else
71863 #endif
71864 +
71865 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71866 + if (flags & GFP_USERCOPY)
71867 + cachep = malloc_sizes[i].cs_usercopycachep;
71868 + else
71869 +#endif
71870 +
71871 cachep = malloc_sizes[i].cs_cachep;
71872
71873 ret = kmem_cache_alloc_trace(cachep, flags, size);
71874 @@ -162,7 +174,7 @@ found:
71875 }
71876
71877 #ifdef CONFIG_NUMA
71878 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71879 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71880 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71881
71882 #ifdef CONFIG_TRACING
71883 @@ -205,6 +217,13 @@ found:
71884 cachep = malloc_sizes[i].cs_dmacachep;
71885 else
71886 #endif
71887 +
71888 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71889 + if (flags & GFP_USERCOPY)
71890 + cachep = malloc_sizes[i].cs_usercopycachep;
71891 + else
71892 +#endif
71893 +
71894 cachep = malloc_sizes[i].cs_cachep;
71895
71896 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71897 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71898 index f28e14a..7831211 100644
71899 --- a/include/linux/slob_def.h
71900 +++ b/include/linux/slob_def.h
71901 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71902 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71903 }
71904
71905 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71906 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71907
71908 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71909 {
71910 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71911 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71912 }
71913
71914 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71915 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71916 {
71917 return kmalloc(size, flags);
71918 }
71919 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71920 index 9db4825..ed42fb5 100644
71921 --- a/include/linux/slub_def.h
71922 +++ b/include/linux/slub_def.h
71923 @@ -91,7 +91,7 @@ struct kmem_cache {
71924 struct kmem_cache_order_objects max;
71925 struct kmem_cache_order_objects min;
71926 gfp_t allocflags; /* gfp flags to use on each alloc */
71927 - int refcount; /* Refcount for slab cache destroy */
71928 + atomic_t refcount; /* Refcount for slab cache destroy */
71929 void (*ctor)(void *);
71930 int inuse; /* Offset to metadata */
71931 int align; /* Alignment */
71932 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71933 * Sorry that the following has to be that ugly but some versions of GCC
71934 * have trouble with constant propagation and loops.
71935 */
71936 -static __always_inline int kmalloc_index(size_t size)
71937 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71938 {
71939 if (!size)
71940 return 0;
71941 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71942 }
71943
71944 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71945 -void *__kmalloc(size_t size, gfp_t flags);
71946 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71947
71948 static __always_inline void *
71949 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71950 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71951 }
71952 #endif
71953
71954 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71955 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71956 {
71957 unsigned int order = get_order(size);
71958 return kmalloc_order_trace(size, flags, order);
71959 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71960 }
71961
71962 #ifdef CONFIG_NUMA
71963 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71964 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71965 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71966
71967 #ifdef CONFIG_TRACING
71968 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71969 index e8d702e..0a56eb4 100644
71970 --- a/include/linux/sock_diag.h
71971 +++ b/include/linux/sock_diag.h
71972 @@ -10,7 +10,7 @@ struct sock;
71973 struct sock_diag_handler {
71974 __u8 family;
71975 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71976 -};
71977 +} __do_const;
71978
71979 int sock_diag_register(const struct sock_diag_handler *h);
71980 void sock_diag_unregister(const struct sock_diag_handler *h);
71981 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71982 index 680f9a3..f13aeb0 100644
71983 --- a/include/linux/sonet.h
71984 +++ b/include/linux/sonet.h
71985 @@ -7,7 +7,7 @@
71986 #include <uapi/linux/sonet.h>
71987
71988 struct k_sonet_stats {
71989 -#define __HANDLE_ITEM(i) atomic_t i
71990 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71991 __SONET_ITEMS
71992 #undef __HANDLE_ITEM
71993 };
71994 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71995 index 34206b8..3db7f1c 100644
71996 --- a/include/linux/sunrpc/clnt.h
71997 +++ b/include/linux/sunrpc/clnt.h
71998 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71999 unsigned int p_timer; /* Which RTT timer to use */
72000 u32 p_statidx; /* Which procedure to account */
72001 const char * p_name; /* name of procedure */
72002 -};
72003 +} __do_const;
72004
72005 #ifdef __KERNEL__
72006
72007 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72008 {
72009 switch (sap->sa_family) {
72010 case AF_INET:
72011 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72012 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72013 case AF_INET6:
72014 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72015 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72016 }
72017 return 0;
72018 }
72019 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72020 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72021 const struct sockaddr *src)
72022 {
72023 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72024 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72025 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72026
72027 dsin->sin_family = ssin->sin_family;
72028 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72029 if (sa->sa_family != AF_INET6)
72030 return 0;
72031
72032 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72033 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72034 }
72035
72036 #endif /* __KERNEL__ */
72037 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72038 index 676ddf5..4c519a1 100644
72039 --- a/include/linux/sunrpc/svc.h
72040 +++ b/include/linux/sunrpc/svc.h
72041 @@ -410,7 +410,7 @@ struct svc_procedure {
72042 unsigned int pc_count; /* call count */
72043 unsigned int pc_cachetype; /* cache info (NFS) */
72044 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72045 -};
72046 +} __do_const;
72047
72048 /*
72049 * Function prototypes.
72050 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72051 index 0b8e3e6..33e0a01 100644
72052 --- a/include/linux/sunrpc/svc_rdma.h
72053 +++ b/include/linux/sunrpc/svc_rdma.h
72054 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72055 extern unsigned int svcrdma_max_requests;
72056 extern unsigned int svcrdma_max_req_size;
72057
72058 -extern atomic_t rdma_stat_recv;
72059 -extern atomic_t rdma_stat_read;
72060 -extern atomic_t rdma_stat_write;
72061 -extern atomic_t rdma_stat_sq_starve;
72062 -extern atomic_t rdma_stat_rq_starve;
72063 -extern atomic_t rdma_stat_rq_poll;
72064 -extern atomic_t rdma_stat_rq_prod;
72065 -extern atomic_t rdma_stat_sq_poll;
72066 -extern atomic_t rdma_stat_sq_prod;
72067 +extern atomic_unchecked_t rdma_stat_recv;
72068 +extern atomic_unchecked_t rdma_stat_read;
72069 +extern atomic_unchecked_t rdma_stat_write;
72070 +extern atomic_unchecked_t rdma_stat_sq_starve;
72071 +extern atomic_unchecked_t rdma_stat_rq_starve;
72072 +extern atomic_unchecked_t rdma_stat_rq_poll;
72073 +extern atomic_unchecked_t rdma_stat_rq_prod;
72074 +extern atomic_unchecked_t rdma_stat_sq_poll;
72075 +extern atomic_unchecked_t rdma_stat_sq_prod;
72076
72077 #define RPCRDMA_VERSION 1
72078
72079 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72080 index dd74084a..7f509d5 100644
72081 --- a/include/linux/sunrpc/svcauth.h
72082 +++ b/include/linux/sunrpc/svcauth.h
72083 @@ -109,7 +109,7 @@ struct auth_ops {
72084 int (*release)(struct svc_rqst *rq);
72085 void (*domain_release)(struct auth_domain *);
72086 int (*set_client)(struct svc_rqst *rq);
72087 -};
72088 +} __do_const;
72089
72090 #define SVC_GARBAGE 1
72091 #define SVC_SYSERR 2
72092 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72093 index 071d62c..4ccc7ac 100644
72094 --- a/include/linux/swiotlb.h
72095 +++ b/include/linux/swiotlb.h
72096 @@ -59,7 +59,8 @@ extern void
72097
72098 extern void
72099 swiotlb_free_coherent(struct device *hwdev, size_t size,
72100 - void *vaddr, dma_addr_t dma_handle);
72101 + void *vaddr, dma_addr_t dma_handle,
72102 + struct dma_attrs *attrs);
72103
72104 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72105 unsigned long offset, size_t size,
72106 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72107 index 45e2db2..1635156a 100644
72108 --- a/include/linux/syscalls.h
72109 +++ b/include/linux/syscalls.h
72110 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72111 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72112 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72113 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72114 - struct sockaddr __user *, int);
72115 + struct sockaddr __user *, int) __intentional_overflow(0);
72116 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72117 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72118 unsigned int vlen, unsigned flags);
72119 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72120 index 27b3b0b..e093dd9 100644
72121 --- a/include/linux/syscore_ops.h
72122 +++ b/include/linux/syscore_ops.h
72123 @@ -16,7 +16,7 @@ struct syscore_ops {
72124 int (*suspend)(void);
72125 void (*resume)(void);
72126 void (*shutdown)(void);
72127 -};
72128 +} __do_const;
72129
72130 extern void register_syscore_ops(struct syscore_ops *ops);
72131 extern void unregister_syscore_ops(struct syscore_ops *ops);
72132 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72133 index 14a8ff2..af52bad 100644
72134 --- a/include/linux/sysctl.h
72135 +++ b/include/linux/sysctl.h
72136 @@ -34,13 +34,13 @@ struct ctl_table_root;
72137 struct ctl_table_header;
72138 struct ctl_dir;
72139
72140 -typedef struct ctl_table ctl_table;
72141 -
72142 typedef int proc_handler (struct ctl_table *ctl, int write,
72143 void __user *buffer, size_t *lenp, loff_t *ppos);
72144
72145 extern int proc_dostring(struct ctl_table *, int,
72146 void __user *, size_t *, loff_t *);
72147 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72148 + void __user *, size_t *, loff_t *);
72149 extern int proc_dointvec(struct ctl_table *, int,
72150 void __user *, size_t *, loff_t *);
72151 extern int proc_dointvec_minmax(struct ctl_table *, int,
72152 @@ -115,7 +115,9 @@ struct ctl_table
72153 struct ctl_table_poll *poll;
72154 void *extra1;
72155 void *extra2;
72156 -};
72157 +} __do_const;
72158 +typedef struct ctl_table __no_const ctl_table_no_const;
72159 +typedef struct ctl_table ctl_table;
72160
72161 struct ctl_node {
72162 struct rb_node node;
72163 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72164 index 381f06d..dc16cc7 100644
72165 --- a/include/linux/sysfs.h
72166 +++ b/include/linux/sysfs.h
72167 @@ -31,7 +31,8 @@ struct attribute {
72168 struct lock_class_key *key;
72169 struct lock_class_key skey;
72170 #endif
72171 -};
72172 +} __do_const;
72173 +typedef struct attribute __no_const attribute_no_const;
72174
72175 /**
72176 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72177 @@ -59,8 +60,8 @@ struct attribute_group {
72178 umode_t (*is_visible)(struct kobject *,
72179 struct attribute *, int);
72180 struct attribute **attrs;
72181 -};
72182 -
72183 +} __do_const;
72184 +typedef struct attribute_group __no_const attribute_group_no_const;
72185
72186
72187 /**
72188 @@ -107,7 +108,8 @@ struct bin_attribute {
72189 char *, loff_t, size_t);
72190 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72191 struct vm_area_struct *vma);
72192 -};
72193 +} __do_const;
72194 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72195
72196 /**
72197 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72198 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72199 index 7faf933..9b85a0c 100644
72200 --- a/include/linux/sysrq.h
72201 +++ b/include/linux/sysrq.h
72202 @@ -16,6 +16,7 @@
72203
72204 #include <linux/errno.h>
72205 #include <linux/types.h>
72206 +#include <linux/compiler.h>
72207
72208 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72209 #define SYSRQ_DEFAULT_ENABLE 1
72210 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72211 char *help_msg;
72212 char *action_msg;
72213 int enable_mask;
72214 -};
72215 +} __do_const;
72216
72217 #ifdef CONFIG_MAGIC_SYSRQ
72218
72219 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72220 index e7e0473..7989295 100644
72221 --- a/include/linux/thread_info.h
72222 +++ b/include/linux/thread_info.h
72223 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72224 #error "no set_restore_sigmask() provided and default one won't work"
72225 #endif
72226
72227 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72228 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72229 +{
72230 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72231 + if (!__builtin_constant_p(n))
72232 +#endif
72233 + __check_object_size(ptr, n, to_user);
72234 +}
72235 +
72236 #endif /* __KERNEL__ */
72237
72238 #endif /* _LINUX_THREAD_INFO_H */
72239 diff --git a/include/linux/tty.h b/include/linux/tty.h
72240 index 8db1b56..c16a040 100644
72241 --- a/include/linux/tty.h
72242 +++ b/include/linux/tty.h
72243 @@ -194,7 +194,7 @@ struct tty_port {
72244 const struct tty_port_operations *ops; /* Port operations */
72245 spinlock_t lock; /* Lock protecting tty field */
72246 int blocked_open; /* Waiting to open */
72247 - int count; /* Usage count */
72248 + atomic_t count; /* Usage count */
72249 wait_queue_head_t open_wait; /* Open waiters */
72250 wait_queue_head_t close_wait; /* Close waiters */
72251 wait_queue_head_t delta_msr_wait; /* Modem status change */
72252 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72253 struct tty_struct *tty, struct file *filp);
72254 static inline int tty_port_users(struct tty_port *port)
72255 {
72256 - return port->count + port->blocked_open;
72257 + return atomic_read(&port->count) + port->blocked_open;
72258 }
72259
72260 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72261 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72262 index dd976cf..e272742 100644
72263 --- a/include/linux/tty_driver.h
72264 +++ b/include/linux/tty_driver.h
72265 @@ -284,7 +284,7 @@ struct tty_operations {
72266 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72267 #endif
72268 const struct file_operations *proc_fops;
72269 -};
72270 +} __do_const;
72271
72272 struct tty_driver {
72273 int magic; /* magic number for this structure */
72274 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72275 index fb79dd8d..07d4773 100644
72276 --- a/include/linux/tty_ldisc.h
72277 +++ b/include/linux/tty_ldisc.h
72278 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72279
72280 struct module *owner;
72281
72282 - int refcount;
72283 + atomic_t refcount;
72284 };
72285
72286 struct tty_ldisc {
72287 diff --git a/include/linux/types.h b/include/linux/types.h
72288 index 4d118ba..c3ee9bf 100644
72289 --- a/include/linux/types.h
72290 +++ b/include/linux/types.h
72291 @@ -176,10 +176,26 @@ typedef struct {
72292 int counter;
72293 } atomic_t;
72294
72295 +#ifdef CONFIG_PAX_REFCOUNT
72296 +typedef struct {
72297 + int counter;
72298 +} atomic_unchecked_t;
72299 +#else
72300 +typedef atomic_t atomic_unchecked_t;
72301 +#endif
72302 +
72303 #ifdef CONFIG_64BIT
72304 typedef struct {
72305 long counter;
72306 } atomic64_t;
72307 +
72308 +#ifdef CONFIG_PAX_REFCOUNT
72309 +typedef struct {
72310 + long counter;
72311 +} atomic64_unchecked_t;
72312 +#else
72313 +typedef atomic64_t atomic64_unchecked_t;
72314 +#endif
72315 #endif
72316
72317 struct list_head {
72318 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72319 index 5ca0951..ab496a5 100644
72320 --- a/include/linux/uaccess.h
72321 +++ b/include/linux/uaccess.h
72322 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72323 long ret; \
72324 mm_segment_t old_fs = get_fs(); \
72325 \
72326 - set_fs(KERNEL_DS); \
72327 pagefault_disable(); \
72328 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72329 - pagefault_enable(); \
72330 + set_fs(KERNEL_DS); \
72331 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72332 set_fs(old_fs); \
72333 + pagefault_enable(); \
72334 ret; \
72335 })
72336
72337 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72338 index 8e522cbc..aa8572d 100644
72339 --- a/include/linux/uidgid.h
72340 +++ b/include/linux/uidgid.h
72341 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72342
72343 #endif /* CONFIG_USER_NS */
72344
72345 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72346 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72347 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72348 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72349 +
72350 #endif /* _LINUX_UIDGID_H */
72351 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72352 index 99c1b4d..562e6f3 100644
72353 --- a/include/linux/unaligned/access_ok.h
72354 +++ b/include/linux/unaligned/access_ok.h
72355 @@ -4,34 +4,34 @@
72356 #include <linux/kernel.h>
72357 #include <asm/byteorder.h>
72358
72359 -static inline u16 get_unaligned_le16(const void *p)
72360 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72361 {
72362 - return le16_to_cpup((__le16 *)p);
72363 + return le16_to_cpup((const __le16 *)p);
72364 }
72365
72366 -static inline u32 get_unaligned_le32(const void *p)
72367 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72368 {
72369 - return le32_to_cpup((__le32 *)p);
72370 + return le32_to_cpup((const __le32 *)p);
72371 }
72372
72373 -static inline u64 get_unaligned_le64(const void *p)
72374 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72375 {
72376 - return le64_to_cpup((__le64 *)p);
72377 + return le64_to_cpup((const __le64 *)p);
72378 }
72379
72380 -static inline u16 get_unaligned_be16(const void *p)
72381 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72382 {
72383 - return be16_to_cpup((__be16 *)p);
72384 + return be16_to_cpup((const __be16 *)p);
72385 }
72386
72387 -static inline u32 get_unaligned_be32(const void *p)
72388 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72389 {
72390 - return be32_to_cpup((__be32 *)p);
72391 + return be32_to_cpup((const __be32 *)p);
72392 }
72393
72394 -static inline u64 get_unaligned_be64(const void *p)
72395 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72396 {
72397 - return be64_to_cpup((__be64 *)p);
72398 + return be64_to_cpup((const __be64 *)p);
72399 }
72400
72401 static inline void put_unaligned_le16(u16 val, void *p)
72402 diff --git a/include/linux/usb.h b/include/linux/usb.h
72403 index 4d22d0f..8d0e8f8 100644
72404 --- a/include/linux/usb.h
72405 +++ b/include/linux/usb.h
72406 @@ -554,7 +554,7 @@ struct usb_device {
72407 int maxchild;
72408
72409 u32 quirks;
72410 - atomic_t urbnum;
72411 + atomic_unchecked_t urbnum;
72412
72413 unsigned long active_duration;
72414
72415 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72416
72417 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72418 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72419 - void *data, __u16 size, int timeout);
72420 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72421 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72422 void *data, int len, int *actual_length, int timeout);
72423 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72424 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72425 index c5d36c6..108f4f9 100644
72426 --- a/include/linux/usb/renesas_usbhs.h
72427 +++ b/include/linux/usb/renesas_usbhs.h
72428 @@ -39,7 +39,7 @@ enum {
72429 */
72430 struct renesas_usbhs_driver_callback {
72431 int (*notify_hotplug)(struct platform_device *pdev);
72432 -};
72433 +} __no_const;
72434
72435 /*
72436 * callback functions for platform
72437 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72438 index 5209cfe..b6b215f 100644
72439 --- a/include/linux/user_namespace.h
72440 +++ b/include/linux/user_namespace.h
72441 @@ -21,7 +21,7 @@ struct user_namespace {
72442 struct uid_gid_map uid_map;
72443 struct uid_gid_map gid_map;
72444 struct uid_gid_map projid_map;
72445 - struct kref kref;
72446 + atomic_t count;
72447 struct user_namespace *parent;
72448 kuid_t owner;
72449 kgid_t group;
72450 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72451 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72452 {
72453 if (ns)
72454 - kref_get(&ns->kref);
72455 + atomic_inc(&ns->count);
72456 return ns;
72457 }
72458
72459 extern int create_user_ns(struct cred *new);
72460 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72461 -extern void free_user_ns(struct kref *kref);
72462 +extern void free_user_ns(struct user_namespace *ns);
72463
72464 static inline void put_user_ns(struct user_namespace *ns)
72465 {
72466 - if (ns)
72467 - kref_put(&ns->kref, free_user_ns);
72468 + if (ns && atomic_dec_and_test(&ns->count))
72469 + free_user_ns(ns);
72470 }
72471
72472 struct seq_operations;
72473 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72474 index 6f8fbcf..8259001 100644
72475 --- a/include/linux/vermagic.h
72476 +++ b/include/linux/vermagic.h
72477 @@ -25,9 +25,35 @@
72478 #define MODULE_ARCH_VERMAGIC ""
72479 #endif
72480
72481 +#ifdef CONFIG_PAX_REFCOUNT
72482 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72483 +#else
72484 +#define MODULE_PAX_REFCOUNT ""
72485 +#endif
72486 +
72487 +#ifdef CONSTIFY_PLUGIN
72488 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72489 +#else
72490 +#define MODULE_CONSTIFY_PLUGIN ""
72491 +#endif
72492 +
72493 +#ifdef STACKLEAK_PLUGIN
72494 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72495 +#else
72496 +#define MODULE_STACKLEAK_PLUGIN ""
72497 +#endif
72498 +
72499 +#ifdef CONFIG_GRKERNSEC
72500 +#define MODULE_GRSEC "GRSEC "
72501 +#else
72502 +#define MODULE_GRSEC ""
72503 +#endif
72504 +
72505 #define VERMAGIC_STRING \
72506 UTS_RELEASE " " \
72507 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72508 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72509 - MODULE_ARCH_VERMAGIC
72510 + MODULE_ARCH_VERMAGIC \
72511 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72512 + MODULE_GRSEC
72513
72514 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72515 index 6071e91..ca6a489 100644
72516 --- a/include/linux/vmalloc.h
72517 +++ b/include/linux/vmalloc.h
72518 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72519 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72520 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72521 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72522 +
72523 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72524 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72525 +#endif
72526 +
72527 /* bits [20..32] reserved for arch specific ioremap internals */
72528
72529 /*
72530 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72531 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72532 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72533 unsigned long start, unsigned long end, gfp_t gfp_mask,
72534 - pgprot_t prot, int node, const void *caller);
72535 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72536 extern void vfree(const void *addr);
72537
72538 extern void *vmap(struct page **pages, unsigned int count,
72539 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72540 extern void free_vm_area(struct vm_struct *area);
72541
72542 /* for /dev/kmem */
72543 -extern long vread(char *buf, char *addr, unsigned long count);
72544 -extern long vwrite(char *buf, char *addr, unsigned long count);
72545 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72546 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72547
72548 /*
72549 * Internals. Dont't use..
72550 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72551 index a13291f..af51fa3 100644
72552 --- a/include/linux/vmstat.h
72553 +++ b/include/linux/vmstat.h
72554 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72555 /*
72556 * Zone based page accounting with per cpu differentials.
72557 */
72558 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72559 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72560
72561 static inline void zone_page_state_add(long x, struct zone *zone,
72562 enum zone_stat_item item)
72563 {
72564 - atomic_long_add(x, &zone->vm_stat[item]);
72565 - atomic_long_add(x, &vm_stat[item]);
72566 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72567 + atomic_long_add_unchecked(x, &vm_stat[item]);
72568 }
72569
72570 static inline unsigned long global_page_state(enum zone_stat_item item)
72571 {
72572 - long x = atomic_long_read(&vm_stat[item]);
72573 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72574 #ifdef CONFIG_SMP
72575 if (x < 0)
72576 x = 0;
72577 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72578 static inline unsigned long zone_page_state(struct zone *zone,
72579 enum zone_stat_item item)
72580 {
72581 - long x = atomic_long_read(&zone->vm_stat[item]);
72582 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72583 #ifdef CONFIG_SMP
72584 if (x < 0)
72585 x = 0;
72586 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72587 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72588 enum zone_stat_item item)
72589 {
72590 - long x = atomic_long_read(&zone->vm_stat[item]);
72591 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72592
72593 #ifdef CONFIG_SMP
72594 int cpu;
72595 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72596
72597 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72598 {
72599 - atomic_long_inc(&zone->vm_stat[item]);
72600 - atomic_long_inc(&vm_stat[item]);
72601 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72602 + atomic_long_inc_unchecked(&vm_stat[item]);
72603 }
72604
72605 static inline void __inc_zone_page_state(struct page *page,
72606 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72607
72608 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72609 {
72610 - atomic_long_dec(&zone->vm_stat[item]);
72611 - atomic_long_dec(&vm_stat[item]);
72612 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72613 + atomic_long_dec_unchecked(&vm_stat[item]);
72614 }
72615
72616 static inline void __dec_zone_page_state(struct page *page,
72617 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72618 index fdbafc6..b7ffd47 100644
72619 --- a/include/linux/xattr.h
72620 +++ b/include/linux/xattr.h
72621 @@ -28,7 +28,7 @@ struct xattr_handler {
72622 size_t size, int handler_flags);
72623 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72624 size_t size, int flags, int handler_flags);
72625 -};
72626 +} __do_const;
72627
72628 struct xattr {
72629 char *name;
72630 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72631 index 9c5a6b4..09c9438 100644
72632 --- a/include/linux/zlib.h
72633 +++ b/include/linux/zlib.h
72634 @@ -31,6 +31,7 @@
72635 #define _ZLIB_H
72636
72637 #include <linux/zconf.h>
72638 +#include <linux/compiler.h>
72639
72640 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72641 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72642 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72643
72644 /* basic functions */
72645
72646 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72647 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72648 /*
72649 Returns the number of bytes that needs to be allocated for a per-
72650 stream workspace with the specified parameters. A pointer to this
72651 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72652 index 95d1c91..6798cca 100644
72653 --- a/include/media/v4l2-dev.h
72654 +++ b/include/media/v4l2-dev.h
72655 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72656 int (*mmap) (struct file *, struct vm_area_struct *);
72657 int (*open) (struct file *);
72658 int (*release) (struct file *);
72659 -};
72660 +} __do_const;
72661
72662 /*
72663 * Newer version of video_device, handled by videodev2.c
72664 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72665 index 4118ad1..cb7e25f 100644
72666 --- a/include/media/v4l2-ioctl.h
72667 +++ b/include/media/v4l2-ioctl.h
72668 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72669 bool valid_prio, int cmd, void *arg);
72670 };
72671
72672 -
72673 /* v4l debugging and diagnostics */
72674
72675 /* Debug bitmask flags to be used on V4L2 */
72676 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72677 index adcbb20..62c2559 100644
72678 --- a/include/net/9p/transport.h
72679 +++ b/include/net/9p/transport.h
72680 @@ -57,7 +57,7 @@ struct p9_trans_module {
72681 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72682 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72683 char *, char *, int , int, int, int);
72684 -};
72685 +} __do_const;
72686
72687 void v9fs_register_trans(struct p9_trans_module *m);
72688 void v9fs_unregister_trans(struct p9_trans_module *m);
72689 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72690 index 7588ef4..e62d35f 100644
72691 --- a/include/net/bluetooth/l2cap.h
72692 +++ b/include/net/bluetooth/l2cap.h
72693 @@ -552,7 +552,7 @@ struct l2cap_ops {
72694 void (*defer) (struct l2cap_chan *chan);
72695 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72696 unsigned long len, int nb);
72697 -};
72698 +} __do_const;
72699
72700 struct l2cap_conn {
72701 struct hci_conn *hcon;
72702 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72703 index 9e5425b..8136ffc 100644
72704 --- a/include/net/caif/cfctrl.h
72705 +++ b/include/net/caif/cfctrl.h
72706 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72707 void (*radioset_rsp)(void);
72708 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72709 struct cflayer *client_layer);
72710 -};
72711 +} __no_const;
72712
72713 /* Link Setup Parameters for CAIF-Links. */
72714 struct cfctrl_link_param {
72715 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72716 struct cfctrl {
72717 struct cfsrvl serv;
72718 struct cfctrl_rsp res;
72719 - atomic_t req_seq_no;
72720 - atomic_t rsp_seq_no;
72721 + atomic_unchecked_t req_seq_no;
72722 + atomic_unchecked_t rsp_seq_no;
72723 struct list_head list;
72724 /* Protects from simultaneous access to first_req list */
72725 spinlock_t info_list_lock;
72726 diff --git a/include/net/flow.h b/include/net/flow.h
72727 index 628e11b..4c475df 100644
72728 --- a/include/net/flow.h
72729 +++ b/include/net/flow.h
72730 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72731
72732 extern void flow_cache_flush(void);
72733 extern void flow_cache_flush_deferred(void);
72734 -extern atomic_t flow_cache_genid;
72735 +extern atomic_unchecked_t flow_cache_genid;
72736
72737 #endif
72738 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72739 index bdfbe68..4402ebe 100644
72740 --- a/include/net/genetlink.h
72741 +++ b/include/net/genetlink.h
72742 @@ -118,7 +118,7 @@ struct genl_ops {
72743 struct netlink_callback *cb);
72744 int (*done)(struct netlink_callback *cb);
72745 struct list_head ops_list;
72746 -};
72747 +} __do_const;
72748
72749 extern int genl_register_family(struct genl_family *family);
72750 extern int genl_register_family_with_ops(struct genl_family *family,
72751 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72752 index e5062c9..48a9a4b 100644
72753 --- a/include/net/gro_cells.h
72754 +++ b/include/net/gro_cells.h
72755 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72756 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72757
72758 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72759 - atomic_long_inc(&dev->rx_dropped);
72760 + atomic_long_inc_unchecked(&dev->rx_dropped);
72761 kfree_skb(skb);
72762 return;
72763 }
72764 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72765 int i;
72766
72767 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72768 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72769 - gcells->gro_cells_mask + 1,
72770 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72771 + sizeof(struct gro_cell),
72772 GFP_KERNEL);
72773 if (!gcells->cells)
72774 return -ENOMEM;
72775 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72776 index 1832927..ce39aea 100644
72777 --- a/include/net/inet_connection_sock.h
72778 +++ b/include/net/inet_connection_sock.h
72779 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72780 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72781 int (*bind_conflict)(const struct sock *sk,
72782 const struct inet_bind_bucket *tb, bool relax);
72783 -};
72784 +} __do_const;
72785
72786 /** inet_connection_sock - INET connection oriented sock
72787 *
72788 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72789 index 53f464d..ba76aaa 100644
72790 --- a/include/net/inetpeer.h
72791 +++ b/include/net/inetpeer.h
72792 @@ -47,8 +47,8 @@ struct inet_peer {
72793 */
72794 union {
72795 struct {
72796 - atomic_t rid; /* Frag reception counter */
72797 - atomic_t ip_id_count; /* IP ID for the next packet */
72798 + atomic_unchecked_t rid; /* Frag reception counter */
72799 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72800 };
72801 struct rcu_head rcu;
72802 struct inet_peer *gc_next;
72803 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72804 more++;
72805 inet_peer_refcheck(p);
72806 do {
72807 - old = atomic_read(&p->ip_id_count);
72808 + old = atomic_read_unchecked(&p->ip_id_count);
72809 new = old + more;
72810 if (!new)
72811 new = 1;
72812 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72813 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72814 return new;
72815 }
72816
72817 diff --git a/include/net/ip.h b/include/net/ip.h
72818 index a68f838..74518ab 100644
72819 --- a/include/net/ip.h
72820 +++ b/include/net/ip.h
72821 @@ -202,7 +202,7 @@ extern struct local_ports {
72822 } sysctl_local_ports;
72823 extern void inet_get_local_port_range(int *low, int *high);
72824
72825 -extern unsigned long *sysctl_local_reserved_ports;
72826 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72827 static inline int inet_is_reserved_local_port(int port)
72828 {
72829 return test_bit(port, sysctl_local_reserved_ports);
72830 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72831 index e49db91..76a81de 100644
72832 --- a/include/net/ip_fib.h
72833 +++ b/include/net/ip_fib.h
72834 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72835
72836 #define FIB_RES_SADDR(net, res) \
72837 ((FIB_RES_NH(res).nh_saddr_genid == \
72838 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72839 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72840 FIB_RES_NH(res).nh_saddr : \
72841 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72842 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72843 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72844 index 68c69d5..bdab192 100644
72845 --- a/include/net/ip_vs.h
72846 +++ b/include/net/ip_vs.h
72847 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72848 struct ip_vs_conn *control; /* Master control connection */
72849 atomic_t n_control; /* Number of controlled ones */
72850 struct ip_vs_dest *dest; /* real server */
72851 - atomic_t in_pkts; /* incoming packet counter */
72852 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72853
72854 /* packet transmitter for different forwarding methods. If it
72855 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72856 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72857 __be16 port; /* port number of the server */
72858 union nf_inet_addr addr; /* IP address of the server */
72859 volatile unsigned int flags; /* dest status flags */
72860 - atomic_t conn_flags; /* flags to copy to conn */
72861 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72862 atomic_t weight; /* server weight */
72863
72864 atomic_t refcnt; /* reference counter */
72865 @@ -980,11 +980,11 @@ struct netns_ipvs {
72866 /* ip_vs_lblc */
72867 int sysctl_lblc_expiration;
72868 struct ctl_table_header *lblc_ctl_header;
72869 - struct ctl_table *lblc_ctl_table;
72870 + ctl_table_no_const *lblc_ctl_table;
72871 /* ip_vs_lblcr */
72872 int sysctl_lblcr_expiration;
72873 struct ctl_table_header *lblcr_ctl_header;
72874 - struct ctl_table *lblcr_ctl_table;
72875 + ctl_table_no_const *lblcr_ctl_table;
72876 /* ip_vs_est */
72877 struct list_head est_list; /* estimator list */
72878 spinlock_t est_lock;
72879 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72880 index 80ffde3..968b0f4 100644
72881 --- a/include/net/irda/ircomm_tty.h
72882 +++ b/include/net/irda/ircomm_tty.h
72883 @@ -35,6 +35,7 @@
72884 #include <linux/termios.h>
72885 #include <linux/timer.h>
72886 #include <linux/tty.h> /* struct tty_struct */
72887 +#include <asm/local.h>
72888
72889 #include <net/irda/irias_object.h>
72890 #include <net/irda/ircomm_core.h>
72891 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72892 index cc7c197..9f2da2a 100644
72893 --- a/include/net/iucv/af_iucv.h
72894 +++ b/include/net/iucv/af_iucv.h
72895 @@ -141,7 +141,7 @@ struct iucv_sock {
72896 struct iucv_sock_list {
72897 struct hlist_head head;
72898 rwlock_t lock;
72899 - atomic_t autobind_name;
72900 + atomic_unchecked_t autobind_name;
72901 };
72902
72903 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72904 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72905 index df83f69..9b640b8 100644
72906 --- a/include/net/llc_c_ac.h
72907 +++ b/include/net/llc_c_ac.h
72908 @@ -87,7 +87,7 @@
72909 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72910 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72911
72912 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72913 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72914
72915 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72916 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72917 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72918 index 6ca3113..f8026dd 100644
72919 --- a/include/net/llc_c_ev.h
72920 +++ b/include/net/llc_c_ev.h
72921 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72922 return (struct llc_conn_state_ev *)skb->cb;
72923 }
72924
72925 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72926 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72927 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72928 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72929
72930 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72931 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72932 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72933 index 0e79cfb..f46db31 100644
72934 --- a/include/net/llc_c_st.h
72935 +++ b/include/net/llc_c_st.h
72936 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72937 u8 next_state;
72938 llc_conn_ev_qfyr_t *ev_qualifiers;
72939 llc_conn_action_t *ev_actions;
72940 -};
72941 +} __do_const;
72942
72943 struct llc_conn_state {
72944 u8 current_state;
72945 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72946 index 37a3bbd..55a4241 100644
72947 --- a/include/net/llc_s_ac.h
72948 +++ b/include/net/llc_s_ac.h
72949 @@ -23,7 +23,7 @@
72950 #define SAP_ACT_TEST_IND 9
72951
72952 /* All action functions must look like this */
72953 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72954 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72955
72956 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72957 struct sk_buff *skb);
72958 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72959 index 567c681..cd73ac0 100644
72960 --- a/include/net/llc_s_st.h
72961 +++ b/include/net/llc_s_st.h
72962 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72963 llc_sap_ev_t ev;
72964 u8 next_state;
72965 llc_sap_action_t *ev_actions;
72966 -};
72967 +} __do_const;
72968
72969 struct llc_sap_state {
72970 u8 curr_state;
72971 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72972 index ee50c5e..1bc3b1a 100644
72973 --- a/include/net/mac80211.h
72974 +++ b/include/net/mac80211.h
72975 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72976 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72977 struct dentry *dir);
72978 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72979 -};
72980 +} __do_const;
72981
72982 static inline int rate_supported(struct ieee80211_sta *sta,
72983 enum ieee80211_band band,
72984 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72985 index 0dab173..1b76af0 100644
72986 --- a/include/net/neighbour.h
72987 +++ b/include/net/neighbour.h
72988 @@ -123,7 +123,7 @@ struct neigh_ops {
72989 void (*error_report)(struct neighbour *, struct sk_buff *);
72990 int (*output)(struct neighbour *, struct sk_buff *);
72991 int (*connected_output)(struct neighbour *, struct sk_buff *);
72992 -};
72993 +} __do_const;
72994
72995 struct pneigh_entry {
72996 struct pneigh_entry *next;
72997 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72998 index de644bc..dfbcc4c 100644
72999 --- a/include/net/net_namespace.h
73000 +++ b/include/net/net_namespace.h
73001 @@ -115,7 +115,7 @@ struct net {
73002 #endif
73003 struct netns_ipvs *ipvs;
73004 struct sock *diag_nlsk;
73005 - atomic_t rt_genid;
73006 + atomic_unchecked_t rt_genid;
73007 };
73008
73009 /*
73010 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73011 #define __net_init __init
73012 #define __net_exit __exit_refok
73013 #define __net_initdata __initdata
73014 +#ifdef CONSTIFY_PLUGIN
73015 #define __net_initconst __initconst
73016 +#else
73017 +#define __net_initconst __initdata
73018 +#endif
73019 #endif
73020
73021 struct pernet_operations {
73022 @@ -282,7 +286,7 @@ struct pernet_operations {
73023 void (*exit_batch)(struct list_head *net_exit_list);
73024 int *id;
73025 size_t size;
73026 -};
73027 +} __do_const;
73028
73029 /*
73030 * Use these carefully. If you implement a network device and it
73031 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73032
73033 static inline int rt_genid(struct net *net)
73034 {
73035 - return atomic_read(&net->rt_genid);
73036 + return atomic_read_unchecked(&net->rt_genid);
73037 }
73038
73039 static inline void rt_genid_bump(struct net *net)
73040 {
73041 - atomic_inc(&net->rt_genid);
73042 + atomic_inc_unchecked(&net->rt_genid);
73043 }
73044
73045 #endif /* __NET_NET_NAMESPACE_H */
73046 diff --git a/include/net/netdma.h b/include/net/netdma.h
73047 index 8ba8ce2..99b7fff 100644
73048 --- a/include/net/netdma.h
73049 +++ b/include/net/netdma.h
73050 @@ -24,7 +24,7 @@
73051 #include <linux/dmaengine.h>
73052 #include <linux/skbuff.h>
73053
73054 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73055 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73056 struct sk_buff *skb, int offset, struct iovec *to,
73057 size_t len, struct dma_pinned_list *pinned_list);
73058
73059 diff --git a/include/net/netlink.h b/include/net/netlink.h
73060 index 9690b0f..87aded7 100644
73061 --- a/include/net/netlink.h
73062 +++ b/include/net/netlink.h
73063 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73064 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73065 {
73066 if (mark)
73067 - skb_trim(skb, (unsigned char *) mark - skb->data);
73068 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73069 }
73070
73071 /**
73072 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73073 index 923cb20..deae816 100644
73074 --- a/include/net/netns/conntrack.h
73075 +++ b/include/net/netns/conntrack.h
73076 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73077 struct nf_proto_net {
73078 #ifdef CONFIG_SYSCTL
73079 struct ctl_table_header *ctl_table_header;
73080 - struct ctl_table *ctl_table;
73081 + ctl_table_no_const *ctl_table;
73082 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73083 struct ctl_table_header *ctl_compat_header;
73084 - struct ctl_table *ctl_compat_table;
73085 + ctl_table_no_const *ctl_compat_table;
73086 #endif
73087 #endif
73088 unsigned int users;
73089 @@ -58,7 +58,7 @@ struct nf_ip_net {
73090 struct nf_icmp_net icmpv6;
73091 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73092 struct ctl_table_header *ctl_table_header;
73093 - struct ctl_table *ctl_table;
73094 + ctl_table_no_const *ctl_table;
73095 #endif
73096 };
73097
73098 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73099 index 2ae2b83..dbdc85e 100644
73100 --- a/include/net/netns/ipv4.h
73101 +++ b/include/net/netns/ipv4.h
73102 @@ -64,7 +64,7 @@ struct netns_ipv4 {
73103 kgid_t sysctl_ping_group_range[2];
73104 long sysctl_tcp_mem[3];
73105
73106 - atomic_t dev_addr_genid;
73107 + atomic_unchecked_t dev_addr_genid;
73108
73109 #ifdef CONFIG_IP_MROUTE
73110 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73111 diff --git a/include/net/protocol.h b/include/net/protocol.h
73112 index 047c047..b9dad15 100644
73113 --- a/include/net/protocol.h
73114 +++ b/include/net/protocol.h
73115 @@ -44,7 +44,7 @@ struct net_protocol {
73116 void (*err_handler)(struct sk_buff *skb, u32 info);
73117 unsigned int no_policy:1,
73118 netns_ok:1;
73119 -};
73120 +} __do_const;
73121
73122 #if IS_ENABLED(CONFIG_IPV6)
73123 struct inet6_protocol {
73124 @@ -57,7 +57,7 @@ struct inet6_protocol {
73125 u8 type, u8 code, int offset,
73126 __be32 info);
73127 unsigned int flags; /* INET6_PROTO_xxx */
73128 -};
73129 +} __do_const;
73130
73131 #define INET6_PROTO_NOPOLICY 0x1
73132 #define INET6_PROTO_FINAL 0x2
73133 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73134 index 5a15fab..d799ea7 100644
73135 --- a/include/net/rtnetlink.h
73136 +++ b/include/net/rtnetlink.h
73137 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73138 const struct net_device *dev);
73139 unsigned int (*get_num_tx_queues)(void);
73140 unsigned int (*get_num_rx_queues)(void);
73141 -};
73142 +} __do_const;
73143
73144 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73145 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73146 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73147 index 7fdf298..197e9f7 100644
73148 --- a/include/net/sctp/sctp.h
73149 +++ b/include/net/sctp/sctp.h
73150 @@ -330,9 +330,9 @@ do { \
73151
73152 #else /* SCTP_DEBUG */
73153
73154 -#define SCTP_DEBUG_PRINTK(whatever...)
73155 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73156 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73157 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73158 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73159 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73160 #define SCTP_ENABLE_DEBUG
73161 #define SCTP_DISABLE_DEBUG
73162 #define SCTP_ASSERT(expr, str, func)
73163 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73164 index 2a82d13..62a31c2 100644
73165 --- a/include/net/sctp/sm.h
73166 +++ b/include/net/sctp/sm.h
73167 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73168 typedef struct {
73169 sctp_state_fn_t *fn;
73170 const char *name;
73171 -} sctp_sm_table_entry_t;
73172 +} __do_const sctp_sm_table_entry_t;
73173
73174 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73175 * currently in use.
73176 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73177 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73178
73179 /* Extern declarations for major data structures. */
73180 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73181 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73182
73183
73184 /* Get the size of a DATA chunk payload. */
73185 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73186 index fdeb85a..1329d95 100644
73187 --- a/include/net/sctp/structs.h
73188 +++ b/include/net/sctp/structs.h
73189 @@ -517,7 +517,7 @@ struct sctp_pf {
73190 struct sctp_association *asoc);
73191 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73192 struct sctp_af *af;
73193 -};
73194 +} __do_const;
73195
73196
73197 /* Structure to track chunk fragments that have been acked, but peer
73198 diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h
73199 index c2e542b..6ca975b 100644
73200 --- a/include/net/secure_seq.h
73201 +++ b/include/net/secure_seq.h
73202 @@ -3,6 +3,7 @@
73203
73204 #include <linux/types.h>
73205
73206 +extern void net_secret_init(void);
73207 extern __u32 secure_ip_id(__be32 daddr);
73208 extern __u32 secure_ipv6_id(const __be32 daddr[4]);
73209 extern u32 secure_ipv4_port_ephemeral(__be32 saddr, __be32 daddr, __be16 dport);
73210 diff --git a/include/net/sock.h b/include/net/sock.h
73211 index 25afaa0..8bb0070 100644
73212 --- a/include/net/sock.h
73213 +++ b/include/net/sock.h
73214 @@ -322,7 +322,7 @@ struct sock {
73215 #ifdef CONFIG_RPS
73216 __u32 sk_rxhash;
73217 #endif
73218 - atomic_t sk_drops;
73219 + atomic_unchecked_t sk_drops;
73220 int sk_rcvbuf;
73221
73222 struct sk_filter __rcu *sk_filter;
73223 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73224 }
73225
73226 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73227 - char __user *from, char *to,
73228 + char __user *from, unsigned char *to,
73229 int copy, int offset)
73230 {
73231 if (skb->ip_summed == CHECKSUM_NONE) {
73232 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73233 }
73234 }
73235
73236 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73237 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73238
73239 /**
73240 * sk_page_frag - return an appropriate page_frag
73241 diff --git a/include/net/tcp.h b/include/net/tcp.h
73242 index aed42c7..43890c6 100644
73243 --- a/include/net/tcp.h
73244 +++ b/include/net/tcp.h
73245 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73246 extern void tcp_xmit_retransmit_queue(struct sock *);
73247 extern void tcp_simple_retransmit(struct sock *);
73248 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73249 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73250 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73251
73252 extern void tcp_send_probe0(struct sock *);
73253 extern void tcp_send_partial(struct sock *);
73254 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73255 struct inet6_skb_parm h6;
73256 #endif
73257 } header; /* For incoming frames */
73258 - __u32 seq; /* Starting sequence number */
73259 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73260 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73261 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73262 __u32 when; /* used to compute rtt's */
73263 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73264
73265 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73266
73267 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73268 /* 1 byte hole */
73269 - __u32 ack_seq; /* Sequence number ACK'd */
73270 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73271 };
73272
73273 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73274 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73275 index 63445ed..d6fc34f 100644
73276 --- a/include/net/xfrm.h
73277 +++ b/include/net/xfrm.h
73278 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73279 struct net_device *dev,
73280 const struct flowi *fl);
73281 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73282 -};
73283 +} __do_const;
73284
73285 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73286 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73287 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73288 struct sk_buff *skb);
73289 int (*transport_finish)(struct sk_buff *skb,
73290 int async);
73291 -};
73292 +} __do_const;
73293
73294 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73295 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73296 @@ -423,7 +423,7 @@ struct xfrm_mode {
73297 struct module *owner;
73298 unsigned int encap;
73299 int flags;
73300 -};
73301 +} __do_const;
73302
73303 /* Flags for xfrm_mode. */
73304 enum {
73305 @@ -514,7 +514,7 @@ struct xfrm_policy {
73306 struct timer_list timer;
73307
73308 struct flow_cache_object flo;
73309 - atomic_t genid;
73310 + atomic_unchecked_t genid;
73311 u32 priority;
73312 u32 index;
73313 struct xfrm_mark mark;
73314 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73315 index 1a046b1..ee0bef0 100644
73316 --- a/include/rdma/iw_cm.h
73317 +++ b/include/rdma/iw_cm.h
73318 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73319 int backlog);
73320
73321 int (*destroy_listen)(struct iw_cm_id *cm_id);
73322 -};
73323 +} __no_const;
73324
73325 /**
73326 * iw_create_cm_id - Create an IW CM identifier.
73327 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73328 index 399162b..b337f1a 100644
73329 --- a/include/scsi/libfc.h
73330 +++ b/include/scsi/libfc.h
73331 @@ -762,6 +762,7 @@ struct libfc_function_template {
73332 */
73333 void (*disc_stop_final) (struct fc_lport *);
73334 };
73335 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73336
73337 /**
73338 * struct fc_disc - Discovery context
73339 @@ -866,7 +867,7 @@ struct fc_lport {
73340 struct fc_vport *vport;
73341
73342 /* Operational Information */
73343 - struct libfc_function_template tt;
73344 + libfc_function_template_no_const tt;
73345 u8 link_up;
73346 u8 qfull;
73347 enum fc_lport_state state;
73348 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73349 index e65c62e..aa2e5a2 100644
73350 --- a/include/scsi/scsi_device.h
73351 +++ b/include/scsi/scsi_device.h
73352 @@ -170,9 +170,9 @@ struct scsi_device {
73353 unsigned int max_device_blocked; /* what device_blocked counts down from */
73354 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73355
73356 - atomic_t iorequest_cnt;
73357 - atomic_t iodone_cnt;
73358 - atomic_t ioerr_cnt;
73359 + atomic_unchecked_t iorequest_cnt;
73360 + atomic_unchecked_t iodone_cnt;
73361 + atomic_unchecked_t ioerr_cnt;
73362
73363 struct device sdev_gendev,
73364 sdev_dev;
73365 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73366 index b797e8f..8e2c3aa 100644
73367 --- a/include/scsi/scsi_transport_fc.h
73368 +++ b/include/scsi/scsi_transport_fc.h
73369 @@ -751,7 +751,8 @@ struct fc_function_template {
73370 unsigned long show_host_system_hostname:1;
73371
73372 unsigned long disable_target_scan:1;
73373 -};
73374 +} __do_const;
73375 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73376
73377
73378 /**
73379 diff --git a/include/sound/soc.h b/include/sound/soc.h
73380 index bc56738..a4be132 100644
73381 --- a/include/sound/soc.h
73382 +++ b/include/sound/soc.h
73383 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73384 /* probe ordering - for components with runtime dependencies */
73385 int probe_order;
73386 int remove_order;
73387 -};
73388 +} __do_const;
73389
73390 /* SoC platform interface */
73391 struct snd_soc_platform_driver {
73392 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73393 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73394 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73395 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73396 -};
73397 +} __do_const;
73398
73399 struct snd_soc_platform {
73400 const char *name;
73401 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73402 index 663e34a..91b306a 100644
73403 --- a/include/target/target_core_base.h
73404 +++ b/include/target/target_core_base.h
73405 @@ -654,7 +654,7 @@ struct se_device {
73406 spinlock_t stats_lock;
73407 /* Active commands on this virtual SE device */
73408 atomic_t simple_cmds;
73409 - atomic_t dev_ordered_id;
73410 + atomic_unchecked_t dev_ordered_id;
73411 atomic_t dev_ordered_sync;
73412 atomic_t dev_qf_count;
73413 int export_count;
73414 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73415 new file mode 100644
73416 index 0000000..fb634b7
73417 --- /dev/null
73418 +++ b/include/trace/events/fs.h
73419 @@ -0,0 +1,53 @@
73420 +#undef TRACE_SYSTEM
73421 +#define TRACE_SYSTEM fs
73422 +
73423 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73424 +#define _TRACE_FS_H
73425 +
73426 +#include <linux/fs.h>
73427 +#include <linux/tracepoint.h>
73428 +
73429 +TRACE_EVENT(do_sys_open,
73430 +
73431 + TP_PROTO(const char *filename, int flags, int mode),
73432 +
73433 + TP_ARGS(filename, flags, mode),
73434 +
73435 + TP_STRUCT__entry(
73436 + __string( filename, filename )
73437 + __field( int, flags )
73438 + __field( int, mode )
73439 + ),
73440 +
73441 + TP_fast_assign(
73442 + __assign_str(filename, filename);
73443 + __entry->flags = flags;
73444 + __entry->mode = mode;
73445 + ),
73446 +
73447 + TP_printk("\"%s\" %x %o",
73448 + __get_str(filename), __entry->flags, __entry->mode)
73449 +);
73450 +
73451 +TRACE_EVENT(open_exec,
73452 +
73453 + TP_PROTO(const char *filename),
73454 +
73455 + TP_ARGS(filename),
73456 +
73457 + TP_STRUCT__entry(
73458 + __string( filename, filename )
73459 + ),
73460 +
73461 + TP_fast_assign(
73462 + __assign_str(filename, filename);
73463 + ),
73464 +
73465 + TP_printk("\"%s\"",
73466 + __get_str(filename))
73467 +);
73468 +
73469 +#endif /* _TRACE_FS_H */
73470 +
73471 +/* This part must be outside protection */
73472 +#include <trace/define_trace.h>
73473 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73474 index 1c09820..7f5ec79 100644
73475 --- a/include/trace/events/irq.h
73476 +++ b/include/trace/events/irq.h
73477 @@ -36,7 +36,7 @@ struct softirq_action;
73478 */
73479 TRACE_EVENT(irq_handler_entry,
73480
73481 - TP_PROTO(int irq, struct irqaction *action),
73482 + TP_PROTO(int irq, const struct irqaction *action),
73483
73484 TP_ARGS(irq, action),
73485
73486 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73487 */
73488 TRACE_EVENT(irq_handler_exit,
73489
73490 - TP_PROTO(int irq, struct irqaction *action, int ret),
73491 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73492
73493 TP_ARGS(irq, action, ret),
73494
73495 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73496 index 7caf44c..23c6f27 100644
73497 --- a/include/uapi/linux/a.out.h
73498 +++ b/include/uapi/linux/a.out.h
73499 @@ -39,6 +39,14 @@ enum machine_type {
73500 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73501 };
73502
73503 +/* Constants for the N_FLAGS field */
73504 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73505 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73506 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73507 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73508 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73509 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73510 +
73511 #if !defined (N_MAGIC)
73512 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73513 #endif
73514 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73515 index d876736..ccce5c0 100644
73516 --- a/include/uapi/linux/byteorder/little_endian.h
73517 +++ b/include/uapi/linux/byteorder/little_endian.h
73518 @@ -42,51 +42,51 @@
73519
73520 static inline __le64 __cpu_to_le64p(const __u64 *p)
73521 {
73522 - return (__force __le64)*p;
73523 + return (__force const __le64)*p;
73524 }
73525 -static inline __u64 __le64_to_cpup(const __le64 *p)
73526 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73527 {
73528 - return (__force __u64)*p;
73529 + return (__force const __u64)*p;
73530 }
73531 static inline __le32 __cpu_to_le32p(const __u32 *p)
73532 {
73533 - return (__force __le32)*p;
73534 + return (__force const __le32)*p;
73535 }
73536 static inline __u32 __le32_to_cpup(const __le32 *p)
73537 {
73538 - return (__force __u32)*p;
73539 + return (__force const __u32)*p;
73540 }
73541 static inline __le16 __cpu_to_le16p(const __u16 *p)
73542 {
73543 - return (__force __le16)*p;
73544 + return (__force const __le16)*p;
73545 }
73546 static inline __u16 __le16_to_cpup(const __le16 *p)
73547 {
73548 - return (__force __u16)*p;
73549 + return (__force const __u16)*p;
73550 }
73551 static inline __be64 __cpu_to_be64p(const __u64 *p)
73552 {
73553 - return (__force __be64)__swab64p(p);
73554 + return (__force const __be64)__swab64p(p);
73555 }
73556 static inline __u64 __be64_to_cpup(const __be64 *p)
73557 {
73558 - return __swab64p((__u64 *)p);
73559 + return __swab64p((const __u64 *)p);
73560 }
73561 static inline __be32 __cpu_to_be32p(const __u32 *p)
73562 {
73563 - return (__force __be32)__swab32p(p);
73564 + return (__force const __be32)__swab32p(p);
73565 }
73566 -static inline __u32 __be32_to_cpup(const __be32 *p)
73567 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73568 {
73569 - return __swab32p((__u32 *)p);
73570 + return __swab32p((const __u32 *)p);
73571 }
73572 static inline __be16 __cpu_to_be16p(const __u16 *p)
73573 {
73574 - return (__force __be16)__swab16p(p);
73575 + return (__force const __be16)__swab16p(p);
73576 }
73577 static inline __u16 __be16_to_cpup(const __be16 *p)
73578 {
73579 - return __swab16p((__u16 *)p);
73580 + return __swab16p((const __u16 *)p);
73581 }
73582 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73583 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73584 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73585 index 126a817..d522bd1 100644
73586 --- a/include/uapi/linux/elf.h
73587 +++ b/include/uapi/linux/elf.h
73588 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73589 #define PT_GNU_EH_FRAME 0x6474e550
73590
73591 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73592 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73593 +
73594 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73595 +
73596 +/* Constants for the e_flags field */
73597 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73598 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73599 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73600 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73601 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73602 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73603
73604 /*
73605 * Extended Numbering
73606 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73607 #define DT_DEBUG 21
73608 #define DT_TEXTREL 22
73609 #define DT_JMPREL 23
73610 +#define DT_FLAGS 30
73611 + #define DF_TEXTREL 0x00000004
73612 #define DT_ENCODING 32
73613 #define OLD_DT_LOOS 0x60000000
73614 #define DT_LOOS 0x6000000d
73615 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73616 #define PF_W 0x2
73617 #define PF_X 0x1
73618
73619 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73620 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73621 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73622 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73623 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73624 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73625 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73626 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73627 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73628 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73629 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73630 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73631 +
73632 typedef struct elf32_phdr{
73633 Elf32_Word p_type;
73634 Elf32_Off p_offset;
73635 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73636 #define EI_OSABI 7
73637 #define EI_PAD 8
73638
73639 +#define EI_PAX 14
73640 +
73641 #define ELFMAG0 0x7f /* EI_MAG */
73642 #define ELFMAG1 'E'
73643 #define ELFMAG2 'L'
73644 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73645 index aa169c4..6a2771d 100644
73646 --- a/include/uapi/linux/personality.h
73647 +++ b/include/uapi/linux/personality.h
73648 @@ -30,6 +30,7 @@ enum {
73649 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73650 ADDR_NO_RANDOMIZE | \
73651 ADDR_COMPAT_LAYOUT | \
73652 + ADDR_LIMIT_3GB | \
73653 MMAP_PAGE_ZERO)
73654
73655 /*
73656 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73657 index 7530e74..e714828 100644
73658 --- a/include/uapi/linux/screen_info.h
73659 +++ b/include/uapi/linux/screen_info.h
73660 @@ -43,7 +43,8 @@ struct screen_info {
73661 __u16 pages; /* 0x32 */
73662 __u16 vesa_attributes; /* 0x34 */
73663 __u32 capabilities; /* 0x36 */
73664 - __u8 _reserved[6]; /* 0x3a */
73665 + __u16 vesapm_size; /* 0x3a */
73666 + __u8 _reserved[4]; /* 0x3c */
73667 } __attribute__((packed));
73668
73669 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73670 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73671 index 0e011eb..82681b1 100644
73672 --- a/include/uapi/linux/swab.h
73673 +++ b/include/uapi/linux/swab.h
73674 @@ -43,7 +43,7 @@
73675 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73676 */
73677
73678 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73679 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73680 {
73681 #ifdef __HAVE_BUILTIN_BSWAP16__
73682 return __builtin_bswap16(val);
73683 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73684 #endif
73685 }
73686
73687 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73688 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73689 {
73690 #ifdef __HAVE_BUILTIN_BSWAP32__
73691 return __builtin_bswap32(val);
73692 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73693 #endif
73694 }
73695
73696 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73697 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73698 {
73699 #ifdef __HAVE_BUILTIN_BSWAP64__
73700 return __builtin_bswap64(val);
73701 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73702 index 6d67213..8dab561 100644
73703 --- a/include/uapi/linux/sysctl.h
73704 +++ b/include/uapi/linux/sysctl.h
73705 @@ -155,7 +155,11 @@ enum
73706 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73707 };
73708
73709 -
73710 +#ifdef CONFIG_PAX_SOFTMODE
73711 +enum {
73712 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73713 +};
73714 +#endif
73715
73716 /* CTL_VM names: */
73717 enum
73718 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73719 index 26607bd..588b65f 100644
73720 --- a/include/uapi/linux/xattr.h
73721 +++ b/include/uapi/linux/xattr.h
73722 @@ -60,5 +60,9 @@
73723 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73724 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73725
73726 +/* User namespace */
73727 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73728 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73729 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73730
73731 #endif /* _UAPI_LINUX_XATTR_H */
73732 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73733 index f9466fa..f4e2b81 100644
73734 --- a/include/video/udlfb.h
73735 +++ b/include/video/udlfb.h
73736 @@ -53,10 +53,10 @@ struct dlfb_data {
73737 u32 pseudo_palette[256];
73738 int blank_mode; /*one of FB_BLANK_ */
73739 /* blit-only rendering path metrics, exposed through sysfs */
73740 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73741 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73742 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73743 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73744 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73745 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73746 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73747 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73748 };
73749
73750 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73751 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73752 index 0993a22..32ba2fe 100644
73753 --- a/include/video/uvesafb.h
73754 +++ b/include/video/uvesafb.h
73755 @@ -177,6 +177,7 @@ struct uvesafb_par {
73756 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73757 u8 pmi_setpal; /* PMI for palette changes */
73758 u16 *pmi_base; /* protected mode interface location */
73759 + u8 *pmi_code; /* protected mode code location */
73760 void *pmi_start;
73761 void *pmi_pal;
73762 u8 *vbe_state_orig; /*
73763 diff --git a/init/Kconfig b/init/Kconfig
73764 index be8b7f5..1eeca9b 100644
73765 --- a/init/Kconfig
73766 +++ b/init/Kconfig
73767 @@ -990,6 +990,7 @@ endif # CGROUPS
73768
73769 config CHECKPOINT_RESTORE
73770 bool "Checkpoint/restore support" if EXPERT
73771 + depends on !GRKERNSEC
73772 default n
73773 help
73774 Enables additional kernel features in a sake of checkpoint/restore.
73775 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73776
73777 config COMPAT_BRK
73778 bool "Disable heap randomization"
73779 - default y
73780 + default n
73781 help
73782 Randomizing heap placement makes heap exploits harder, but it
73783 also breaks ancient binaries (including anything libc5 based).
73784 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73785 config STOP_MACHINE
73786 bool
73787 default y
73788 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73789 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73790 help
73791 Need stop_machine() primitive.
73792
73793 diff --git a/init/Makefile b/init/Makefile
73794 index 7bc47ee..6da2dc7 100644
73795 --- a/init/Makefile
73796 +++ b/init/Makefile
73797 @@ -2,6 +2,9 @@
73798 # Makefile for the linux kernel.
73799 #
73800
73801 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73802 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73803 +
73804 obj-y := main.o version.o mounts.o
73805 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73806 obj-y += noinitramfs.o
73807 diff --git a/init/do_mounts.c b/init/do_mounts.c
73808 index 1d1b634..a1c810f 100644
73809 --- a/init/do_mounts.c
73810 +++ b/init/do_mounts.c
73811 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73812 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73813 {
73814 struct super_block *s;
73815 - int err = sys_mount(name, "/root", fs, flags, data);
73816 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73817 if (err)
73818 return err;
73819
73820 - sys_chdir("/root");
73821 + sys_chdir((const char __force_user *)"/root");
73822 s = current->fs->pwd.dentry->d_sb;
73823 ROOT_DEV = s->s_dev;
73824 printk(KERN_INFO
73825 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73826 va_start(args, fmt);
73827 vsprintf(buf, fmt, args);
73828 va_end(args);
73829 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73830 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73831 if (fd >= 0) {
73832 sys_ioctl(fd, FDEJECT, 0);
73833 sys_close(fd);
73834 }
73835 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73836 - fd = sys_open("/dev/console", O_RDWR, 0);
73837 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73838 if (fd >= 0) {
73839 sys_ioctl(fd, TCGETS, (long)&termios);
73840 termios.c_lflag &= ~ICANON;
73841 sys_ioctl(fd, TCSETSF, (long)&termios);
73842 - sys_read(fd, &c, 1);
73843 + sys_read(fd, (char __user *)&c, 1);
73844 termios.c_lflag |= ICANON;
73845 sys_ioctl(fd, TCSETSF, (long)&termios);
73846 sys_close(fd);
73847 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73848 mount_root();
73849 out:
73850 devtmpfs_mount("dev");
73851 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73852 - sys_chroot(".");
73853 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73854 + sys_chroot((const char __force_user *)".");
73855 }
73856 diff --git a/init/do_mounts.h b/init/do_mounts.h
73857 index f5b978a..69dbfe8 100644
73858 --- a/init/do_mounts.h
73859 +++ b/init/do_mounts.h
73860 @@ -15,15 +15,15 @@ extern int root_mountflags;
73861
73862 static inline int create_dev(char *name, dev_t dev)
73863 {
73864 - sys_unlink(name);
73865 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73866 + sys_unlink((char __force_user *)name);
73867 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73868 }
73869
73870 #if BITS_PER_LONG == 32
73871 static inline u32 bstat(char *name)
73872 {
73873 struct stat64 stat;
73874 - if (sys_stat64(name, &stat) != 0)
73875 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73876 return 0;
73877 if (!S_ISBLK(stat.st_mode))
73878 return 0;
73879 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73880 static inline u32 bstat(char *name)
73881 {
73882 struct stat stat;
73883 - if (sys_newstat(name, &stat) != 0)
73884 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73885 return 0;
73886 if (!S_ISBLK(stat.st_mode))
73887 return 0;
73888 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73889 index f9acf71..1e19144 100644
73890 --- a/init/do_mounts_initrd.c
73891 +++ b/init/do_mounts_initrd.c
73892 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73893 create_dev("/dev/root.old", Root_RAM0);
73894 /* mount initrd on rootfs' /root */
73895 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73896 - sys_mkdir("/old", 0700);
73897 - sys_chdir("/old");
73898 + sys_mkdir((const char __force_user *)"/old", 0700);
73899 + sys_chdir((const char __force_user *)"/old");
73900
73901 /*
73902 * In case that a resume from disk is carried out by linuxrc or one of
73903 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73904 current->flags &= ~PF_FREEZER_SKIP;
73905
73906 /* move initrd to rootfs' /old */
73907 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73908 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73909 /* switch root and cwd back to / of rootfs */
73910 - sys_chroot("..");
73911 + sys_chroot((const char __force_user *)"..");
73912
73913 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73914 - sys_chdir("/old");
73915 + sys_chdir((const char __force_user *)"/old");
73916 return;
73917 }
73918
73919 - sys_chdir("/");
73920 + sys_chdir((const char __force_user *)"/");
73921 ROOT_DEV = new_decode_dev(real_root_dev);
73922 mount_root();
73923
73924 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73925 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73926 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73927 if (!error)
73928 printk("okay\n");
73929 else {
73930 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73931 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73932 if (error == -ENOENT)
73933 printk("/initrd does not exist. Ignored.\n");
73934 else
73935 printk("failed\n");
73936 printk(KERN_NOTICE "Unmounting old root\n");
73937 - sys_umount("/old", MNT_DETACH);
73938 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73939 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73940 if (fd < 0) {
73941 error = fd;
73942 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73943 * mounted in the normal path.
73944 */
73945 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73946 - sys_unlink("/initrd.image");
73947 + sys_unlink((const char __force_user *)"/initrd.image");
73948 handle_initrd();
73949 return 1;
73950 }
73951 }
73952 - sys_unlink("/initrd.image");
73953 + sys_unlink((const char __force_user *)"/initrd.image");
73954 return 0;
73955 }
73956 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73957 index 8cb6db5..d729f50 100644
73958 --- a/init/do_mounts_md.c
73959 +++ b/init/do_mounts_md.c
73960 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73961 partitioned ? "_d" : "", minor,
73962 md_setup_args[ent].device_names);
73963
73964 - fd = sys_open(name, 0, 0);
73965 + fd = sys_open((char __force_user *)name, 0, 0);
73966 if (fd < 0) {
73967 printk(KERN_ERR "md: open failed - cannot start "
73968 "array %s\n", name);
73969 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73970 * array without it
73971 */
73972 sys_close(fd);
73973 - fd = sys_open(name, 0, 0);
73974 + fd = sys_open((char __force_user *)name, 0, 0);
73975 sys_ioctl(fd, BLKRRPART, 0);
73976 }
73977 sys_close(fd);
73978 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73979
73980 wait_for_device_probe();
73981
73982 - fd = sys_open("/dev/md0", 0, 0);
73983 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73984 if (fd >= 0) {
73985 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73986 sys_close(fd);
73987 diff --git a/init/init_task.c b/init/init_task.c
73988 index 8b2f399..f0797c9 100644
73989 --- a/init/init_task.c
73990 +++ b/init/init_task.c
73991 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73992 * Initial thread structure. Alignment of this is handled by a special
73993 * linker map entry.
73994 */
73995 +#ifdef CONFIG_X86
73996 +union thread_union init_thread_union __init_task_data;
73997 +#else
73998 union thread_union init_thread_union __init_task_data =
73999 { INIT_THREAD_INFO(init_task) };
74000 +#endif
74001 diff --git a/init/initramfs.c b/init/initramfs.c
74002 index 84c6bf1..8899338 100644
74003 --- a/init/initramfs.c
74004 +++ b/init/initramfs.c
74005 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74006 }
74007 }
74008
74009 -static long __init do_utime(char *filename, time_t mtime)
74010 +static long __init do_utime(char __force_user *filename, time_t mtime)
74011 {
74012 struct timespec t[2];
74013
74014 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74015 struct dir_entry *de, *tmp;
74016 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74017 list_del(&de->list);
74018 - do_utime(de->name, de->mtime);
74019 + do_utime((char __force_user *)de->name, de->mtime);
74020 kfree(de->name);
74021 kfree(de);
74022 }
74023 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74024 if (nlink >= 2) {
74025 char *old = find_link(major, minor, ino, mode, collected);
74026 if (old)
74027 - return (sys_link(old, collected) < 0) ? -1 : 1;
74028 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74029 }
74030 return 0;
74031 }
74032 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74033 {
74034 struct stat st;
74035
74036 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74037 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74038 if (S_ISDIR(st.st_mode))
74039 - sys_rmdir(path);
74040 + sys_rmdir((char __force_user *)path);
74041 else
74042 - sys_unlink(path);
74043 + sys_unlink((char __force_user *)path);
74044 }
74045 }
74046
74047 @@ -315,7 +315,7 @@ static int __init do_name(void)
74048 int openflags = O_WRONLY|O_CREAT;
74049 if (ml != 1)
74050 openflags |= O_TRUNC;
74051 - wfd = sys_open(collected, openflags, mode);
74052 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74053
74054 if (wfd >= 0) {
74055 sys_fchown(wfd, uid, gid);
74056 @@ -327,17 +327,17 @@ static int __init do_name(void)
74057 }
74058 }
74059 } else if (S_ISDIR(mode)) {
74060 - sys_mkdir(collected, mode);
74061 - sys_chown(collected, uid, gid);
74062 - sys_chmod(collected, mode);
74063 + sys_mkdir((char __force_user *)collected, mode);
74064 + sys_chown((char __force_user *)collected, uid, gid);
74065 + sys_chmod((char __force_user *)collected, mode);
74066 dir_add(collected, mtime);
74067 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74068 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74069 if (maybe_link() == 0) {
74070 - sys_mknod(collected, mode, rdev);
74071 - sys_chown(collected, uid, gid);
74072 - sys_chmod(collected, mode);
74073 - do_utime(collected, mtime);
74074 + sys_mknod((char __force_user *)collected, mode, rdev);
74075 + sys_chown((char __force_user *)collected, uid, gid);
74076 + sys_chmod((char __force_user *)collected, mode);
74077 + do_utime((char __force_user *)collected, mtime);
74078 }
74079 }
74080 return 0;
74081 @@ -346,15 +346,15 @@ static int __init do_name(void)
74082 static int __init do_copy(void)
74083 {
74084 if (count >= body_len) {
74085 - sys_write(wfd, victim, body_len);
74086 + sys_write(wfd, (char __force_user *)victim, body_len);
74087 sys_close(wfd);
74088 - do_utime(vcollected, mtime);
74089 + do_utime((char __force_user *)vcollected, mtime);
74090 kfree(vcollected);
74091 eat(body_len);
74092 state = SkipIt;
74093 return 0;
74094 } else {
74095 - sys_write(wfd, victim, count);
74096 + sys_write(wfd, (char __force_user *)victim, count);
74097 body_len -= count;
74098 eat(count);
74099 return 1;
74100 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74101 {
74102 collected[N_ALIGN(name_len) + body_len] = '\0';
74103 clean_path(collected, 0);
74104 - sys_symlink(collected + N_ALIGN(name_len), collected);
74105 - sys_lchown(collected, uid, gid);
74106 - do_utime(collected, mtime);
74107 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74108 + sys_lchown((char __force_user *)collected, uid, gid);
74109 + do_utime((char __force_user *)collected, mtime);
74110 state = SkipIt;
74111 next_state = Reset;
74112 return 0;
74113 diff --git a/init/main.c b/init/main.c
74114 index cee4b5c..360e10a 100644
74115 --- a/init/main.c
74116 +++ b/init/main.c
74117 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
74118 extern void tc_init(void);
74119 #endif
74120
74121 +extern void grsecurity_init(void);
74122 +
74123 /*
74124 * Debug helper: via this flag we know that we are in 'early bootup code'
74125 * where only the boot processor is running with IRQ disabled. This means
74126 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74127
74128 __setup("reset_devices", set_reset_devices);
74129
74130 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74131 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74132 +static int __init setup_grsec_proc_gid(char *str)
74133 +{
74134 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74135 + return 1;
74136 +}
74137 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74138 +#endif
74139 +
74140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74141 +extern char pax_enter_kernel_user[];
74142 +extern char pax_exit_kernel_user[];
74143 +extern pgdval_t clone_pgd_mask;
74144 +#endif
74145 +
74146 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74147 +static int __init setup_pax_nouderef(char *str)
74148 +{
74149 +#ifdef CONFIG_X86_32
74150 + unsigned int cpu;
74151 + struct desc_struct *gdt;
74152 +
74153 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74154 + gdt = get_cpu_gdt_table(cpu);
74155 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74156 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74157 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74158 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74159 + }
74160 + loadsegment(ds, __KERNEL_DS);
74161 + loadsegment(es, __KERNEL_DS);
74162 + loadsegment(ss, __KERNEL_DS);
74163 +#else
74164 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74165 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74166 + clone_pgd_mask = ~(pgdval_t)0UL;
74167 +#endif
74168 +
74169 + return 0;
74170 +}
74171 +early_param("pax_nouderef", setup_pax_nouderef);
74172 +#endif
74173 +
74174 +#ifdef CONFIG_PAX_SOFTMODE
74175 +int pax_softmode;
74176 +
74177 +static int __init setup_pax_softmode(char *str)
74178 +{
74179 + get_option(&str, &pax_softmode);
74180 + return 1;
74181 +}
74182 +__setup("pax_softmode=", setup_pax_softmode);
74183 +#endif
74184 +
74185 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74186 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74187 static const char *panic_later, *panic_param;
74188 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74189 {
74190 int count = preempt_count();
74191 int ret;
74192 + const char *msg1 = "", *msg2 = "";
74193
74194 if (initcall_debug)
74195 ret = do_one_initcall_debug(fn);
74196 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74197 sprintf(msgbuf, "error code %d ", ret);
74198
74199 if (preempt_count() != count) {
74200 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74201 + msg1 = " preemption imbalance";
74202 preempt_count() = count;
74203 }
74204 if (irqs_disabled()) {
74205 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74206 + msg2 = " disabled interrupts";
74207 local_irq_enable();
74208 }
74209 - if (msgbuf[0]) {
74210 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74211 + if (msgbuf[0] || *msg1 || *msg2) {
74212 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74213 }
74214
74215 return ret;
74216 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74217 level, level,
74218 &repair_env_string);
74219
74220 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74221 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74222 do_one_initcall(*fn);
74223 +
74224 +#ifdef LATENT_ENTROPY_PLUGIN
74225 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74226 +#endif
74227 +
74228 + }
74229 }
74230
74231 static void __init do_initcalls(void)
74232 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74233 {
74234 initcall_t *fn;
74235
74236 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74237 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74238 do_one_initcall(*fn);
74239 +
74240 +#ifdef LATENT_ENTROPY_PLUGIN
74241 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74242 +#endif
74243 +
74244 + }
74245 }
74246
74247 static int run_init_process(const char *init_filename)
74248 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74249 do_basic_setup();
74250
74251 /* Open the /dev/console on the rootfs, this should never fail */
74252 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74253 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74254 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74255
74256 (void) sys_dup(0);
74257 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74258 if (!ramdisk_execute_command)
74259 ramdisk_execute_command = "/init";
74260
74261 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74262 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74263 ramdisk_execute_command = NULL;
74264 prepare_namespace();
74265 }
74266
74267 + grsecurity_init();
74268 +
74269 /*
74270 * Ok, we have completed the initial bootup, and
74271 * we're essentially up and running. Get rid of the
74272 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74273 index 130dfec..cc88451 100644
74274 --- a/ipc/ipc_sysctl.c
74275 +++ b/ipc/ipc_sysctl.c
74276 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74277 static int proc_ipc_dointvec(ctl_table *table, int write,
74278 void __user *buffer, size_t *lenp, loff_t *ppos)
74279 {
74280 - struct ctl_table ipc_table;
74281 + ctl_table_no_const ipc_table;
74282
74283 memcpy(&ipc_table, table, sizeof(ipc_table));
74284 ipc_table.data = get_ipc(table);
74285 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74286 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74287 void __user *buffer, size_t *lenp, loff_t *ppos)
74288 {
74289 - struct ctl_table ipc_table;
74290 + ctl_table_no_const ipc_table;
74291
74292 memcpy(&ipc_table, table, sizeof(ipc_table));
74293 ipc_table.data = get_ipc(table);
74294 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74295 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74296 void __user *buffer, size_t *lenp, loff_t *ppos)
74297 {
74298 - struct ctl_table ipc_table;
74299 + ctl_table_no_const ipc_table;
74300 size_t lenp_bef = *lenp;
74301 int rc;
74302
74303 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74304 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74305 void __user *buffer, size_t *lenp, loff_t *ppos)
74306 {
74307 - struct ctl_table ipc_table;
74308 + ctl_table_no_const ipc_table;
74309 memcpy(&ipc_table, table, sizeof(ipc_table));
74310 ipc_table.data = get_ipc(table);
74311
74312 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74313 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74314 void __user *buffer, size_t *lenp, loff_t *ppos)
74315 {
74316 - struct ctl_table ipc_table;
74317 + ctl_table_no_const ipc_table;
74318 size_t lenp_bef = *lenp;
74319 int oldval;
74320 int rc;
74321 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74322 index 383d638..943fdbb 100644
74323 --- a/ipc/mq_sysctl.c
74324 +++ b/ipc/mq_sysctl.c
74325 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74326 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74327 void __user *buffer, size_t *lenp, loff_t *ppos)
74328 {
74329 - struct ctl_table mq_table;
74330 + ctl_table_no_const mq_table;
74331 memcpy(&mq_table, table, sizeof(mq_table));
74332 mq_table.data = get_mq(table);
74333
74334 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74335 index f3f40dc..ffe5a3a 100644
74336 --- a/ipc/mqueue.c
74337 +++ b/ipc/mqueue.c
74338 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74339 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74340 info->attr.mq_msgsize);
74341
74342 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74343 spin_lock(&mq_lock);
74344 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74345 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74346 diff --git a/ipc/msg.c b/ipc/msg.c
74347 index fede1d0..9778e0f8 100644
74348 --- a/ipc/msg.c
74349 +++ b/ipc/msg.c
74350 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74351 return security_msg_queue_associate(msq, msgflg);
74352 }
74353
74354 +static struct ipc_ops msg_ops = {
74355 + .getnew = newque,
74356 + .associate = msg_security,
74357 + .more_checks = NULL
74358 +};
74359 +
74360 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74361 {
74362 struct ipc_namespace *ns;
74363 - struct ipc_ops msg_ops;
74364 struct ipc_params msg_params;
74365
74366 ns = current->nsproxy->ipc_ns;
74367
74368 - msg_ops.getnew = newque;
74369 - msg_ops.associate = msg_security;
74370 - msg_ops.more_checks = NULL;
74371 -
74372 msg_params.key = key;
74373 msg_params.flg = msgflg;
74374
74375 diff --git a/ipc/sem.c b/ipc/sem.c
74376 index 58d31f1..cce7a55 100644
74377 --- a/ipc/sem.c
74378 +++ b/ipc/sem.c
74379 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74380 return 0;
74381 }
74382
74383 +static struct ipc_ops sem_ops = {
74384 + .getnew = newary,
74385 + .associate = sem_security,
74386 + .more_checks = sem_more_checks
74387 +};
74388 +
74389 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74390 {
74391 struct ipc_namespace *ns;
74392 - struct ipc_ops sem_ops;
74393 struct ipc_params sem_params;
74394
74395 ns = current->nsproxy->ipc_ns;
74396 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74397 if (nsems < 0 || nsems > ns->sc_semmsl)
74398 return -EINVAL;
74399
74400 - sem_ops.getnew = newary;
74401 - sem_ops.associate = sem_security;
74402 - sem_ops.more_checks = sem_more_checks;
74403 -
74404 sem_params.key = key;
74405 sem_params.flg = semflg;
74406 sem_params.u.nsems = nsems;
74407 diff --git a/ipc/shm.c b/ipc/shm.c
74408 index 9bab650..1ce68a5 100644
74409 --- a/ipc/shm.c
74410 +++ b/ipc/shm.c
74411 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74412 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74413 #endif
74414
74415 +#ifdef CONFIG_GRKERNSEC
74416 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74417 + const time_t shm_createtime, const kuid_t cuid,
74418 + const int shmid);
74419 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74420 + const time_t shm_createtime);
74421 +#endif
74422 +
74423 void shm_init_ns(struct ipc_namespace *ns)
74424 {
74425 ns->shm_ctlmax = SHMMAX;
74426 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74427 shp->shm_lprid = 0;
74428 shp->shm_atim = shp->shm_dtim = 0;
74429 shp->shm_ctim = get_seconds();
74430 +#ifdef CONFIG_GRKERNSEC
74431 + {
74432 + struct timespec timeval;
74433 + do_posix_clock_monotonic_gettime(&timeval);
74434 +
74435 + shp->shm_createtime = timeval.tv_sec;
74436 + }
74437 +#endif
74438 shp->shm_segsz = size;
74439 shp->shm_nattch = 0;
74440 shp->shm_file = file;
74441 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74442 return 0;
74443 }
74444
74445 +static struct ipc_ops shm_ops = {
74446 + .getnew = newseg,
74447 + .associate = shm_security,
74448 + .more_checks = shm_more_checks
74449 +};
74450 +
74451 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74452 {
74453 struct ipc_namespace *ns;
74454 - struct ipc_ops shm_ops;
74455 struct ipc_params shm_params;
74456
74457 ns = current->nsproxy->ipc_ns;
74458
74459 - shm_ops.getnew = newseg;
74460 - shm_ops.associate = shm_security;
74461 - shm_ops.more_checks = shm_more_checks;
74462 -
74463 shm_params.key = key;
74464 shm_params.flg = shmflg;
74465 shm_params.u.size = size;
74466 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74467 f_mode = FMODE_READ | FMODE_WRITE;
74468 }
74469 if (shmflg & SHM_EXEC) {
74470 +
74471 +#ifdef CONFIG_PAX_MPROTECT
74472 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74473 + goto out;
74474 +#endif
74475 +
74476 prot |= PROT_EXEC;
74477 acc_mode |= S_IXUGO;
74478 }
74479 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74480 if (err)
74481 goto out_unlock;
74482
74483 +#ifdef CONFIG_GRKERNSEC
74484 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74485 + shp->shm_perm.cuid, shmid) ||
74486 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74487 + err = -EACCES;
74488 + goto out_unlock;
74489 + }
74490 +#endif
74491 +
74492 path = shp->shm_file->f_path;
74493 path_get(&path);
74494 shp->shm_nattch++;
74495 +#ifdef CONFIG_GRKERNSEC
74496 + shp->shm_lapid = current->pid;
74497 +#endif
74498 size = i_size_read(path.dentry->d_inode);
74499 shm_unlock(shp);
74500
74501 diff --git a/kernel/acct.c b/kernel/acct.c
74502 index 051e071..15e0920 100644
74503 --- a/kernel/acct.c
74504 +++ b/kernel/acct.c
74505 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74506 */
74507 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74508 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74509 - file->f_op->write(file, (char *)&ac,
74510 + file->f_op->write(file, (char __force_user *)&ac,
74511 sizeof(acct_t), &file->f_pos);
74512 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74513 set_fs(fs);
74514 diff --git a/kernel/audit.c b/kernel/audit.c
74515 index d596e53..dbef3c3 100644
74516 --- a/kernel/audit.c
74517 +++ b/kernel/audit.c
74518 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74519 3) suppressed due to audit_rate_limit
74520 4) suppressed due to audit_backlog_limit
74521 */
74522 -static atomic_t audit_lost = ATOMIC_INIT(0);
74523 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74524
74525 /* The netlink socket. */
74526 static struct sock *audit_sock;
74527 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74528 unsigned long now;
74529 int print;
74530
74531 - atomic_inc(&audit_lost);
74532 + atomic_inc_unchecked(&audit_lost);
74533
74534 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74535
74536 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74537 printk(KERN_WARNING
74538 "audit: audit_lost=%d audit_rate_limit=%d "
74539 "audit_backlog_limit=%d\n",
74540 - atomic_read(&audit_lost),
74541 + atomic_read_unchecked(&audit_lost),
74542 audit_rate_limit,
74543 audit_backlog_limit);
74544 audit_panic(message);
74545 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74546 status_set.pid = audit_pid;
74547 status_set.rate_limit = audit_rate_limit;
74548 status_set.backlog_limit = audit_backlog_limit;
74549 - status_set.lost = atomic_read(&audit_lost);
74550 + status_set.lost = atomic_read_unchecked(&audit_lost);
74551 status_set.backlog = skb_queue_len(&audit_skb_queue);
74552 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74553 &status_set, sizeof(status_set));
74554 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74555 index a371f85..da826c1 100644
74556 --- a/kernel/auditsc.c
74557 +++ b/kernel/auditsc.c
74558 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74559 }
74560
74561 /* global counter which is incremented every time something logs in */
74562 -static atomic_t session_id = ATOMIC_INIT(0);
74563 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74564
74565 /**
74566 * audit_set_loginuid - set current task's audit_context loginuid
74567 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74568 return -EPERM;
74569 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74570
74571 - sessionid = atomic_inc_return(&session_id);
74572 + sessionid = atomic_inc_return_unchecked(&session_id);
74573 if (context && context->in_syscall) {
74574 struct audit_buffer *ab;
74575
74576 diff --git a/kernel/capability.c b/kernel/capability.c
74577 index f6c2ce5..982c0f9 100644
74578 --- a/kernel/capability.c
74579 +++ b/kernel/capability.c
74580 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74581 * before modification is attempted and the application
74582 * fails.
74583 */
74584 + if (tocopy > ARRAY_SIZE(kdata))
74585 + return -EFAULT;
74586 +
74587 if (copy_to_user(dataptr, kdata, tocopy
74588 * sizeof(struct __user_cap_data_struct))) {
74589 return -EFAULT;
74590 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74591 int ret;
74592
74593 rcu_read_lock();
74594 - ret = security_capable(__task_cred(t), ns, cap);
74595 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74596 + gr_task_is_capable(t, __task_cred(t), cap);
74597 rcu_read_unlock();
74598
74599 - return (ret == 0);
74600 + return ret;
74601 }
74602
74603 /**
74604 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74605 int ret;
74606
74607 rcu_read_lock();
74608 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74609 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74610 rcu_read_unlock();
74611
74612 - return (ret == 0);
74613 + return ret;
74614 }
74615
74616 /**
74617 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74618 BUG();
74619 }
74620
74621 - if (security_capable(current_cred(), ns, cap) == 0) {
74622 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74623 current->flags |= PF_SUPERPRIV;
74624 return true;
74625 }
74626 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74627 }
74628 EXPORT_SYMBOL(ns_capable);
74629
74630 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74631 +{
74632 + if (unlikely(!cap_valid(cap))) {
74633 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74634 + BUG();
74635 + }
74636 +
74637 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74638 + current->flags |= PF_SUPERPRIV;
74639 + return true;
74640 + }
74641 + return false;
74642 +}
74643 +EXPORT_SYMBOL(ns_capable_nolog);
74644 +
74645 /**
74646 * file_ns_capable - Determine if the file's opener had a capability in effect
74647 * @file: The file we want to check
74648 @@ -432,6 +451,12 @@ bool capable(int cap)
74649 }
74650 EXPORT_SYMBOL(capable);
74651
74652 +bool capable_nolog(int cap)
74653 +{
74654 + return ns_capable_nolog(&init_user_ns, cap);
74655 +}
74656 +EXPORT_SYMBOL(capable_nolog);
74657 +
74658 /**
74659 * nsown_capable - Check superior capability to one's own user_ns
74660 * @cap: The capability in question
74661 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74662
74663 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74664 }
74665 +
74666 +bool inode_capable_nolog(const struct inode *inode, int cap)
74667 +{
74668 + struct user_namespace *ns = current_user_ns();
74669 +
74670 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74671 +}
74672 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74673 index cddf1d9..34e9721 100644
74674 --- a/kernel/cgroup.c
74675 +++ b/kernel/cgroup.c
74676 @@ -5544,7 +5544,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74677 struct css_set *cg = link->cg;
74678 struct task_struct *task;
74679 int count = 0;
74680 - seq_printf(seq, "css_set %p\n", cg);
74681 + seq_printf(seq, "css_set %pK\n", cg);
74682 list_for_each_entry(task, &cg->tasks, cg_list) {
74683 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74684 seq_puts(seq, " ...\n");
74685 diff --git a/kernel/compat.c b/kernel/compat.c
74686 index 36700e9..73d770c 100644
74687 --- a/kernel/compat.c
74688 +++ b/kernel/compat.c
74689 @@ -13,6 +13,7 @@
74690
74691 #include <linux/linkage.h>
74692 #include <linux/compat.h>
74693 +#include <linux/module.h>
74694 #include <linux/errno.h>
74695 #include <linux/time.h>
74696 #include <linux/signal.h>
74697 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74698 mm_segment_t oldfs;
74699 long ret;
74700
74701 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74702 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74703 oldfs = get_fs();
74704 set_fs(KERNEL_DS);
74705 ret = hrtimer_nanosleep_restart(restart);
74706 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74707 oldfs = get_fs();
74708 set_fs(KERNEL_DS);
74709 ret = hrtimer_nanosleep(&tu,
74710 - rmtp ? (struct timespec __user *)&rmt : NULL,
74711 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74712 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74713 set_fs(oldfs);
74714
74715 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74716 mm_segment_t old_fs = get_fs();
74717
74718 set_fs(KERNEL_DS);
74719 - ret = sys_sigpending((old_sigset_t __user *) &s);
74720 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74721 set_fs(old_fs);
74722 if (ret == 0)
74723 ret = put_user(s, set);
74724 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74725 mm_segment_t old_fs = get_fs();
74726
74727 set_fs(KERNEL_DS);
74728 - ret = sys_old_getrlimit(resource, &r);
74729 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74730 set_fs(old_fs);
74731
74732 if (!ret) {
74733 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74734 mm_segment_t old_fs = get_fs();
74735
74736 set_fs(KERNEL_DS);
74737 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74738 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74739 set_fs(old_fs);
74740
74741 if (ret)
74742 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74743 set_fs (KERNEL_DS);
74744 ret = sys_wait4(pid,
74745 (stat_addr ?
74746 - (unsigned int __user *) &status : NULL),
74747 - options, (struct rusage __user *) &r);
74748 + (unsigned int __force_user *) &status : NULL),
74749 + options, (struct rusage __force_user *) &r);
74750 set_fs (old_fs);
74751
74752 if (ret > 0) {
74753 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74754 memset(&info, 0, sizeof(info));
74755
74756 set_fs(KERNEL_DS);
74757 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74758 - uru ? (struct rusage __user *)&ru : NULL);
74759 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74760 + uru ? (struct rusage __force_user *)&ru : NULL);
74761 set_fs(old_fs);
74762
74763 if ((ret < 0) || (info.si_signo == 0))
74764 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74765 oldfs = get_fs();
74766 set_fs(KERNEL_DS);
74767 err = sys_timer_settime(timer_id, flags,
74768 - (struct itimerspec __user *) &newts,
74769 - (struct itimerspec __user *) &oldts);
74770 + (struct itimerspec __force_user *) &newts,
74771 + (struct itimerspec __force_user *) &oldts);
74772 set_fs(oldfs);
74773 if (!err && old && put_compat_itimerspec(old, &oldts))
74774 return -EFAULT;
74775 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74776 oldfs = get_fs();
74777 set_fs(KERNEL_DS);
74778 err = sys_timer_gettime(timer_id,
74779 - (struct itimerspec __user *) &ts);
74780 + (struct itimerspec __force_user *) &ts);
74781 set_fs(oldfs);
74782 if (!err && put_compat_itimerspec(setting, &ts))
74783 return -EFAULT;
74784 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74785 oldfs = get_fs();
74786 set_fs(KERNEL_DS);
74787 err = sys_clock_settime(which_clock,
74788 - (struct timespec __user *) &ts);
74789 + (struct timespec __force_user *) &ts);
74790 set_fs(oldfs);
74791 return err;
74792 }
74793 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74794 oldfs = get_fs();
74795 set_fs(KERNEL_DS);
74796 err = sys_clock_gettime(which_clock,
74797 - (struct timespec __user *) &ts);
74798 + (struct timespec __force_user *) &ts);
74799 set_fs(oldfs);
74800 if (!err && put_compat_timespec(&ts, tp))
74801 return -EFAULT;
74802 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74803
74804 oldfs = get_fs();
74805 set_fs(KERNEL_DS);
74806 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74807 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74808 set_fs(oldfs);
74809
74810 err = compat_put_timex(utp, &txc);
74811 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74812 oldfs = get_fs();
74813 set_fs(KERNEL_DS);
74814 err = sys_clock_getres(which_clock,
74815 - (struct timespec __user *) &ts);
74816 + (struct timespec __force_user *) &ts);
74817 set_fs(oldfs);
74818 if (!err && tp && put_compat_timespec(&ts, tp))
74819 return -EFAULT;
74820 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74821 long err;
74822 mm_segment_t oldfs;
74823 struct timespec tu;
74824 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74825 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74826
74827 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74828 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74829 oldfs = get_fs();
74830 set_fs(KERNEL_DS);
74831 err = clock_nanosleep_restart(restart);
74832 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74833 oldfs = get_fs();
74834 set_fs(KERNEL_DS);
74835 err = sys_clock_nanosleep(which_clock, flags,
74836 - (struct timespec __user *) &in,
74837 - (struct timespec __user *) &out);
74838 + (struct timespec __force_user *) &in,
74839 + (struct timespec __force_user *) &out);
74840 set_fs(oldfs);
74841
74842 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74843 diff --git a/kernel/configs.c b/kernel/configs.c
74844 index 42e8fa0..9e7406b 100644
74845 --- a/kernel/configs.c
74846 +++ b/kernel/configs.c
74847 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74848 struct proc_dir_entry *entry;
74849
74850 /* create the current config file */
74851 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74852 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74853 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74854 + &ikconfig_file_ops);
74855 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74856 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74857 + &ikconfig_file_ops);
74858 +#endif
74859 +#else
74860 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74861 &ikconfig_file_ops);
74862 +#endif
74863 +
74864 if (!entry)
74865 return -ENOMEM;
74866
74867 diff --git a/kernel/cred.c b/kernel/cred.c
74868 index e0573a4..3874e41 100644
74869 --- a/kernel/cred.c
74870 +++ b/kernel/cred.c
74871 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74872 validate_creds(cred);
74873 alter_cred_subscribers(cred, -1);
74874 put_cred(cred);
74875 +
74876 +#ifdef CONFIG_GRKERNSEC_SETXID
74877 + cred = (struct cred *) tsk->delayed_cred;
74878 + if (cred != NULL) {
74879 + tsk->delayed_cred = NULL;
74880 + validate_creds(cred);
74881 + alter_cred_subscribers(cred, -1);
74882 + put_cred(cred);
74883 + }
74884 +#endif
74885 }
74886
74887 /**
74888 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74889 * Always returns 0 thus allowing this function to be tail-called at the end
74890 * of, say, sys_setgid().
74891 */
74892 -int commit_creds(struct cred *new)
74893 +static int __commit_creds(struct cred *new)
74894 {
74895 struct task_struct *task = current;
74896 const struct cred *old = task->real_cred;
74897 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74898
74899 get_cred(new); /* we will require a ref for the subj creds too */
74900
74901 + gr_set_role_label(task, new->uid, new->gid);
74902 +
74903 /* dumpability changes */
74904 if (!uid_eq(old->euid, new->euid) ||
74905 !gid_eq(old->egid, new->egid) ||
74906 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74907 put_cred(old);
74908 return 0;
74909 }
74910 +#ifdef CONFIG_GRKERNSEC_SETXID
74911 +extern int set_user(struct cred *new);
74912 +
74913 +void gr_delayed_cred_worker(void)
74914 +{
74915 + const struct cred *new = current->delayed_cred;
74916 + struct cred *ncred;
74917 +
74918 + current->delayed_cred = NULL;
74919 +
74920 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74921 + // from doing get_cred on it when queueing this
74922 + put_cred(new);
74923 + return;
74924 + } else if (new == NULL)
74925 + return;
74926 +
74927 + ncred = prepare_creds();
74928 + if (!ncred)
74929 + goto die;
74930 + // uids
74931 + ncred->uid = new->uid;
74932 + ncred->euid = new->euid;
74933 + ncred->suid = new->suid;
74934 + ncred->fsuid = new->fsuid;
74935 + // gids
74936 + ncred->gid = new->gid;
74937 + ncred->egid = new->egid;
74938 + ncred->sgid = new->sgid;
74939 + ncred->fsgid = new->fsgid;
74940 + // groups
74941 + if (set_groups(ncred, new->group_info) < 0) {
74942 + abort_creds(ncred);
74943 + goto die;
74944 + }
74945 + // caps
74946 + ncred->securebits = new->securebits;
74947 + ncred->cap_inheritable = new->cap_inheritable;
74948 + ncred->cap_permitted = new->cap_permitted;
74949 + ncred->cap_effective = new->cap_effective;
74950 + ncred->cap_bset = new->cap_bset;
74951 +
74952 + if (set_user(ncred)) {
74953 + abort_creds(ncred);
74954 + goto die;
74955 + }
74956 +
74957 + // from doing get_cred on it when queueing this
74958 + put_cred(new);
74959 +
74960 + __commit_creds(ncred);
74961 + return;
74962 +die:
74963 + // from doing get_cred on it when queueing this
74964 + put_cred(new);
74965 + do_group_exit(SIGKILL);
74966 +}
74967 +#endif
74968 +
74969 +int commit_creds(struct cred *new)
74970 +{
74971 +#ifdef CONFIG_GRKERNSEC_SETXID
74972 + int ret;
74973 + int schedule_it = 0;
74974 + struct task_struct *t;
74975 +
74976 + /* we won't get called with tasklist_lock held for writing
74977 + and interrupts disabled as the cred struct in that case is
74978 + init_cred
74979 + */
74980 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74981 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74982 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74983 + schedule_it = 1;
74984 + }
74985 + ret = __commit_creds(new);
74986 + if (schedule_it) {
74987 + rcu_read_lock();
74988 + read_lock(&tasklist_lock);
74989 + for (t = next_thread(current); t != current;
74990 + t = next_thread(t)) {
74991 + if (t->delayed_cred == NULL) {
74992 + t->delayed_cred = get_cred(new);
74993 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74994 + set_tsk_need_resched(t);
74995 + }
74996 + }
74997 + read_unlock(&tasklist_lock);
74998 + rcu_read_unlock();
74999 + }
75000 + return ret;
75001 +#else
75002 + return __commit_creds(new);
75003 +#endif
75004 +}
75005 +
75006 EXPORT_SYMBOL(commit_creds);
75007
75008 /**
75009 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75010 index 9a61738..c5c8f3a 100644
75011 --- a/kernel/debug/debug_core.c
75012 +++ b/kernel/debug/debug_core.c
75013 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75014 */
75015 static atomic_t masters_in_kgdb;
75016 static atomic_t slaves_in_kgdb;
75017 -static atomic_t kgdb_break_tasklet_var;
75018 +static atomic_unchecked_t kgdb_break_tasklet_var;
75019 atomic_t kgdb_setting_breakpoint;
75020
75021 struct task_struct *kgdb_usethread;
75022 @@ -132,7 +132,7 @@ int kgdb_single_step;
75023 static pid_t kgdb_sstep_pid;
75024
75025 /* to keep track of the CPU which is doing the single stepping*/
75026 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75027 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75028
75029 /*
75030 * If you are debugging a problem where roundup (the collection of
75031 @@ -540,7 +540,7 @@ return_normal:
75032 * kernel will only try for the value of sstep_tries before
75033 * giving up and continuing on.
75034 */
75035 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75036 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75037 (kgdb_info[cpu].task &&
75038 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75039 atomic_set(&kgdb_active, -1);
75040 @@ -634,8 +634,8 @@ cpu_master_loop:
75041 }
75042
75043 kgdb_restore:
75044 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75045 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75046 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75047 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75048 if (kgdb_info[sstep_cpu].task)
75049 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75050 else
75051 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
75052 static void kgdb_tasklet_bpt(unsigned long ing)
75053 {
75054 kgdb_breakpoint();
75055 - atomic_set(&kgdb_break_tasklet_var, 0);
75056 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75057 }
75058
75059 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75060
75061 void kgdb_schedule_breakpoint(void)
75062 {
75063 - if (atomic_read(&kgdb_break_tasklet_var) ||
75064 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75065 atomic_read(&kgdb_active) != -1 ||
75066 atomic_read(&kgdb_setting_breakpoint))
75067 return;
75068 - atomic_inc(&kgdb_break_tasklet_var);
75069 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75070 tasklet_schedule(&kgdb_tasklet_breakpoint);
75071 }
75072 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75073 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75074 index 8875254..7cf4928 100644
75075 --- a/kernel/debug/kdb/kdb_main.c
75076 +++ b/kernel/debug/kdb/kdb_main.c
75077 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75078 continue;
75079
75080 kdb_printf("%-20s%8u 0x%p ", mod->name,
75081 - mod->core_size, (void *)mod);
75082 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75083 #ifdef CONFIG_MODULE_UNLOAD
75084 kdb_printf("%4ld ", module_refcount(mod));
75085 #endif
75086 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75087 kdb_printf(" (Loading)");
75088 else
75089 kdb_printf(" (Live)");
75090 - kdb_printf(" 0x%p", mod->module_core);
75091 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75092
75093 #ifdef CONFIG_MODULE_UNLOAD
75094 {
75095 diff --git a/kernel/events/core.c b/kernel/events/core.c
75096 index 0600d3b..742ab1b 100644
75097 --- a/kernel/events/core.c
75098 +++ b/kernel/events/core.c
75099 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75100 return 0;
75101 }
75102
75103 -static atomic64_t perf_event_id;
75104 +static atomic64_unchecked_t perf_event_id;
75105
75106 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75107 enum event_type_t event_type);
75108 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
75109
75110 static inline u64 perf_event_count(struct perf_event *event)
75111 {
75112 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75113 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75114 }
75115
75116 static u64 perf_event_read(struct perf_event *event)
75117 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75118 mutex_lock(&event->child_mutex);
75119 total += perf_event_read(event);
75120 *enabled += event->total_time_enabled +
75121 - atomic64_read(&event->child_total_time_enabled);
75122 + atomic64_read_unchecked(&event->child_total_time_enabled);
75123 *running += event->total_time_running +
75124 - atomic64_read(&event->child_total_time_running);
75125 + atomic64_read_unchecked(&event->child_total_time_running);
75126
75127 list_for_each_entry(child, &event->child_list, child_list) {
75128 total += perf_event_read(child);
75129 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75130 userpg->offset -= local64_read(&event->hw.prev_count);
75131
75132 userpg->time_enabled = enabled +
75133 - atomic64_read(&event->child_total_time_enabled);
75134 + atomic64_read_unchecked(&event->child_total_time_enabled);
75135
75136 userpg->time_running = running +
75137 - atomic64_read(&event->child_total_time_running);
75138 + atomic64_read_unchecked(&event->child_total_time_running);
75139
75140 arch_perf_update_userpage(userpg, now);
75141
75142 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75143 values[n++] = perf_event_count(event);
75144 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75145 values[n++] = enabled +
75146 - atomic64_read(&event->child_total_time_enabled);
75147 + atomic64_read_unchecked(&event->child_total_time_enabled);
75148 }
75149 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75150 values[n++] = running +
75151 - atomic64_read(&event->child_total_time_running);
75152 + atomic64_read_unchecked(&event->child_total_time_running);
75153 }
75154 if (read_format & PERF_FORMAT_ID)
75155 values[n++] = primary_event_id(event);
75156 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75157 * need to add enough zero bytes after the string to handle
75158 * the 64bit alignment we do later.
75159 */
75160 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75161 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75162 if (!buf) {
75163 name = strncpy(tmp, "//enomem", sizeof(tmp));
75164 goto got_name;
75165 }
75166 - name = d_path(&file->f_path, buf, PATH_MAX);
75167 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75168 if (IS_ERR(name)) {
75169 name = strncpy(tmp, "//toolong", sizeof(tmp));
75170 goto got_name;
75171 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75172 event->parent = parent_event;
75173
75174 event->ns = get_pid_ns(task_active_pid_ns(current));
75175 - event->id = atomic64_inc_return(&perf_event_id);
75176 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75177
75178 event->state = PERF_EVENT_STATE_INACTIVE;
75179
75180 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75181 /*
75182 * Add back the child's count to the parent's count:
75183 */
75184 - atomic64_add(child_val, &parent_event->child_count);
75185 - atomic64_add(child_event->total_time_enabled,
75186 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75187 + atomic64_add_unchecked(child_event->total_time_enabled,
75188 &parent_event->child_total_time_enabled);
75189 - atomic64_add(child_event->total_time_running,
75190 + atomic64_add_unchecked(child_event->total_time_running,
75191 &parent_event->child_total_time_running);
75192
75193 /*
75194 diff --git a/kernel/exit.c b/kernel/exit.c
75195 index b4df219..f13c02d 100644
75196 --- a/kernel/exit.c
75197 +++ b/kernel/exit.c
75198 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75199 struct task_struct *leader;
75200 int zap_leader;
75201 repeat:
75202 +#ifdef CONFIG_NET
75203 + gr_del_task_from_ip_table(p);
75204 +#endif
75205 +
75206 /* don't need to get the RCU readlock here - the process is dead and
75207 * can't be modifying its own credentials. But shut RCU-lockdep up */
75208 rcu_read_lock();
75209 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75210 * know it'll be handled, so that they don't get converted to
75211 * SIGKILL or just silently dropped.
75212 */
75213 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75214 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75215 recalc_sigpending();
75216 spin_unlock_irq(&current->sighand->siglock);
75217 return 0;
75218 @@ -708,6 +712,8 @@ void do_exit(long code)
75219 struct task_struct *tsk = current;
75220 int group_dead;
75221
75222 + set_fs(USER_DS);
75223 +
75224 profile_task_exit(tsk);
75225
75226 WARN_ON(blk_needs_flush_plug(tsk));
75227 @@ -724,7 +730,6 @@ void do_exit(long code)
75228 * mm_release()->clear_child_tid() from writing to a user-controlled
75229 * kernel address.
75230 */
75231 - set_fs(USER_DS);
75232
75233 ptrace_event(PTRACE_EVENT_EXIT, code);
75234
75235 @@ -783,6 +788,9 @@ void do_exit(long code)
75236 tsk->exit_code = code;
75237 taskstats_exit(tsk, group_dead);
75238
75239 + gr_acl_handle_psacct(tsk, code);
75240 + gr_acl_handle_exit();
75241 +
75242 exit_mm(tsk);
75243
75244 if (group_dead)
75245 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75246 * Take down every thread in the group. This is called by fatal signals
75247 * as well as by sys_exit_group (below).
75248 */
75249 -void
75250 +__noreturn void
75251 do_group_exit(int exit_code)
75252 {
75253 struct signal_struct *sig = current->signal;
75254 diff --git a/kernel/fork.c b/kernel/fork.c
75255 index 5630e52..0cee608 100644
75256 --- a/kernel/fork.c
75257 +++ b/kernel/fork.c
75258 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75259 *stackend = STACK_END_MAGIC; /* for overflow detection */
75260
75261 #ifdef CONFIG_CC_STACKPROTECTOR
75262 - tsk->stack_canary = get_random_int();
75263 + tsk->stack_canary = pax_get_random_long();
75264 #endif
75265
75266 /*
75267 @@ -344,13 +344,81 @@ free_tsk:
75268 }
75269
75270 #ifdef CONFIG_MMU
75271 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75272 +{
75273 + struct vm_area_struct *tmp;
75274 + unsigned long charge;
75275 + struct mempolicy *pol;
75276 + struct file *file;
75277 +
75278 + charge = 0;
75279 + if (mpnt->vm_flags & VM_ACCOUNT) {
75280 + unsigned long len = vma_pages(mpnt);
75281 +
75282 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75283 + goto fail_nomem;
75284 + charge = len;
75285 + }
75286 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75287 + if (!tmp)
75288 + goto fail_nomem;
75289 + *tmp = *mpnt;
75290 + tmp->vm_mm = mm;
75291 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75292 + pol = mpol_dup(vma_policy(mpnt));
75293 + if (IS_ERR(pol))
75294 + goto fail_nomem_policy;
75295 + vma_set_policy(tmp, pol);
75296 + if (anon_vma_fork(tmp, mpnt))
75297 + goto fail_nomem_anon_vma_fork;
75298 + tmp->vm_flags &= ~VM_LOCKED;
75299 + tmp->vm_next = tmp->vm_prev = NULL;
75300 + tmp->vm_mirror = NULL;
75301 + file = tmp->vm_file;
75302 + if (file) {
75303 + struct inode *inode = file->f_path.dentry->d_inode;
75304 + struct address_space *mapping = file->f_mapping;
75305 +
75306 + get_file(file);
75307 + if (tmp->vm_flags & VM_DENYWRITE)
75308 + atomic_dec(&inode->i_writecount);
75309 + mutex_lock(&mapping->i_mmap_mutex);
75310 + if (tmp->vm_flags & VM_SHARED)
75311 + mapping->i_mmap_writable++;
75312 + flush_dcache_mmap_lock(mapping);
75313 + /* insert tmp into the share list, just after mpnt */
75314 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75315 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75316 + else
75317 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75318 + flush_dcache_mmap_unlock(mapping);
75319 + mutex_unlock(&mapping->i_mmap_mutex);
75320 + }
75321 +
75322 + /*
75323 + * Clear hugetlb-related page reserves for children. This only
75324 + * affects MAP_PRIVATE mappings. Faults generated by the child
75325 + * are not guaranteed to succeed, even if read-only
75326 + */
75327 + if (is_vm_hugetlb_page(tmp))
75328 + reset_vma_resv_huge_pages(tmp);
75329 +
75330 + return tmp;
75331 +
75332 +fail_nomem_anon_vma_fork:
75333 + mpol_put(pol);
75334 +fail_nomem_policy:
75335 + kmem_cache_free(vm_area_cachep, tmp);
75336 +fail_nomem:
75337 + vm_unacct_memory(charge);
75338 + return NULL;
75339 +}
75340 +
75341 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75342 {
75343 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75344 struct rb_node **rb_link, *rb_parent;
75345 int retval;
75346 - unsigned long charge;
75347 - struct mempolicy *pol;
75348
75349 uprobe_start_dup_mmap();
75350 down_write(&oldmm->mmap_sem);
75351 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75352 mm->locked_vm = 0;
75353 mm->mmap = NULL;
75354 mm->mmap_cache = NULL;
75355 - mm->free_area_cache = oldmm->mmap_base;
75356 - mm->cached_hole_size = ~0UL;
75357 + mm->free_area_cache = oldmm->free_area_cache;
75358 + mm->cached_hole_size = oldmm->cached_hole_size;
75359 mm->map_count = 0;
75360 cpumask_clear(mm_cpumask(mm));
75361 mm->mm_rb = RB_ROOT;
75362 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75363
75364 prev = NULL;
75365 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75366 - struct file *file;
75367 -
75368 if (mpnt->vm_flags & VM_DONTCOPY) {
75369 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75370 -vma_pages(mpnt));
75371 continue;
75372 }
75373 - charge = 0;
75374 - if (mpnt->vm_flags & VM_ACCOUNT) {
75375 - unsigned long len = vma_pages(mpnt);
75376 -
75377 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75378 - goto fail_nomem;
75379 - charge = len;
75380 - }
75381 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75382 - if (!tmp)
75383 - goto fail_nomem;
75384 - *tmp = *mpnt;
75385 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75386 - pol = mpol_dup(vma_policy(mpnt));
75387 - retval = PTR_ERR(pol);
75388 - if (IS_ERR(pol))
75389 - goto fail_nomem_policy;
75390 - vma_set_policy(tmp, pol);
75391 - tmp->vm_mm = mm;
75392 - if (anon_vma_fork(tmp, mpnt))
75393 - goto fail_nomem_anon_vma_fork;
75394 - tmp->vm_flags &= ~VM_LOCKED;
75395 - tmp->vm_next = tmp->vm_prev = NULL;
75396 - file = tmp->vm_file;
75397 - if (file) {
75398 - struct inode *inode = file->f_path.dentry->d_inode;
75399 - struct address_space *mapping = file->f_mapping;
75400 -
75401 - get_file(file);
75402 - if (tmp->vm_flags & VM_DENYWRITE)
75403 - atomic_dec(&inode->i_writecount);
75404 - mutex_lock(&mapping->i_mmap_mutex);
75405 - if (tmp->vm_flags & VM_SHARED)
75406 - mapping->i_mmap_writable++;
75407 - flush_dcache_mmap_lock(mapping);
75408 - /* insert tmp into the share list, just after mpnt */
75409 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75410 - vma_nonlinear_insert(tmp,
75411 - &mapping->i_mmap_nonlinear);
75412 - else
75413 - vma_interval_tree_insert_after(tmp, mpnt,
75414 - &mapping->i_mmap);
75415 - flush_dcache_mmap_unlock(mapping);
75416 - mutex_unlock(&mapping->i_mmap_mutex);
75417 + tmp = dup_vma(mm, oldmm, mpnt);
75418 + if (!tmp) {
75419 + retval = -ENOMEM;
75420 + goto out;
75421 }
75422
75423 /*
75424 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75425 if (retval)
75426 goto out;
75427 }
75428 +
75429 +#ifdef CONFIG_PAX_SEGMEXEC
75430 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75431 + struct vm_area_struct *mpnt_m;
75432 +
75433 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75434 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75435 +
75436 + if (!mpnt->vm_mirror)
75437 + continue;
75438 +
75439 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75440 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75441 + mpnt->vm_mirror = mpnt_m;
75442 + } else {
75443 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75444 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75445 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75446 + mpnt->vm_mirror->vm_mirror = mpnt;
75447 + }
75448 + }
75449 + BUG_ON(mpnt_m);
75450 + }
75451 +#endif
75452 +
75453 /* a new mm has just been created */
75454 arch_dup_mmap(oldmm, mm);
75455 retval = 0;
75456 @@ -472,14 +523,6 @@ out:
75457 up_write(&oldmm->mmap_sem);
75458 uprobe_end_dup_mmap();
75459 return retval;
75460 -fail_nomem_anon_vma_fork:
75461 - mpol_put(pol);
75462 -fail_nomem_policy:
75463 - kmem_cache_free(vm_area_cachep, tmp);
75464 -fail_nomem:
75465 - retval = -ENOMEM;
75466 - vm_unacct_memory(charge);
75467 - goto out;
75468 }
75469
75470 static inline int mm_alloc_pgd(struct mm_struct *mm)
75471 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75472 return ERR_PTR(err);
75473
75474 mm = get_task_mm(task);
75475 - if (mm && mm != current->mm &&
75476 - !ptrace_may_access(task, mode)) {
75477 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75478 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75479 mmput(mm);
75480 mm = ERR_PTR(-EACCES);
75481 }
75482 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75483 spin_unlock(&fs->lock);
75484 return -EAGAIN;
75485 }
75486 - fs->users++;
75487 + atomic_inc(&fs->users);
75488 spin_unlock(&fs->lock);
75489 return 0;
75490 }
75491 tsk->fs = copy_fs_struct(fs);
75492 if (!tsk->fs)
75493 return -ENOMEM;
75494 + /* Carry through gr_chroot_dentry and is_chrooted instead
75495 + of recomputing it here. Already copied when the task struct
75496 + is duplicated. This allows pivot_root to not be treated as
75497 + a chroot
75498 + */
75499 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75500 +
75501 return 0;
75502 }
75503
75504 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75505 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75506 #endif
75507 retval = -EAGAIN;
75508 +
75509 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75510 +
75511 if (atomic_read(&p->real_cred->user->processes) >=
75512 task_rlimit(p, RLIMIT_NPROC)) {
75513 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75514 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75515 goto bad_fork_free_pid;
75516 }
75517
75518 + /* synchronizes with gr_set_acls()
75519 + we need to call this past the point of no return for fork()
75520 + */
75521 + gr_copy_label(p);
75522 +
75523 if (clone_flags & CLONE_THREAD) {
75524 current->signal->nr_threads++;
75525 atomic_inc(&current->signal->live);
75526 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75527 bad_fork_free:
75528 free_task(p);
75529 fork_out:
75530 + gr_log_forkfail(retval);
75531 +
75532 return ERR_PTR(retval);
75533 }
75534
75535 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75536 return -EINVAL;
75537 }
75538
75539 +#ifdef CONFIG_GRKERNSEC
75540 + if (clone_flags & CLONE_NEWUSER) {
75541 + /*
75542 + * This doesn't really inspire confidence:
75543 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75544 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75545 + * Increases kernel attack surface in areas developers
75546 + * previously cared little about ("low importance due
75547 + * to requiring "root" capability")
75548 + * To be removed when this code receives *proper* review
75549 + */
75550 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75551 + !capable(CAP_SETGID))
75552 + return -EPERM;
75553 + }
75554 +#endif
75555 +
75556 /*
75557 * Determine whether and which event to report to ptracer. When
75558 * called from kernel_thread or CLONE_UNTRACED is explicitly
75559 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75560 if (clone_flags & CLONE_PARENT_SETTID)
75561 put_user(nr, parent_tidptr);
75562
75563 + gr_handle_brute_check();
75564 +
75565 if (clone_flags & CLONE_VFORK) {
75566 p->vfork_done = &vfork;
75567 init_completion(&vfork);
75568 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75569 return 0;
75570
75571 /* don't need lock here; in the worst case we'll do useless copy */
75572 - if (fs->users == 1)
75573 + if (atomic_read(&fs->users) == 1)
75574 return 0;
75575
75576 *new_fsp = copy_fs_struct(fs);
75577 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75578 fs = current->fs;
75579 spin_lock(&fs->lock);
75580 current->fs = new_fs;
75581 - if (--fs->users)
75582 + gr_set_chroot_entries(current, &current->fs->root);
75583 + if (atomic_dec_return(&fs->users))
75584 new_fs = NULL;
75585 else
75586 new_fs = fs;
75587 diff --git a/kernel/futex.c b/kernel/futex.c
75588 index 8879430..31696f1 100644
75589 --- a/kernel/futex.c
75590 +++ b/kernel/futex.c
75591 @@ -54,6 +54,7 @@
75592 #include <linux/mount.h>
75593 #include <linux/pagemap.h>
75594 #include <linux/syscalls.h>
75595 +#include <linux/ptrace.h>
75596 #include <linux/signal.h>
75597 #include <linux/export.h>
75598 #include <linux/magic.h>
75599 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75600 struct page *page, *page_head;
75601 int err, ro = 0;
75602
75603 +#ifdef CONFIG_PAX_SEGMEXEC
75604 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75605 + return -EFAULT;
75606 +#endif
75607 +
75608 /*
75609 * The futex address must be "naturally" aligned.
75610 */
75611 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75612 {
75613 u32 curval;
75614 int i;
75615 + mm_segment_t oldfs;
75616
75617 /*
75618 * This will fail and we want it. Some arch implementations do
75619 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75620 * implementation, the non-functional ones will return
75621 * -ENOSYS.
75622 */
75623 + oldfs = get_fs();
75624 + set_fs(USER_DS);
75625 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75626 futex_cmpxchg_enabled = 1;
75627 + set_fs(oldfs);
75628
75629 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75630 plist_head_init(&futex_queues[i].chain);
75631 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75632 index a9642d5..51eb98c 100644
75633 --- a/kernel/futex_compat.c
75634 +++ b/kernel/futex_compat.c
75635 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75636 return 0;
75637 }
75638
75639 -static void __user *futex_uaddr(struct robust_list __user *entry,
75640 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75641 compat_long_t futex_offset)
75642 {
75643 compat_uptr_t base = ptr_to_compat(entry);
75644 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75645 index 9b22d03..6295b62 100644
75646 --- a/kernel/gcov/base.c
75647 +++ b/kernel/gcov/base.c
75648 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75649 }
75650
75651 #ifdef CONFIG_MODULES
75652 -static inline int within(void *addr, void *start, unsigned long size)
75653 -{
75654 - return ((addr >= start) && (addr < start + size));
75655 -}
75656 -
75657 /* Update list and generate events when modules are unloaded. */
75658 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75659 void *data)
75660 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75661 prev = NULL;
75662 /* Remove entries located in module from linked list. */
75663 for (info = gcov_info_head; info; info = info->next) {
75664 - if (within(info, mod->module_core, mod->core_size)) {
75665 + if (within_module_core_rw((unsigned long)info, mod)) {
75666 if (prev)
75667 prev->next = info->next;
75668 else
75669 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75670 index 60f7e32..76ccd96 100644
75671 --- a/kernel/hrtimer.c
75672 +++ b/kernel/hrtimer.c
75673 @@ -1414,7 +1414,7 @@ void hrtimer_peek_ahead_timers(void)
75674 local_irq_restore(flags);
75675 }
75676
75677 -static void run_hrtimer_softirq(struct softirq_action *h)
75678 +static void run_hrtimer_softirq(void)
75679 {
75680 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75681
75682 @@ -1756,7 +1756,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75683 return NOTIFY_OK;
75684 }
75685
75686 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75687 +static struct notifier_block hrtimers_nb = {
75688 .notifier_call = hrtimer_cpu_notify,
75689 };
75690
75691 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75692 index 60f48fa..7f3a770 100644
75693 --- a/kernel/jump_label.c
75694 +++ b/kernel/jump_label.c
75695 @@ -13,6 +13,7 @@
75696 #include <linux/sort.h>
75697 #include <linux/err.h>
75698 #include <linux/static_key.h>
75699 +#include <linux/mm.h>
75700
75701 #ifdef HAVE_JUMP_LABEL
75702
75703 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75704
75705 size = (((unsigned long)stop - (unsigned long)start)
75706 / sizeof(struct jump_entry));
75707 + pax_open_kernel();
75708 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75709 + pax_close_kernel();
75710 }
75711
75712 static void jump_label_update(struct static_key *key, int enable);
75713 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75714 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75715 struct jump_entry *iter;
75716
75717 + pax_open_kernel();
75718 for (iter = iter_start; iter < iter_stop; iter++) {
75719 if (within_module_init(iter->code, mod))
75720 iter->code = 0;
75721 }
75722 + pax_close_kernel();
75723 }
75724
75725 static int
75726 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75727 index 2169fee..706ccca 100644
75728 --- a/kernel/kallsyms.c
75729 +++ b/kernel/kallsyms.c
75730 @@ -11,6 +11,9 @@
75731 * Changed the compression method from stem compression to "table lookup"
75732 * compression (see scripts/kallsyms.c for a more complete description)
75733 */
75734 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75735 +#define __INCLUDED_BY_HIDESYM 1
75736 +#endif
75737 #include <linux/kallsyms.h>
75738 #include <linux/module.h>
75739 #include <linux/init.h>
75740 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75741
75742 static inline int is_kernel_inittext(unsigned long addr)
75743 {
75744 + if (system_state != SYSTEM_BOOTING)
75745 + return 0;
75746 +
75747 if (addr >= (unsigned long)_sinittext
75748 && addr <= (unsigned long)_einittext)
75749 return 1;
75750 return 0;
75751 }
75752
75753 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75754 +#ifdef CONFIG_MODULES
75755 +static inline int is_module_text(unsigned long addr)
75756 +{
75757 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75758 + return 1;
75759 +
75760 + addr = ktla_ktva(addr);
75761 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75762 +}
75763 +#else
75764 +static inline int is_module_text(unsigned long addr)
75765 +{
75766 + return 0;
75767 +}
75768 +#endif
75769 +#endif
75770 +
75771 static inline int is_kernel_text(unsigned long addr)
75772 {
75773 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75774 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75775
75776 static inline int is_kernel(unsigned long addr)
75777 {
75778 +
75779 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75780 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75781 + return 1;
75782 +
75783 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75784 +#else
75785 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75786 +#endif
75787 +
75788 return 1;
75789 return in_gate_area_no_mm(addr);
75790 }
75791
75792 static int is_ksym_addr(unsigned long addr)
75793 {
75794 +
75795 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75796 + if (is_module_text(addr))
75797 + return 0;
75798 +#endif
75799 +
75800 if (all_var)
75801 return is_kernel(addr);
75802
75803 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75804
75805 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75806 {
75807 - iter->name[0] = '\0';
75808 iter->nameoff = get_symbol_offset(new_pos);
75809 iter->pos = new_pos;
75810 }
75811 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75812 {
75813 struct kallsym_iter *iter = m->private;
75814
75815 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75816 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75817 + return 0;
75818 +#endif
75819 +
75820 /* Some debugging symbols have no name. Ignore them. */
75821 if (!iter->name[0])
75822 return 0;
75823 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75824 */
75825 type = iter->exported ? toupper(iter->type) :
75826 tolower(iter->type);
75827 +
75828 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75829 type, iter->name, iter->module_name);
75830 } else
75831 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75832 struct kallsym_iter *iter;
75833 int ret;
75834
75835 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75836 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75837 if (!iter)
75838 return -ENOMEM;
75839 reset_iter(iter, 0);
75840 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75841 index e30ac0f..3528cac 100644
75842 --- a/kernel/kcmp.c
75843 +++ b/kernel/kcmp.c
75844 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75845 struct task_struct *task1, *task2;
75846 int ret;
75847
75848 +#ifdef CONFIG_GRKERNSEC
75849 + return -ENOSYS;
75850 +#endif
75851 +
75852 rcu_read_lock();
75853
75854 /*
75855 diff --git a/kernel/kexec.c b/kernel/kexec.c
75856 index 5e4bd78..00c5b91 100644
75857 --- a/kernel/kexec.c
75858 +++ b/kernel/kexec.c
75859 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75860 unsigned long flags)
75861 {
75862 struct compat_kexec_segment in;
75863 - struct kexec_segment out, __user *ksegments;
75864 + struct kexec_segment out;
75865 + struct kexec_segment __user *ksegments;
75866 unsigned long i, result;
75867
75868 /* Don't allow clients that don't understand the native
75869 diff --git a/kernel/kmod.c b/kernel/kmod.c
75870 index 0023a87..9c0c068 100644
75871 --- a/kernel/kmod.c
75872 +++ b/kernel/kmod.c
75873 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75874 kfree(info->argv);
75875 }
75876
75877 -static int call_modprobe(char *module_name, int wait)
75878 +static int call_modprobe(char *module_name, char *module_param, int wait)
75879 {
75880 static char *envp[] = {
75881 "HOME=/",
75882 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75883 NULL
75884 };
75885
75886 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75887 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75888 if (!argv)
75889 goto out;
75890
75891 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75892 argv[1] = "-q";
75893 argv[2] = "--";
75894 argv[3] = module_name; /* check free_modprobe_argv() */
75895 - argv[4] = NULL;
75896 + argv[4] = module_param;
75897 + argv[5] = NULL;
75898
75899 return call_usermodehelper_fns(modprobe_path, argv, envp,
75900 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75901 @@ -120,9 +121,8 @@ out:
75902 * If module auto-loading support is disabled then this function
75903 * becomes a no-operation.
75904 */
75905 -int __request_module(bool wait, const char *fmt, ...)
75906 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75907 {
75908 - va_list args;
75909 char module_name[MODULE_NAME_LEN];
75910 unsigned int max_modprobes;
75911 int ret;
75912 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75913 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75914 static int kmod_loop_msg;
75915
75916 - va_start(args, fmt);
75917 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75918 - va_end(args);
75919 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75920 if (ret >= MODULE_NAME_LEN)
75921 return -ENAMETOOLONG;
75922
75923 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75924 if (ret)
75925 return ret;
75926
75927 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75928 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75929 + /* hack to workaround consolekit/udisks stupidity */
75930 + read_lock(&tasklist_lock);
75931 + if (!strcmp(current->comm, "mount") &&
75932 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75933 + read_unlock(&tasklist_lock);
75934 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75935 + return -EPERM;
75936 + }
75937 + read_unlock(&tasklist_lock);
75938 + }
75939 +#endif
75940 +
75941 /* If modprobe needs a service that is in a module, we get a recursive
75942 * loop. Limit the number of running kmod threads to max_threads/2 or
75943 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75944 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75945
75946 trace_module_request(module_name, wait, _RET_IP_);
75947
75948 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75949 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75950
75951 atomic_dec(&kmod_concurrent);
75952 return ret;
75953 }
75954 +
75955 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75956 +{
75957 + va_list args;
75958 + int ret;
75959 +
75960 + va_start(args, fmt);
75961 + ret = ____request_module(wait, module_param, fmt, args);
75962 + va_end(args);
75963 +
75964 + return ret;
75965 +}
75966 +
75967 +int __request_module(bool wait, const char *fmt, ...)
75968 +{
75969 + va_list args;
75970 + int ret;
75971 +
75972 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75973 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75974 + char module_param[MODULE_NAME_LEN];
75975 +
75976 + memset(module_param, 0, sizeof(module_param));
75977 +
75978 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75979 +
75980 + va_start(args, fmt);
75981 + ret = ____request_module(wait, module_param, fmt, args);
75982 + va_end(args);
75983 +
75984 + return ret;
75985 + }
75986 +#endif
75987 +
75988 + va_start(args, fmt);
75989 + ret = ____request_module(wait, NULL, fmt, args);
75990 + va_end(args);
75991 +
75992 + return ret;
75993 +}
75994 +
75995 EXPORT_SYMBOL(__request_module);
75996 #endif /* CONFIG_MODULES */
75997
75998 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75999 *
76000 * Thus the __user pointer cast is valid here.
76001 */
76002 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76003 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76004
76005 /*
76006 * If ret is 0, either ____call_usermodehelper failed and the
76007 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
76008 static int proc_cap_handler(struct ctl_table *table, int write,
76009 void __user *buffer, size_t *lenp, loff_t *ppos)
76010 {
76011 - struct ctl_table t;
76012 + ctl_table_no_const t;
76013 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76014 kernel_cap_t new_cap;
76015 int err, i;
76016 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76017 index 098f396..fe85ff1 100644
76018 --- a/kernel/kprobes.c
76019 +++ b/kernel/kprobes.c
76020 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76021 * kernel image and loaded module images reside. This is required
76022 * so x86_64 can correctly handle the %rip-relative fixups.
76023 */
76024 - kip->insns = module_alloc(PAGE_SIZE);
76025 + kip->insns = module_alloc_exec(PAGE_SIZE);
76026 if (!kip->insns) {
76027 kfree(kip);
76028 return NULL;
76029 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76030 */
76031 if (!list_is_singular(&kip->list)) {
76032 list_del(&kip->list);
76033 - module_free(NULL, kip->insns);
76034 + module_free_exec(NULL, kip->insns);
76035 kfree(kip);
76036 }
76037 return 1;
76038 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
76039 {
76040 int i, err = 0;
76041 unsigned long offset = 0, size = 0;
76042 - char *modname, namebuf[128];
76043 + char *modname, namebuf[KSYM_NAME_LEN];
76044 const char *symbol_name;
76045 void *addr;
76046 struct kprobe_blackpoint *kb;
76047 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76048 kprobe_type = "k";
76049
76050 if (sym)
76051 - seq_printf(pi, "%p %s %s+0x%x %s ",
76052 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76053 p->addr, kprobe_type, sym, offset,
76054 (modname ? modname : " "));
76055 else
76056 - seq_printf(pi, "%p %s %p ",
76057 + seq_printf(pi, "%pK %s %pK ",
76058 p->addr, kprobe_type, p->addr);
76059
76060 if (!pp)
76061 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76062 const char *sym = NULL;
76063 unsigned int i = *(loff_t *) v;
76064 unsigned long offset = 0;
76065 - char *modname, namebuf[128];
76066 + char *modname, namebuf[KSYM_NAME_LEN];
76067
76068 head = &kprobe_table[i];
76069 preempt_disable();
76070 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76071 index 6ada93c..dce7d5d 100644
76072 --- a/kernel/ksysfs.c
76073 +++ b/kernel/ksysfs.c
76074 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76075 {
76076 if (count+1 > UEVENT_HELPER_PATH_LEN)
76077 return -ENOENT;
76078 + if (!capable(CAP_SYS_ADMIN))
76079 + return -EPERM;
76080 memcpy(uevent_helper, buf, count);
76081 uevent_helper[count] = '\0';
76082 if (count && uevent_helper[count-1] == '\n')
76083 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76084 return count;
76085 }
76086
76087 -static struct bin_attribute notes_attr = {
76088 +static bin_attribute_no_const notes_attr __read_only = {
76089 .attr = {
76090 .name = "notes",
76091 .mode = S_IRUGO,
76092 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76093 index 7981e5b..7f2105c 100644
76094 --- a/kernel/lockdep.c
76095 +++ b/kernel/lockdep.c
76096 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
76097 end = (unsigned long) &_end,
76098 addr = (unsigned long) obj;
76099
76100 +#ifdef CONFIG_PAX_KERNEXEC
76101 + start = ktla_ktva(start);
76102 +#endif
76103 +
76104 /*
76105 * static variable?
76106 */
76107 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76108 if (!static_obj(lock->key)) {
76109 debug_locks_off();
76110 printk("INFO: trying to register non-static key.\n");
76111 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76112 printk("the code is fine but needs lockdep annotation.\n");
76113 printk("turning off the locking correctness validator.\n");
76114 dump_stack();
76115 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76116 if (!class)
76117 return 0;
76118 }
76119 - atomic_inc((atomic_t *)&class->ops);
76120 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76121 if (very_verbose(class)) {
76122 printk("\nacquire class [%p] %s", class->key, class->name);
76123 if (class->name_version > 1)
76124 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76125 index b2c71c5..7b88d63 100644
76126 --- a/kernel/lockdep_proc.c
76127 +++ b/kernel/lockdep_proc.c
76128 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76129 return 0;
76130 }
76131
76132 - seq_printf(m, "%p", class->key);
76133 + seq_printf(m, "%pK", class->key);
76134 #ifdef CONFIG_DEBUG_LOCKDEP
76135 seq_printf(m, " OPS:%8ld", class->ops);
76136 #endif
76137 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76138
76139 list_for_each_entry(entry, &class->locks_after, entry) {
76140 if (entry->distance == 1) {
76141 - seq_printf(m, " -> [%p] ", entry->class->key);
76142 + seq_printf(m, " -> [%pK] ", entry->class->key);
76143 print_name(m, entry->class);
76144 seq_puts(m, "\n");
76145 }
76146 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76147 if (!class->key)
76148 continue;
76149
76150 - seq_printf(m, "[%p] ", class->key);
76151 + seq_printf(m, "[%pK] ", class->key);
76152 print_name(m, class);
76153 seq_puts(m, "\n");
76154 }
76155 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76156 if (!i)
76157 seq_line(m, '-', 40-namelen, namelen);
76158
76159 - snprintf(ip, sizeof(ip), "[<%p>]",
76160 + snprintf(ip, sizeof(ip), "[<%pK>]",
76161 (void *)class->contention_point[i]);
76162 seq_printf(m, "%40s %14lu %29s %pS\n",
76163 name, stats->contention_point[i],
76164 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76165 if (!i)
76166 seq_line(m, '-', 40-namelen, namelen);
76167
76168 - snprintf(ip, sizeof(ip), "[<%p>]",
76169 + snprintf(ip, sizeof(ip), "[<%pK>]",
76170 (void *)class->contending_point[i]);
76171 seq_printf(m, "%40s %14lu %29s %pS\n",
76172 name, stats->contending_point[i],
76173 diff --git a/kernel/module.c b/kernel/module.c
76174 index eab0827..f488603 100644
76175 --- a/kernel/module.c
76176 +++ b/kernel/module.c
76177 @@ -61,6 +61,7 @@
76178 #include <linux/pfn.h>
76179 #include <linux/bsearch.h>
76180 #include <linux/fips.h>
76181 +#include <linux/grsecurity.h>
76182 #include <uapi/linux/module.h>
76183 #include "module-internal.h"
76184
76185 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76186
76187 /* Bounds of module allocation, for speeding __module_address.
76188 * Protected by module_mutex. */
76189 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76190 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76191 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76192
76193 int register_module_notifier(struct notifier_block * nb)
76194 {
76195 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76196 return true;
76197
76198 list_for_each_entry_rcu(mod, &modules, list) {
76199 - struct symsearch arr[] = {
76200 + struct symsearch modarr[] = {
76201 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76202 NOT_GPL_ONLY, false },
76203 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76204 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76205 if (mod->state == MODULE_STATE_UNFORMED)
76206 continue;
76207
76208 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76209 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76210 return true;
76211 }
76212 return false;
76213 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76214 static int percpu_modalloc(struct module *mod,
76215 unsigned long size, unsigned long align)
76216 {
76217 - if (align > PAGE_SIZE) {
76218 + if (align-1 >= PAGE_SIZE) {
76219 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76220 mod->name, align, PAGE_SIZE);
76221 align = PAGE_SIZE;
76222 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76223 static ssize_t show_coresize(struct module_attribute *mattr,
76224 struct module_kobject *mk, char *buffer)
76225 {
76226 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76227 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76228 }
76229
76230 static struct module_attribute modinfo_coresize =
76231 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76232 static ssize_t show_initsize(struct module_attribute *mattr,
76233 struct module_kobject *mk, char *buffer)
76234 {
76235 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76236 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76237 }
76238
76239 static struct module_attribute modinfo_initsize =
76240 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76241 */
76242 #ifdef CONFIG_SYSFS
76243
76244 -#ifdef CONFIG_KALLSYMS
76245 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76246 static inline bool sect_empty(const Elf_Shdr *sect)
76247 {
76248 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76249 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76250 {
76251 unsigned int notes, loaded, i;
76252 struct module_notes_attrs *notes_attrs;
76253 - struct bin_attribute *nattr;
76254 + bin_attribute_no_const *nattr;
76255
76256 /* failed to create section attributes, so can't create notes */
76257 if (!mod->sect_attrs)
76258 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76259 static int module_add_modinfo_attrs(struct module *mod)
76260 {
76261 struct module_attribute *attr;
76262 - struct module_attribute *temp_attr;
76263 + module_attribute_no_const *temp_attr;
76264 int error = 0;
76265 int i;
76266
76267 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76268
76269 static void unset_module_core_ro_nx(struct module *mod)
76270 {
76271 - set_page_attributes(mod->module_core + mod->core_text_size,
76272 - mod->module_core + mod->core_size,
76273 + set_page_attributes(mod->module_core_rw,
76274 + mod->module_core_rw + mod->core_size_rw,
76275 set_memory_x);
76276 - set_page_attributes(mod->module_core,
76277 - mod->module_core + mod->core_ro_size,
76278 + set_page_attributes(mod->module_core_rx,
76279 + mod->module_core_rx + mod->core_size_rx,
76280 set_memory_rw);
76281 }
76282
76283 static void unset_module_init_ro_nx(struct module *mod)
76284 {
76285 - set_page_attributes(mod->module_init + mod->init_text_size,
76286 - mod->module_init + mod->init_size,
76287 + set_page_attributes(mod->module_init_rw,
76288 + mod->module_init_rw + mod->init_size_rw,
76289 set_memory_x);
76290 - set_page_attributes(mod->module_init,
76291 - mod->module_init + mod->init_ro_size,
76292 + set_page_attributes(mod->module_init_rx,
76293 + mod->module_init_rx + mod->init_size_rx,
76294 set_memory_rw);
76295 }
76296
76297 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76298 list_for_each_entry_rcu(mod, &modules, list) {
76299 if (mod->state == MODULE_STATE_UNFORMED)
76300 continue;
76301 - if ((mod->module_core) && (mod->core_text_size)) {
76302 - set_page_attributes(mod->module_core,
76303 - mod->module_core + mod->core_text_size,
76304 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76305 + set_page_attributes(mod->module_core_rx,
76306 + mod->module_core_rx + mod->core_size_rx,
76307 set_memory_rw);
76308 }
76309 - if ((mod->module_init) && (mod->init_text_size)) {
76310 - set_page_attributes(mod->module_init,
76311 - mod->module_init + mod->init_text_size,
76312 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76313 + set_page_attributes(mod->module_init_rx,
76314 + mod->module_init_rx + mod->init_size_rx,
76315 set_memory_rw);
76316 }
76317 }
76318 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76319 list_for_each_entry_rcu(mod, &modules, list) {
76320 if (mod->state == MODULE_STATE_UNFORMED)
76321 continue;
76322 - if ((mod->module_core) && (mod->core_text_size)) {
76323 - set_page_attributes(mod->module_core,
76324 - mod->module_core + mod->core_text_size,
76325 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76326 + set_page_attributes(mod->module_core_rx,
76327 + mod->module_core_rx + mod->core_size_rx,
76328 set_memory_ro);
76329 }
76330 - if ((mod->module_init) && (mod->init_text_size)) {
76331 - set_page_attributes(mod->module_init,
76332 - mod->module_init + mod->init_text_size,
76333 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76334 + set_page_attributes(mod->module_init_rx,
76335 + mod->module_init_rx + mod->init_size_rx,
76336 set_memory_ro);
76337 }
76338 }
76339 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76340
76341 /* This may be NULL, but that's OK */
76342 unset_module_init_ro_nx(mod);
76343 - module_free(mod, mod->module_init);
76344 + module_free(mod, mod->module_init_rw);
76345 + module_free_exec(mod, mod->module_init_rx);
76346 kfree(mod->args);
76347 percpu_modfree(mod);
76348
76349 /* Free lock-classes: */
76350 - lockdep_free_key_range(mod->module_core, mod->core_size);
76351 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76352 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76353
76354 /* Finally, free the core (containing the module structure) */
76355 unset_module_core_ro_nx(mod);
76356 - module_free(mod, mod->module_core);
76357 + module_free_exec(mod, mod->module_core_rx);
76358 + module_free(mod, mod->module_core_rw);
76359
76360 #ifdef CONFIG_MPU
76361 update_protections(current->mm);
76362 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76363 int ret = 0;
76364 const struct kernel_symbol *ksym;
76365
76366 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76367 + int is_fs_load = 0;
76368 + int register_filesystem_found = 0;
76369 + char *p;
76370 +
76371 + p = strstr(mod->args, "grsec_modharden_fs");
76372 + if (p) {
76373 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76374 + /* copy \0 as well */
76375 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76376 + is_fs_load = 1;
76377 + }
76378 +#endif
76379 +
76380 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76381 const char *name = info->strtab + sym[i].st_name;
76382
76383 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76384 + /* it's a real shame this will never get ripped and copied
76385 + upstream! ;(
76386 + */
76387 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76388 + register_filesystem_found = 1;
76389 +#endif
76390 +
76391 switch (sym[i].st_shndx) {
76392 case SHN_COMMON:
76393 /* We compiled with -fno-common. These are not
76394 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76395 ksym = resolve_symbol_wait(mod, info, name);
76396 /* Ok if resolved. */
76397 if (ksym && !IS_ERR(ksym)) {
76398 + pax_open_kernel();
76399 sym[i].st_value = ksym->value;
76400 + pax_close_kernel();
76401 break;
76402 }
76403
76404 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76405 secbase = (unsigned long)mod_percpu(mod);
76406 else
76407 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76408 + pax_open_kernel();
76409 sym[i].st_value += secbase;
76410 + pax_close_kernel();
76411 break;
76412 }
76413 }
76414
76415 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76416 + if (is_fs_load && !register_filesystem_found) {
76417 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76418 + ret = -EPERM;
76419 + }
76420 +#endif
76421 +
76422 return ret;
76423 }
76424
76425 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76426 || s->sh_entsize != ~0UL
76427 || strstarts(sname, ".init"))
76428 continue;
76429 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76430 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76431 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76432 + else
76433 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76434 pr_debug("\t%s\n", sname);
76435 }
76436 - switch (m) {
76437 - case 0: /* executable */
76438 - mod->core_size = debug_align(mod->core_size);
76439 - mod->core_text_size = mod->core_size;
76440 - break;
76441 - case 1: /* RO: text and ro-data */
76442 - mod->core_size = debug_align(mod->core_size);
76443 - mod->core_ro_size = mod->core_size;
76444 - break;
76445 - case 3: /* whole core */
76446 - mod->core_size = debug_align(mod->core_size);
76447 - break;
76448 - }
76449 }
76450
76451 pr_debug("Init section allocation order:\n");
76452 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76453 || s->sh_entsize != ~0UL
76454 || !strstarts(sname, ".init"))
76455 continue;
76456 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76457 - | INIT_OFFSET_MASK);
76458 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76459 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76460 + else
76461 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76462 + s->sh_entsize |= INIT_OFFSET_MASK;
76463 pr_debug("\t%s\n", sname);
76464 }
76465 - switch (m) {
76466 - case 0: /* executable */
76467 - mod->init_size = debug_align(mod->init_size);
76468 - mod->init_text_size = mod->init_size;
76469 - break;
76470 - case 1: /* RO: text and ro-data */
76471 - mod->init_size = debug_align(mod->init_size);
76472 - mod->init_ro_size = mod->init_size;
76473 - break;
76474 - case 3: /* whole init */
76475 - mod->init_size = debug_align(mod->init_size);
76476 - break;
76477 - }
76478 }
76479 }
76480
76481 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76482
76483 /* Put symbol section at end of init part of module. */
76484 symsect->sh_flags |= SHF_ALLOC;
76485 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76486 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76487 info->index.sym) | INIT_OFFSET_MASK;
76488 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76489
76490 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76491 }
76492
76493 /* Append room for core symbols at end of core part. */
76494 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76495 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76496 - mod->core_size += strtab_size;
76497 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76498 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76499 + mod->core_size_rx += strtab_size;
76500
76501 /* Put string table section at end of init part of module. */
76502 strsect->sh_flags |= SHF_ALLOC;
76503 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76504 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76505 info->index.str) | INIT_OFFSET_MASK;
76506 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76507 }
76508 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76509 /* Make sure we get permanent strtab: don't use info->strtab. */
76510 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76511
76512 + pax_open_kernel();
76513 +
76514 /* Set types up while we still have access to sections. */
76515 for (i = 0; i < mod->num_symtab; i++)
76516 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76517
76518 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76519 - mod->core_strtab = s = mod->module_core + info->stroffs;
76520 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76521 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76522 src = mod->symtab;
76523 for (ndst = i = 0; i < mod->num_symtab; i++) {
76524 if (i == 0 ||
76525 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76526 }
76527 }
76528 mod->core_num_syms = ndst;
76529 +
76530 + pax_close_kernel();
76531 }
76532 #else
76533 static inline void layout_symtab(struct module *mod, struct load_info *info)
76534 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76535 return vmalloc_exec(size);
76536 }
76537
76538 -static void *module_alloc_update_bounds(unsigned long size)
76539 +static void *module_alloc_update_bounds_rw(unsigned long size)
76540 {
76541 void *ret = module_alloc(size);
76542
76543 if (ret) {
76544 mutex_lock(&module_mutex);
76545 /* Update module bounds. */
76546 - if ((unsigned long)ret < module_addr_min)
76547 - module_addr_min = (unsigned long)ret;
76548 - if ((unsigned long)ret + size > module_addr_max)
76549 - module_addr_max = (unsigned long)ret + size;
76550 + if ((unsigned long)ret < module_addr_min_rw)
76551 + module_addr_min_rw = (unsigned long)ret;
76552 + if ((unsigned long)ret + size > module_addr_max_rw)
76553 + module_addr_max_rw = (unsigned long)ret + size;
76554 + mutex_unlock(&module_mutex);
76555 + }
76556 + return ret;
76557 +}
76558 +
76559 +static void *module_alloc_update_bounds_rx(unsigned long size)
76560 +{
76561 + void *ret = module_alloc_exec(size);
76562 +
76563 + if (ret) {
76564 + mutex_lock(&module_mutex);
76565 + /* Update module bounds. */
76566 + if ((unsigned long)ret < module_addr_min_rx)
76567 + module_addr_min_rx = (unsigned long)ret;
76568 + if ((unsigned long)ret + size > module_addr_max_rx)
76569 + module_addr_max_rx = (unsigned long)ret + size;
76570 mutex_unlock(&module_mutex);
76571 }
76572 return ret;
76573 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76574 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76575 {
76576 const char *modmagic = get_modinfo(info, "vermagic");
76577 + const char *license = get_modinfo(info, "license");
76578 int err;
76579
76580 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76581 + if (!license || !license_is_gpl_compatible(license))
76582 + return -ENOEXEC;
76583 +#endif
76584 +
76585 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76586 modmagic = NULL;
76587
76588 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76589 }
76590
76591 /* Set up license info based on the info section */
76592 - set_license(mod, get_modinfo(info, "license"));
76593 + set_license(mod, license);
76594
76595 return 0;
76596 }
76597 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76598 void *ptr;
76599
76600 /* Do the allocs. */
76601 - ptr = module_alloc_update_bounds(mod->core_size);
76602 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76603 /*
76604 * The pointer to this block is stored in the module structure
76605 * which is inside the block. Just mark it as not being a
76606 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76607 if (!ptr)
76608 return -ENOMEM;
76609
76610 - memset(ptr, 0, mod->core_size);
76611 - mod->module_core = ptr;
76612 + memset(ptr, 0, mod->core_size_rw);
76613 + mod->module_core_rw = ptr;
76614
76615 - if (mod->init_size) {
76616 - ptr = module_alloc_update_bounds(mod->init_size);
76617 + if (mod->init_size_rw) {
76618 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76619 /*
76620 * The pointer to this block is stored in the module structure
76621 * which is inside the block. This block doesn't need to be
76622 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76623 */
76624 kmemleak_ignore(ptr);
76625 if (!ptr) {
76626 - module_free(mod, mod->module_core);
76627 + module_free(mod, mod->module_core_rw);
76628 return -ENOMEM;
76629 }
76630 - memset(ptr, 0, mod->init_size);
76631 - mod->module_init = ptr;
76632 + memset(ptr, 0, mod->init_size_rw);
76633 + mod->module_init_rw = ptr;
76634 } else
76635 - mod->module_init = NULL;
76636 + mod->module_init_rw = NULL;
76637 +
76638 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76639 + kmemleak_not_leak(ptr);
76640 + if (!ptr) {
76641 + if (mod->module_init_rw)
76642 + module_free(mod, mod->module_init_rw);
76643 + module_free(mod, mod->module_core_rw);
76644 + return -ENOMEM;
76645 + }
76646 +
76647 + pax_open_kernel();
76648 + memset(ptr, 0, mod->core_size_rx);
76649 + pax_close_kernel();
76650 + mod->module_core_rx = ptr;
76651 +
76652 + if (mod->init_size_rx) {
76653 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76654 + kmemleak_ignore(ptr);
76655 + if (!ptr && mod->init_size_rx) {
76656 + module_free_exec(mod, mod->module_core_rx);
76657 + if (mod->module_init_rw)
76658 + module_free(mod, mod->module_init_rw);
76659 + module_free(mod, mod->module_core_rw);
76660 + return -ENOMEM;
76661 + }
76662 +
76663 + pax_open_kernel();
76664 + memset(ptr, 0, mod->init_size_rx);
76665 + pax_close_kernel();
76666 + mod->module_init_rx = ptr;
76667 + } else
76668 + mod->module_init_rx = NULL;
76669
76670 /* Transfer each section which specifies SHF_ALLOC */
76671 pr_debug("final section addresses:\n");
76672 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76673 if (!(shdr->sh_flags & SHF_ALLOC))
76674 continue;
76675
76676 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76677 - dest = mod->module_init
76678 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76679 - else
76680 - dest = mod->module_core + shdr->sh_entsize;
76681 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76682 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76683 + dest = mod->module_init_rw
76684 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76685 + else
76686 + dest = mod->module_init_rx
76687 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76688 + } else {
76689 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76690 + dest = mod->module_core_rw + shdr->sh_entsize;
76691 + else
76692 + dest = mod->module_core_rx + shdr->sh_entsize;
76693 + }
76694 +
76695 + if (shdr->sh_type != SHT_NOBITS) {
76696 +
76697 +#ifdef CONFIG_PAX_KERNEXEC
76698 +#ifdef CONFIG_X86_64
76699 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76700 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76701 +#endif
76702 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76703 + pax_open_kernel();
76704 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76705 + pax_close_kernel();
76706 + } else
76707 +#endif
76708
76709 - if (shdr->sh_type != SHT_NOBITS)
76710 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76711 + }
76712 /* Update sh_addr to point to copy in image. */
76713 - shdr->sh_addr = (unsigned long)dest;
76714 +
76715 +#ifdef CONFIG_PAX_KERNEXEC
76716 + if (shdr->sh_flags & SHF_EXECINSTR)
76717 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76718 + else
76719 +#endif
76720 +
76721 + shdr->sh_addr = (unsigned long)dest;
76722 pr_debug("\t0x%lx %s\n",
76723 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76724 }
76725 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76726 * Do it before processing of module parameters, so the module
76727 * can provide parameter accessor functions of its own.
76728 */
76729 - if (mod->module_init)
76730 - flush_icache_range((unsigned long)mod->module_init,
76731 - (unsigned long)mod->module_init
76732 - + mod->init_size);
76733 - flush_icache_range((unsigned long)mod->module_core,
76734 - (unsigned long)mod->module_core + mod->core_size);
76735 + if (mod->module_init_rx)
76736 + flush_icache_range((unsigned long)mod->module_init_rx,
76737 + (unsigned long)mod->module_init_rx
76738 + + mod->init_size_rx);
76739 + flush_icache_range((unsigned long)mod->module_core_rx,
76740 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76741
76742 set_fs(old_fs);
76743 }
76744 @@ -2983,8 +3088,10 @@ out:
76745 static void module_deallocate(struct module *mod, struct load_info *info)
76746 {
76747 percpu_modfree(mod);
76748 - module_free(mod, mod->module_init);
76749 - module_free(mod, mod->module_core);
76750 + module_free_exec(mod, mod->module_init_rx);
76751 + module_free_exec(mod, mod->module_core_rx);
76752 + module_free(mod, mod->module_init_rw);
76753 + module_free(mod, mod->module_core_rw);
76754 }
76755
76756 int __weak module_finalize(const Elf_Ehdr *hdr,
76757 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76758 static int post_relocation(struct module *mod, const struct load_info *info)
76759 {
76760 /* Sort exception table now relocations are done. */
76761 + pax_open_kernel();
76762 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76763 + pax_close_kernel();
76764
76765 /* Copy relocated percpu area over. */
76766 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76767 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76768 MODULE_STATE_COMING, mod);
76769
76770 /* Set RO and NX regions for core */
76771 - set_section_ro_nx(mod->module_core,
76772 - mod->core_text_size,
76773 - mod->core_ro_size,
76774 - mod->core_size);
76775 + set_section_ro_nx(mod->module_core_rx,
76776 + mod->core_size_rx,
76777 + mod->core_size_rx,
76778 + mod->core_size_rx);
76779
76780 /* Set RO and NX regions for init */
76781 - set_section_ro_nx(mod->module_init,
76782 - mod->init_text_size,
76783 - mod->init_ro_size,
76784 - mod->init_size);
76785 + set_section_ro_nx(mod->module_init_rx,
76786 + mod->init_size_rx,
76787 + mod->init_size_rx,
76788 + mod->init_size_rx);
76789
76790 do_mod_ctors(mod);
76791 /* Start the module */
76792 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76793 mod->strtab = mod->core_strtab;
76794 #endif
76795 unset_module_init_ro_nx(mod);
76796 - module_free(mod, mod->module_init);
76797 - mod->module_init = NULL;
76798 - mod->init_size = 0;
76799 - mod->init_ro_size = 0;
76800 - mod->init_text_size = 0;
76801 + module_free(mod, mod->module_init_rw);
76802 + module_free_exec(mod, mod->module_init_rx);
76803 + mod->module_init_rw = NULL;
76804 + mod->module_init_rx = NULL;
76805 + mod->init_size_rw = 0;
76806 + mod->init_size_rx = 0;
76807 mutex_unlock(&module_mutex);
76808 wake_up_all(&module_wq);
76809
76810 @@ -3209,9 +3319,38 @@ again:
76811 if (err)
76812 goto free_unload;
76813
76814 + /* Now copy in args */
76815 + mod->args = strndup_user(uargs, ~0UL >> 1);
76816 + if (IS_ERR(mod->args)) {
76817 + err = PTR_ERR(mod->args);
76818 + goto free_unload;
76819 + }
76820 +
76821 /* Set up MODINFO_ATTR fields */
76822 setup_modinfo(mod, info);
76823
76824 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76825 + {
76826 + char *p, *p2;
76827 +
76828 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76829 + 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);
76830 + err = -EPERM;
76831 + goto free_modinfo;
76832 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76833 + p += sizeof("grsec_modharden_normal") - 1;
76834 + p2 = strstr(p, "_");
76835 + if (p2) {
76836 + *p2 = '\0';
76837 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76838 + *p2 = '_';
76839 + }
76840 + err = -EPERM;
76841 + goto free_modinfo;
76842 + }
76843 + }
76844 +#endif
76845 +
76846 /* Fix up syms, so that st_value is a pointer to location. */
76847 err = simplify_symbols(mod, info);
76848 if (err < 0)
76849 @@ -3227,13 +3366,6 @@ again:
76850
76851 flush_module_icache(mod);
76852
76853 - /* Now copy in args */
76854 - mod->args = strndup_user(uargs, ~0UL >> 1);
76855 - if (IS_ERR(mod->args)) {
76856 - err = PTR_ERR(mod->args);
76857 - goto free_arch_cleanup;
76858 - }
76859 -
76860 dynamic_debug_setup(info->debug, info->num_debug);
76861
76862 mutex_lock(&module_mutex);
76863 @@ -3278,11 +3410,10 @@ again:
76864 mutex_unlock(&module_mutex);
76865 dynamic_debug_remove(info->debug);
76866 synchronize_sched();
76867 - kfree(mod->args);
76868 - free_arch_cleanup:
76869 module_arch_cleanup(mod);
76870 free_modinfo:
76871 free_modinfo(mod);
76872 + kfree(mod->args);
76873 free_unload:
76874 module_unload_free(mod);
76875 unlink_mod:
76876 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76877 unsigned long nextval;
76878
76879 /* At worse, next value is at end of module */
76880 - if (within_module_init(addr, mod))
76881 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76882 + if (within_module_init_rx(addr, mod))
76883 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76884 + else if (within_module_init_rw(addr, mod))
76885 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76886 + else if (within_module_core_rx(addr, mod))
76887 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76888 + else if (within_module_core_rw(addr, mod))
76889 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76890 else
76891 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76892 + return NULL;
76893
76894 /* Scan for closest preceding symbol, and next symbol. (ELF
76895 starts real symbols at 1). */
76896 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76897 return 0;
76898
76899 seq_printf(m, "%s %u",
76900 - mod->name, mod->init_size + mod->core_size);
76901 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76902 print_unload_info(m, mod);
76903
76904 /* Informative for users. */
76905 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76906 mod->state == MODULE_STATE_COMING ? "Loading":
76907 "Live");
76908 /* Used by oprofile and other similar tools. */
76909 - seq_printf(m, " 0x%pK", mod->module_core);
76910 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76911
76912 /* Taints info */
76913 if (mod->taints)
76914 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76915
76916 static int __init proc_modules_init(void)
76917 {
76918 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76919 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76920 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76921 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76922 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76923 +#else
76924 proc_create("modules", 0, NULL, &proc_modules_operations);
76925 +#endif
76926 +#else
76927 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76928 +#endif
76929 return 0;
76930 }
76931 module_init(proc_modules_init);
76932 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76933 {
76934 struct module *mod;
76935
76936 - if (addr < module_addr_min || addr > module_addr_max)
76937 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76938 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76939 return NULL;
76940
76941 list_for_each_entry_rcu(mod, &modules, list) {
76942 if (mod->state == MODULE_STATE_UNFORMED)
76943 continue;
76944 - if (within_module_core(addr, mod)
76945 - || within_module_init(addr, mod))
76946 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76947 return mod;
76948 }
76949 return NULL;
76950 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76951 */
76952 struct module *__module_text_address(unsigned long addr)
76953 {
76954 - struct module *mod = __module_address(addr);
76955 + struct module *mod;
76956 +
76957 +#ifdef CONFIG_X86_32
76958 + addr = ktla_ktva(addr);
76959 +#endif
76960 +
76961 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76962 + return NULL;
76963 +
76964 + mod = __module_address(addr);
76965 +
76966 if (mod) {
76967 /* Make sure it's within the text section. */
76968 - if (!within(addr, mod->module_init, mod->init_text_size)
76969 - && !within(addr, mod->module_core, mod->core_text_size))
76970 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76971 mod = NULL;
76972 }
76973 return mod;
76974 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76975 index 7e3443f..b2a1e6b 100644
76976 --- a/kernel/mutex-debug.c
76977 +++ b/kernel/mutex-debug.c
76978 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76979 }
76980
76981 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76982 - struct thread_info *ti)
76983 + struct task_struct *task)
76984 {
76985 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76986
76987 /* Mark the current thread as blocked on the lock: */
76988 - ti->task->blocked_on = waiter;
76989 + task->blocked_on = waiter;
76990 }
76991
76992 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76993 - struct thread_info *ti)
76994 + struct task_struct *task)
76995 {
76996 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76997 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76998 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76999 - ti->task->blocked_on = NULL;
77000 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77001 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77002 + task->blocked_on = NULL;
77003
77004 list_del_init(&waiter->list);
77005 waiter->task = NULL;
77006 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77007 index 0799fd3..d06ae3b 100644
77008 --- a/kernel/mutex-debug.h
77009 +++ b/kernel/mutex-debug.h
77010 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77011 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77012 extern void debug_mutex_add_waiter(struct mutex *lock,
77013 struct mutex_waiter *waiter,
77014 - struct thread_info *ti);
77015 + struct task_struct *task);
77016 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77017 - struct thread_info *ti);
77018 + struct task_struct *task);
77019 extern void debug_mutex_unlock(struct mutex *lock);
77020 extern void debug_mutex_init(struct mutex *lock, const char *name,
77021 struct lock_class_key *key);
77022 diff --git a/kernel/mutex.c b/kernel/mutex.c
77023 index a307cc9..27fd2e9 100644
77024 --- a/kernel/mutex.c
77025 +++ b/kernel/mutex.c
77026 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77027 spin_lock_mutex(&lock->wait_lock, flags);
77028
77029 debug_mutex_lock_common(lock, &waiter);
77030 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77031 + debug_mutex_add_waiter(lock, &waiter, task);
77032
77033 /* add waiting tasks to the end of the waitqueue (FIFO): */
77034 list_add_tail(&waiter.list, &lock->wait_list);
77035 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77036 * TASK_UNINTERRUPTIBLE case.)
77037 */
77038 if (unlikely(signal_pending_state(state, task))) {
77039 - mutex_remove_waiter(lock, &waiter,
77040 - task_thread_info(task));
77041 + mutex_remove_waiter(lock, &waiter, task);
77042 mutex_release(&lock->dep_map, 1, ip);
77043 spin_unlock_mutex(&lock->wait_lock, flags);
77044
77045 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
77046 done:
77047 lock_acquired(&lock->dep_map, ip);
77048 /* got the lock - rejoice! */
77049 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77050 + mutex_remove_waiter(lock, &waiter, task);
77051 mutex_set_owner(lock);
77052
77053 /* set it to 0 if there are no waiters left: */
77054 diff --git a/kernel/notifier.c b/kernel/notifier.c
77055 index 2d5cc4c..d9ea600 100644
77056 --- a/kernel/notifier.c
77057 +++ b/kernel/notifier.c
77058 @@ -5,6 +5,7 @@
77059 #include <linux/rcupdate.h>
77060 #include <linux/vmalloc.h>
77061 #include <linux/reboot.h>
77062 +#include <linux/mm.h>
77063
77064 /*
77065 * Notifier list for kernel code which wants to be called
77066 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77067 while ((*nl) != NULL) {
77068 if (n->priority > (*nl)->priority)
77069 break;
77070 - nl = &((*nl)->next);
77071 + nl = (struct notifier_block **)&((*nl)->next);
77072 }
77073 - n->next = *nl;
77074 + pax_open_kernel();
77075 + *(const void **)&n->next = *nl;
77076 rcu_assign_pointer(*nl, n);
77077 + pax_close_kernel();
77078 return 0;
77079 }
77080
77081 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77082 return 0;
77083 if (n->priority > (*nl)->priority)
77084 break;
77085 - nl = &((*nl)->next);
77086 + nl = (struct notifier_block **)&((*nl)->next);
77087 }
77088 - n->next = *nl;
77089 + pax_open_kernel();
77090 + *(const void **)&n->next = *nl;
77091 rcu_assign_pointer(*nl, n);
77092 + pax_close_kernel();
77093 return 0;
77094 }
77095
77096 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77097 {
77098 while ((*nl) != NULL) {
77099 if ((*nl) == n) {
77100 + pax_open_kernel();
77101 rcu_assign_pointer(*nl, n->next);
77102 + pax_close_kernel();
77103 return 0;
77104 }
77105 - nl = &((*nl)->next);
77106 + nl = (struct notifier_block **)&((*nl)->next);
77107 }
77108 return -ENOENT;
77109 }
77110 diff --git a/kernel/panic.c b/kernel/panic.c
77111 index e1b2822..5edc1d9 100644
77112 --- a/kernel/panic.c
77113 +++ b/kernel/panic.c
77114 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77115 const char *board;
77116
77117 printk(KERN_WARNING "------------[ cut here ]------------\n");
77118 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77119 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77120 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77121 if (board)
77122 printk(KERN_WARNING "Hardware name: %s\n", board);
77123 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77124 */
77125 void __stack_chk_fail(void)
77126 {
77127 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77128 + dump_stack();
77129 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77130 __builtin_return_address(0));
77131 }
77132 EXPORT_SYMBOL(__stack_chk_fail);
77133 diff --git a/kernel/pid.c b/kernel/pid.c
77134 index f2c6a68..4922d97 100644
77135 --- a/kernel/pid.c
77136 +++ b/kernel/pid.c
77137 @@ -33,6 +33,7 @@
77138 #include <linux/rculist.h>
77139 #include <linux/bootmem.h>
77140 #include <linux/hash.h>
77141 +#include <linux/security.h>
77142 #include <linux/pid_namespace.h>
77143 #include <linux/init_task.h>
77144 #include <linux/syscalls.h>
77145 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77146
77147 int pid_max = PID_MAX_DEFAULT;
77148
77149 -#define RESERVED_PIDS 300
77150 +#define RESERVED_PIDS 500
77151
77152 int pid_max_min = RESERVED_PIDS + 1;
77153 int pid_max_max = PID_MAX_LIMIT;
77154 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77155 */
77156 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77157 {
77158 + struct task_struct *task;
77159 +
77160 rcu_lockdep_assert(rcu_read_lock_held(),
77161 "find_task_by_pid_ns() needs rcu_read_lock()"
77162 " protection");
77163 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77164 +
77165 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77166 +
77167 + if (gr_pid_is_chrooted(task))
77168 + return NULL;
77169 +
77170 + return task;
77171 }
77172
77173 struct task_struct *find_task_by_vpid(pid_t vnr)
77174 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77175 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77176 }
77177
77178 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77179 +{
77180 + rcu_lockdep_assert(rcu_read_lock_held(),
77181 + "find_task_by_pid_ns() needs rcu_read_lock()"
77182 + " protection");
77183 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77184 +}
77185 +
77186 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77187 {
77188 struct pid *pid;
77189 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77190 index bea15bd..789f3d0 100644
77191 --- a/kernel/pid_namespace.c
77192 +++ b/kernel/pid_namespace.c
77193 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77194 void __user *buffer, size_t *lenp, loff_t *ppos)
77195 {
77196 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77197 - struct ctl_table tmp = *table;
77198 + ctl_table_no_const tmp = *table;
77199
77200 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77201 return -EPERM;
77202 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77203 index 942ca27..111e609 100644
77204 --- a/kernel/posix-cpu-timers.c
77205 +++ b/kernel/posix-cpu-timers.c
77206 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77207
77208 static __init int init_posix_cpu_timers(void)
77209 {
77210 - struct k_clock process = {
77211 + static struct k_clock process = {
77212 .clock_getres = process_cpu_clock_getres,
77213 .clock_get = process_cpu_clock_get,
77214 .timer_create = process_cpu_timer_create,
77215 .nsleep = process_cpu_nsleep,
77216 .nsleep_restart = process_cpu_nsleep_restart,
77217 };
77218 - struct k_clock thread = {
77219 + static struct k_clock thread = {
77220 .clock_getres = thread_cpu_clock_getres,
77221 .clock_get = thread_cpu_clock_get,
77222 .timer_create = thread_cpu_timer_create,
77223 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77224 index e885be1..380fe76 100644
77225 --- a/kernel/posix-timers.c
77226 +++ b/kernel/posix-timers.c
77227 @@ -43,6 +43,7 @@
77228 #include <linux/idr.h>
77229 #include <linux/posix-clock.h>
77230 #include <linux/posix-timers.h>
77231 +#include <linux/grsecurity.h>
77232 #include <linux/syscalls.h>
77233 #include <linux/wait.h>
77234 #include <linux/workqueue.h>
77235 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77236 * which we beg off on and pass to do_sys_settimeofday().
77237 */
77238
77239 -static struct k_clock posix_clocks[MAX_CLOCKS];
77240 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77241
77242 /*
77243 * These ones are defined below.
77244 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77245 */
77246 static __init int init_posix_timers(void)
77247 {
77248 - struct k_clock clock_realtime = {
77249 + static struct k_clock clock_realtime = {
77250 .clock_getres = hrtimer_get_res,
77251 .clock_get = posix_clock_realtime_get,
77252 .clock_set = posix_clock_realtime_set,
77253 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77254 .timer_get = common_timer_get,
77255 .timer_del = common_timer_del,
77256 };
77257 - struct k_clock clock_monotonic = {
77258 + static struct k_clock clock_monotonic = {
77259 .clock_getres = hrtimer_get_res,
77260 .clock_get = posix_ktime_get_ts,
77261 .nsleep = common_nsleep,
77262 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77263 .timer_get = common_timer_get,
77264 .timer_del = common_timer_del,
77265 };
77266 - struct k_clock clock_monotonic_raw = {
77267 + static struct k_clock clock_monotonic_raw = {
77268 .clock_getres = hrtimer_get_res,
77269 .clock_get = posix_get_monotonic_raw,
77270 };
77271 - struct k_clock clock_realtime_coarse = {
77272 + static struct k_clock clock_realtime_coarse = {
77273 .clock_getres = posix_get_coarse_res,
77274 .clock_get = posix_get_realtime_coarse,
77275 };
77276 - struct k_clock clock_monotonic_coarse = {
77277 + static struct k_clock clock_monotonic_coarse = {
77278 .clock_getres = posix_get_coarse_res,
77279 .clock_get = posix_get_monotonic_coarse,
77280 };
77281 - struct k_clock clock_boottime = {
77282 + static struct k_clock clock_boottime = {
77283 .clock_getres = hrtimer_get_res,
77284 .clock_get = posix_get_boottime,
77285 .nsleep = common_nsleep,
77286 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77287 return;
77288 }
77289
77290 - posix_clocks[clock_id] = *new_clock;
77291 + posix_clocks[clock_id] = new_clock;
77292 }
77293 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77294
77295 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77296 return (id & CLOCKFD_MASK) == CLOCKFD ?
77297 &clock_posix_dynamic : &clock_posix_cpu;
77298
77299 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77300 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77301 return NULL;
77302 - return &posix_clocks[id];
77303 + return posix_clocks[id];
77304 }
77305
77306 static int common_timer_create(struct k_itimer *new_timer)
77307 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77308 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77309 return -EFAULT;
77310
77311 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77312 + have their clock_set fptr set to a nosettime dummy function
77313 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77314 + call common_clock_set, which calls do_sys_settimeofday, which
77315 + we hook
77316 + */
77317 +
77318 return kc->clock_set(which_clock, &new_tp);
77319 }
77320
77321 diff --git a/kernel/power/process.c b/kernel/power/process.c
77322 index d5a258b..4271191 100644
77323 --- a/kernel/power/process.c
77324 +++ b/kernel/power/process.c
77325 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77326 u64 elapsed_csecs64;
77327 unsigned int elapsed_csecs;
77328 bool wakeup = false;
77329 + bool timedout = false;
77330
77331 do_gettimeofday(&start);
77332
77333 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77334
77335 while (true) {
77336 todo = 0;
77337 + if (time_after(jiffies, end_time))
77338 + timedout = true;
77339 read_lock(&tasklist_lock);
77340 do_each_thread(g, p) {
77341 if (p == current || !freeze_task(p))
77342 continue;
77343
77344 - if (!freezer_should_skip(p))
77345 + if (!freezer_should_skip(p)) {
77346 todo++;
77347 + if (timedout) {
77348 + printk(KERN_ERR "Task refusing to freeze:\n");
77349 + sched_show_task(p);
77350 + }
77351 + }
77352 } while_each_thread(g, p);
77353 read_unlock(&tasklist_lock);
77354
77355 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77356 todo += wq_busy;
77357 }
77358
77359 - if (!todo || time_after(jiffies, end_time))
77360 + if (!todo || timedout)
77361 break;
77362
77363 if (pm_wakeup_pending()) {
77364 diff --git a/kernel/printk.c b/kernel/printk.c
77365 index 267ce78..2487112 100644
77366 --- a/kernel/printk.c
77367 +++ b/kernel/printk.c
77368 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77369 return ret;
77370 }
77371
77372 +static int check_syslog_permissions(int type, bool from_file);
77373 +
77374 static int devkmsg_open(struct inode *inode, struct file *file)
77375 {
77376 struct devkmsg_user *user;
77377 int err;
77378
77379 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77380 + if (err)
77381 + return err;
77382 +
77383 /* write-only does not need any file context */
77384 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77385 return 0;
77386 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77387 if (dmesg_restrict)
77388 return 1;
77389 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77390 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77391 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77392 }
77393
77394 static int check_syslog_permissions(int type, bool from_file)
77395 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77396 if (from_file && type != SYSLOG_ACTION_OPEN)
77397 return 0;
77398
77399 +#ifdef CONFIG_GRKERNSEC_DMESG
77400 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77401 + return -EPERM;
77402 +#endif
77403 +
77404 if (syslog_action_restricted(type)) {
77405 if (capable(CAP_SYSLOG))
77406 return 0;
77407 diff --git a/kernel/profile.c b/kernel/profile.c
77408 index 1f39181..86093471 100644
77409 --- a/kernel/profile.c
77410 +++ b/kernel/profile.c
77411 @@ -40,7 +40,7 @@ struct profile_hit {
77412 /* Oprofile timer tick hook */
77413 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77414
77415 -static atomic_t *prof_buffer;
77416 +static atomic_unchecked_t *prof_buffer;
77417 static unsigned long prof_len, prof_shift;
77418
77419 int prof_on __read_mostly;
77420 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77421 hits[i].pc = 0;
77422 continue;
77423 }
77424 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77425 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77426 hits[i].hits = hits[i].pc = 0;
77427 }
77428 }
77429 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77430 * Add the current hit(s) and flush the write-queue out
77431 * to the global buffer:
77432 */
77433 - atomic_add(nr_hits, &prof_buffer[pc]);
77434 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77435 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77436 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77437 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77438 hits[i].pc = hits[i].hits = 0;
77439 }
77440 out:
77441 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77442 {
77443 unsigned long pc;
77444 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77445 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77446 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77447 }
77448 #endif /* !CONFIG_SMP */
77449
77450 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77451 return -EFAULT;
77452 buf++; p++; count--; read++;
77453 }
77454 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77455 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77456 if (copy_to_user(buf, (void *)pnt, count))
77457 return -EFAULT;
77458 read += count;
77459 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77460 }
77461 #endif
77462 profile_discard_flip_buffers();
77463 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77464 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77465 return count;
77466 }
77467
77468 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77469 index 6cbeaae..cfe7ff0 100644
77470 --- a/kernel/ptrace.c
77471 +++ b/kernel/ptrace.c
77472 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77473 if (seize)
77474 flags |= PT_SEIZED;
77475 rcu_read_lock();
77476 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77477 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77478 flags |= PT_PTRACE_CAP;
77479 rcu_read_unlock();
77480 task->ptrace = flags;
77481 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77482 break;
77483 return -EIO;
77484 }
77485 - if (copy_to_user(dst, buf, retval))
77486 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77487 return -EFAULT;
77488 copied += retval;
77489 src += retval;
77490 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77491 bool seized = child->ptrace & PT_SEIZED;
77492 int ret = -EIO;
77493 siginfo_t siginfo, *si;
77494 - void __user *datavp = (void __user *) data;
77495 + void __user *datavp = (__force void __user *) data;
77496 unsigned long __user *datalp = datavp;
77497 unsigned long flags;
77498
77499 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77500 goto out;
77501 }
77502
77503 + if (gr_handle_ptrace(child, request)) {
77504 + ret = -EPERM;
77505 + goto out_put_task_struct;
77506 + }
77507 +
77508 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77509 ret = ptrace_attach(child, request, addr, data);
77510 /*
77511 * Some architectures need to do book-keeping after
77512 * a ptrace attach.
77513 */
77514 - if (!ret)
77515 + if (!ret) {
77516 arch_ptrace_attach(child);
77517 + gr_audit_ptrace(child);
77518 + }
77519 goto out_put_task_struct;
77520 }
77521
77522 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77523 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77524 if (copied != sizeof(tmp))
77525 return -EIO;
77526 - return put_user(tmp, (unsigned long __user *)data);
77527 + return put_user(tmp, (__force unsigned long __user *)data);
77528 }
77529
77530 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77531 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77532 }
77533
77534 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77535 - compat_long_t addr, compat_long_t data)
77536 + compat_ulong_t addr, compat_ulong_t data)
77537 {
77538 struct task_struct *child;
77539 long ret;
77540 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77541 goto out;
77542 }
77543
77544 + if (gr_handle_ptrace(child, request)) {
77545 + ret = -EPERM;
77546 + goto out_put_task_struct;
77547 + }
77548 +
77549 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77550 ret = ptrace_attach(child, request, addr, data);
77551 /*
77552 * Some architectures need to do book-keeping after
77553 * a ptrace attach.
77554 */
77555 - if (!ret)
77556 + if (!ret) {
77557 arch_ptrace_attach(child);
77558 + gr_audit_ptrace(child);
77559 + }
77560 goto out_put_task_struct;
77561 }
77562
77563 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77564 index e7dce58..ad0d7b7 100644
77565 --- a/kernel/rcutiny.c
77566 +++ b/kernel/rcutiny.c
77567 @@ -46,7 +46,7 @@
77568 struct rcu_ctrlblk;
77569 static void invoke_rcu_callbacks(void);
77570 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77571 -static void rcu_process_callbacks(struct softirq_action *unused);
77572 +static void rcu_process_callbacks(void);
77573 static void __call_rcu(struct rcu_head *head,
77574 void (*func)(struct rcu_head *rcu),
77575 struct rcu_ctrlblk *rcp);
77576 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77577 rcu_is_callbacks_kthread()));
77578 }
77579
77580 -static void rcu_process_callbacks(struct softirq_action *unused)
77581 +static void rcu_process_callbacks(void)
77582 {
77583 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77584 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77585 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77586 index f85016a..91cb03b 100644
77587 --- a/kernel/rcutiny_plugin.h
77588 +++ b/kernel/rcutiny_plugin.h
77589 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77590 have_rcu_kthread_work = morework;
77591 local_irq_restore(flags);
77592 if (work)
77593 - rcu_process_callbacks(NULL);
77594 + rcu_process_callbacks();
77595 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77596 }
77597
77598 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77599 index 31dea01..ad91ffb 100644
77600 --- a/kernel/rcutorture.c
77601 +++ b/kernel/rcutorture.c
77602 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77603 { 0 };
77604 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77605 { 0 };
77606 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77607 -static atomic_t n_rcu_torture_alloc;
77608 -static atomic_t n_rcu_torture_alloc_fail;
77609 -static atomic_t n_rcu_torture_free;
77610 -static atomic_t n_rcu_torture_mberror;
77611 -static atomic_t n_rcu_torture_error;
77612 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77613 +static atomic_unchecked_t n_rcu_torture_alloc;
77614 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77615 +static atomic_unchecked_t n_rcu_torture_free;
77616 +static atomic_unchecked_t n_rcu_torture_mberror;
77617 +static atomic_unchecked_t n_rcu_torture_error;
77618 static long n_rcu_torture_barrier_error;
77619 static long n_rcu_torture_boost_ktrerror;
77620 static long n_rcu_torture_boost_rterror;
77621 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77622
77623 spin_lock_bh(&rcu_torture_lock);
77624 if (list_empty(&rcu_torture_freelist)) {
77625 - atomic_inc(&n_rcu_torture_alloc_fail);
77626 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77627 spin_unlock_bh(&rcu_torture_lock);
77628 return NULL;
77629 }
77630 - atomic_inc(&n_rcu_torture_alloc);
77631 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77632 p = rcu_torture_freelist.next;
77633 list_del_init(p);
77634 spin_unlock_bh(&rcu_torture_lock);
77635 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77636 static void
77637 rcu_torture_free(struct rcu_torture *p)
77638 {
77639 - atomic_inc(&n_rcu_torture_free);
77640 + atomic_inc_unchecked(&n_rcu_torture_free);
77641 spin_lock_bh(&rcu_torture_lock);
77642 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77643 spin_unlock_bh(&rcu_torture_lock);
77644 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77645 i = rp->rtort_pipe_count;
77646 if (i > RCU_TORTURE_PIPE_LEN)
77647 i = RCU_TORTURE_PIPE_LEN;
77648 - atomic_inc(&rcu_torture_wcount[i]);
77649 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77650 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77651 rp->rtort_mbtest = 0;
77652 rcu_torture_free(rp);
77653 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77654 i = rp->rtort_pipe_count;
77655 if (i > RCU_TORTURE_PIPE_LEN)
77656 i = RCU_TORTURE_PIPE_LEN;
77657 - atomic_inc(&rcu_torture_wcount[i]);
77658 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77659 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77660 rp->rtort_mbtest = 0;
77661 list_del(&rp->rtort_free);
77662 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77663 i = old_rp->rtort_pipe_count;
77664 if (i > RCU_TORTURE_PIPE_LEN)
77665 i = RCU_TORTURE_PIPE_LEN;
77666 - atomic_inc(&rcu_torture_wcount[i]);
77667 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77668 old_rp->rtort_pipe_count++;
77669 cur_ops->deferred_free(old_rp);
77670 }
77671 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77672 }
77673 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77674 if (p->rtort_mbtest == 0)
77675 - atomic_inc(&n_rcu_torture_mberror);
77676 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77677 spin_lock(&rand_lock);
77678 cur_ops->read_delay(&rand);
77679 n_rcu_torture_timers++;
77680 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77681 }
77682 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77683 if (p->rtort_mbtest == 0)
77684 - atomic_inc(&n_rcu_torture_mberror);
77685 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77686 cur_ops->read_delay(&rand);
77687 preempt_disable();
77688 pipe_count = p->rtort_pipe_count;
77689 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77690 rcu_torture_current,
77691 rcu_torture_current_version,
77692 list_empty(&rcu_torture_freelist),
77693 - atomic_read(&n_rcu_torture_alloc),
77694 - atomic_read(&n_rcu_torture_alloc_fail),
77695 - atomic_read(&n_rcu_torture_free));
77696 + atomic_read_unchecked(&n_rcu_torture_alloc),
77697 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77698 + atomic_read_unchecked(&n_rcu_torture_free));
77699 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77700 - atomic_read(&n_rcu_torture_mberror),
77701 + atomic_read_unchecked(&n_rcu_torture_mberror),
77702 n_rcu_torture_boost_ktrerror,
77703 n_rcu_torture_boost_rterror);
77704 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77705 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77706 n_barrier_attempts,
77707 n_rcu_torture_barrier_error);
77708 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77709 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77710 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77711 n_rcu_torture_barrier_error != 0 ||
77712 n_rcu_torture_boost_ktrerror != 0 ||
77713 n_rcu_torture_boost_rterror != 0 ||
77714 n_rcu_torture_boost_failure != 0 ||
77715 i > 1) {
77716 cnt += sprintf(&page[cnt], "!!! ");
77717 - atomic_inc(&n_rcu_torture_error);
77718 + atomic_inc_unchecked(&n_rcu_torture_error);
77719 WARN_ON_ONCE(1);
77720 }
77721 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77722 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77723 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77724 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77725 cnt += sprintf(&page[cnt], " %d",
77726 - atomic_read(&rcu_torture_wcount[i]));
77727 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77728 }
77729 cnt += sprintf(&page[cnt], "\n");
77730 if (cur_ops->stats)
77731 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77732
77733 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77734
77735 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77736 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77737 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77738 else if (n_online_successes != n_online_attempts ||
77739 n_offline_successes != n_offline_attempts)
77740 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77741
77742 rcu_torture_current = NULL;
77743 rcu_torture_current_version = 0;
77744 - atomic_set(&n_rcu_torture_alloc, 0);
77745 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77746 - atomic_set(&n_rcu_torture_free, 0);
77747 - atomic_set(&n_rcu_torture_mberror, 0);
77748 - atomic_set(&n_rcu_torture_error, 0);
77749 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77750 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77751 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77752 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77753 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77754 n_rcu_torture_barrier_error = 0;
77755 n_rcu_torture_boost_ktrerror = 0;
77756 n_rcu_torture_boost_rterror = 0;
77757 n_rcu_torture_boost_failure = 0;
77758 n_rcu_torture_boosts = 0;
77759 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77760 - atomic_set(&rcu_torture_wcount[i], 0);
77761 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77762 for_each_possible_cpu(cpu) {
77763 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77764 per_cpu(rcu_torture_count, cpu)[i] = 0;
77765 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77766 index e441b77..dd54f17 100644
77767 --- a/kernel/rcutree.c
77768 +++ b/kernel/rcutree.c
77769 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77770 rcu_prepare_for_idle(smp_processor_id());
77771 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77772 smp_mb__before_atomic_inc(); /* See above. */
77773 - atomic_inc(&rdtp->dynticks);
77774 + atomic_inc_unchecked(&rdtp->dynticks);
77775 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77776 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77777 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77778
77779 /*
77780 * It is illegal to enter an extended quiescent state while
77781 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77782 int user)
77783 {
77784 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77785 - atomic_inc(&rdtp->dynticks);
77786 + atomic_inc_unchecked(&rdtp->dynticks);
77787 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77788 smp_mb__after_atomic_inc(); /* See above. */
77789 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77790 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77791 rcu_cleanup_after_idle(smp_processor_id());
77792 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77793 if (!user && !is_idle_task(current)) {
77794 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77795 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77796
77797 if (rdtp->dynticks_nmi_nesting == 0 &&
77798 - (atomic_read(&rdtp->dynticks) & 0x1))
77799 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77800 return;
77801 rdtp->dynticks_nmi_nesting++;
77802 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77803 - atomic_inc(&rdtp->dynticks);
77804 + atomic_inc_unchecked(&rdtp->dynticks);
77805 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77806 smp_mb__after_atomic_inc(); /* See above. */
77807 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77808 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77809 }
77810
77811 /**
77812 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77813 return;
77814 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77815 smp_mb__before_atomic_inc(); /* See above. */
77816 - atomic_inc(&rdtp->dynticks);
77817 + atomic_inc_unchecked(&rdtp->dynticks);
77818 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77819 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77820 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77821 }
77822
77823 /**
77824 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77825 int ret;
77826
77827 preempt_disable();
77828 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77829 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77830 preempt_enable();
77831 return ret;
77832 }
77833 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77834 */
77835 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77836 {
77837 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77838 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77839 return (rdp->dynticks_snap & 0x1) == 0;
77840 }
77841
77842 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77843 unsigned int curr;
77844 unsigned int snap;
77845
77846 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77847 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77848 snap = (unsigned int)rdp->dynticks_snap;
77849
77850 /*
77851 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77852 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77853 */
77854 if (till_stall_check < 3) {
77855 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77856 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77857 till_stall_check = 3;
77858 } else if (till_stall_check > 300) {
77859 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77860 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77861 till_stall_check = 300;
77862 }
77863 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77864 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77865 rsp->qlen += rdp->qlen;
77866 rdp->n_cbs_orphaned += rdp->qlen;
77867 rdp->qlen_lazy = 0;
77868 - ACCESS_ONCE(rdp->qlen) = 0;
77869 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77870 }
77871
77872 /*
77873 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77874 }
77875 smp_mb(); /* List handling before counting for rcu_barrier(). */
77876 rdp->qlen_lazy -= count_lazy;
77877 - ACCESS_ONCE(rdp->qlen) -= count;
77878 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77879 rdp->n_cbs_invoked += count;
77880
77881 /* Reinstate batch limit if we have worked down the excess. */
77882 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77883 /*
77884 * Do RCU core processing for the current CPU.
77885 */
77886 -static void rcu_process_callbacks(struct softirq_action *unused)
77887 +static void rcu_process_callbacks(void)
77888 {
77889 struct rcu_state *rsp;
77890
77891 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77892 local_irq_restore(flags);
77893 return;
77894 }
77895 - ACCESS_ONCE(rdp->qlen)++;
77896 + ACCESS_ONCE_RW(rdp->qlen)++;
77897 if (lazy)
77898 rdp->qlen_lazy++;
77899 else
77900 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77901 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77902 * course be required on a 64-bit system.
77903 */
77904 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77905 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77906 (ulong)atomic_long_read(&rsp->expedited_done) +
77907 ULONG_MAX / 8)) {
77908 synchronize_sched();
77909 - atomic_long_inc(&rsp->expedited_wrap);
77910 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77911 return;
77912 }
77913
77914 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77915 * Take a ticket. Note that atomic_inc_return() implies a
77916 * full memory barrier.
77917 */
77918 - snap = atomic_long_inc_return(&rsp->expedited_start);
77919 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77920 firstsnap = snap;
77921 get_online_cpus();
77922 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77923 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77924 synchronize_sched_expedited_cpu_stop,
77925 NULL) == -EAGAIN) {
77926 put_online_cpus();
77927 - atomic_long_inc(&rsp->expedited_tryfail);
77928 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77929
77930 /* Check to see if someone else did our work for us. */
77931 s = atomic_long_read(&rsp->expedited_done);
77932 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77933 /* ensure test happens before caller kfree */
77934 smp_mb__before_atomic_inc(); /* ^^^ */
77935 - atomic_long_inc(&rsp->expedited_workdone1);
77936 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77937 return;
77938 }
77939
77940 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77941 udelay(trycount * num_online_cpus());
77942 } else {
77943 wait_rcu_gp(call_rcu_sched);
77944 - atomic_long_inc(&rsp->expedited_normal);
77945 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77946 return;
77947 }
77948
77949 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77950 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77951 /* ensure test happens before caller kfree */
77952 smp_mb__before_atomic_inc(); /* ^^^ */
77953 - atomic_long_inc(&rsp->expedited_workdone2);
77954 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77955 return;
77956 }
77957
77958 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77959 * period works for us.
77960 */
77961 get_online_cpus();
77962 - snap = atomic_long_read(&rsp->expedited_start);
77963 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77964 smp_mb(); /* ensure read is before try_stop_cpus(). */
77965 }
77966 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77967 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77968
77969 /*
77970 * Everyone up to our most recent fetch is covered by our grace
77971 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77972 * than we did already did their update.
77973 */
77974 do {
77975 - atomic_long_inc(&rsp->expedited_done_tries);
77976 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77977 s = atomic_long_read(&rsp->expedited_done);
77978 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77979 /* ensure test happens before caller kfree */
77980 smp_mb__before_atomic_inc(); /* ^^^ */
77981 - atomic_long_inc(&rsp->expedited_done_lost);
77982 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77983 break;
77984 }
77985 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77986 - atomic_long_inc(&rsp->expedited_done_exit);
77987 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77988
77989 put_online_cpus();
77990 }
77991 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77992 * ACCESS_ONCE() to prevent the compiler from speculating
77993 * the increment to precede the early-exit check.
77994 */
77995 - ACCESS_ONCE(rsp->n_barrier_done)++;
77996 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77997 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77998 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77999 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78000 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78001
78002 /* Increment ->n_barrier_done to prevent duplicate work. */
78003 smp_mb(); /* Keep increment after above mechanism. */
78004 - ACCESS_ONCE(rsp->n_barrier_done)++;
78005 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78006 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78007 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78008 smp_mb(); /* Keep increment before caller's subsequent code. */
78009 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78010 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78011 init_callback_list(rdp);
78012 rdp->qlen_lazy = 0;
78013 - ACCESS_ONCE(rdp->qlen) = 0;
78014 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78015 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78016 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78017 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78018 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78019 #ifdef CONFIG_RCU_USER_QS
78020 WARN_ON_ONCE(rdp->dynticks->in_user);
78021 #endif
78022 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78023 rdp->blimit = blimit;
78024 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78025 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78026 - atomic_set(&rdp->dynticks->dynticks,
78027 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78028 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78029 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78030 rcu_prepare_for_idle_init(cpu);
78031 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78032
78033 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78034 index 4b69291..704c92e 100644
78035 --- a/kernel/rcutree.h
78036 +++ b/kernel/rcutree.h
78037 @@ -86,7 +86,7 @@ struct rcu_dynticks {
78038 long long dynticks_nesting; /* Track irq/process nesting level. */
78039 /* Process level is worth LLONG_MAX/2. */
78040 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78041 - atomic_t dynticks; /* Even value for idle, else odd. */
78042 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78043 #ifdef CONFIG_RCU_FAST_NO_HZ
78044 int dyntick_drain; /* Prepare-for-idle state variable. */
78045 unsigned long dyntick_holdoff;
78046 @@ -423,17 +423,17 @@ struct rcu_state {
78047 /* _rcu_barrier(). */
78048 /* End of fields guarded by barrier_mutex. */
78049
78050 - atomic_long_t expedited_start; /* Starting ticket. */
78051 - atomic_long_t expedited_done; /* Done ticket. */
78052 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78053 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78054 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78055 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78056 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78057 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78058 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78059 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78060 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78061 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78062 + atomic_long_t expedited_done; /* Done ticket. */
78063 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78064 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78065 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78066 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78067 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78068 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78069 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78070 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78071 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78072
78073 unsigned long jiffies_force_qs; /* Time at which to invoke */
78074 /* force_quiescent_state(). */
78075 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78076 index c1cc7e1..f62e436 100644
78077 --- a/kernel/rcutree_plugin.h
78078 +++ b/kernel/rcutree_plugin.h
78079 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
78080
78081 /* Clean up and exit. */
78082 smp_mb(); /* ensure expedited GP seen before counter increment. */
78083 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78084 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78085 unlock_mb_ret:
78086 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78087 mb_ret:
78088 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78089 free_cpumask_var(cm);
78090 }
78091
78092 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78093 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78094 .store = &rcu_cpu_kthread_task,
78095 .thread_should_run = rcu_cpu_kthread_should_run,
78096 .thread_fn = rcu_cpu_kthread,
78097 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78098 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78099 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
78100 cpu, ticks_value, ticks_title,
78101 - atomic_read(&rdtp->dynticks) & 0xfff,
78102 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78103 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78104 fast_no_hz);
78105 }
78106 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78107
78108 /* Enqueue the callback on the nocb list and update counts. */
78109 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78110 - ACCESS_ONCE(*old_rhpp) = rhp;
78111 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78112 atomic_long_add(rhcount, &rdp->nocb_q_count);
78113 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78114
78115 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78116 * Extract queued callbacks, update counts, and wait
78117 * for a grace period to elapse.
78118 */
78119 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78120 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78121 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78122 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78123 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78124 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78125 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78126 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78127 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78128 wait_rcu_gp(rdp->rsp->call_remote);
78129
78130 /* Each pass through the following loop invokes a callback. */
78131 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78132 list = next;
78133 }
78134 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78135 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78136 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78137 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78138 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78139 rdp->n_nocbs_invoked += c;
78140 }
78141 return 0;
78142 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78143 rdp = per_cpu_ptr(rsp->rda, cpu);
78144 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78145 BUG_ON(IS_ERR(t));
78146 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78147 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78148 }
78149 }
78150
78151 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78152 index 93f8e8f..cf812ae 100644
78153 --- a/kernel/rcutree_trace.c
78154 +++ b/kernel/rcutree_trace.c
78155 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78156 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78157 rdp->passed_quiesce, rdp->qs_pending);
78158 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78159 - atomic_read(&rdp->dynticks->dynticks),
78160 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78161 rdp->dynticks->dynticks_nesting,
78162 rdp->dynticks->dynticks_nmi_nesting,
78163 rdp->dynticks_fqs);
78164 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78165 struct rcu_state *rsp = (struct rcu_state *)m->private;
78166
78167 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",
78168 - atomic_long_read(&rsp->expedited_start),
78169 + atomic_long_read_unchecked(&rsp->expedited_start),
78170 atomic_long_read(&rsp->expedited_done),
78171 - atomic_long_read(&rsp->expedited_wrap),
78172 - atomic_long_read(&rsp->expedited_tryfail),
78173 - atomic_long_read(&rsp->expedited_workdone1),
78174 - atomic_long_read(&rsp->expedited_workdone2),
78175 - atomic_long_read(&rsp->expedited_normal),
78176 - atomic_long_read(&rsp->expedited_stoppedcpus),
78177 - atomic_long_read(&rsp->expedited_done_tries),
78178 - atomic_long_read(&rsp->expedited_done_lost),
78179 - atomic_long_read(&rsp->expedited_done_exit));
78180 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78181 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78182 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78183 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78184 + atomic_long_read_unchecked(&rsp->expedited_normal),
78185 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78186 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78187 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78188 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78189 return 0;
78190 }
78191
78192 diff --git a/kernel/resource.c b/kernel/resource.c
78193 index 73f35d4..4684fc4 100644
78194 --- a/kernel/resource.c
78195 +++ b/kernel/resource.c
78196 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78197
78198 static int __init ioresources_init(void)
78199 {
78200 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78201 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78202 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78203 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78204 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78205 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78206 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78207 +#endif
78208 +#else
78209 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78210 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78211 +#endif
78212 return 0;
78213 }
78214 __initcall(ioresources_init);
78215 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78216 index 98ec494..4241d6d 100644
78217 --- a/kernel/rtmutex-tester.c
78218 +++ b/kernel/rtmutex-tester.c
78219 @@ -20,7 +20,7 @@
78220 #define MAX_RT_TEST_MUTEXES 8
78221
78222 static spinlock_t rttest_lock;
78223 -static atomic_t rttest_event;
78224 +static atomic_unchecked_t rttest_event;
78225
78226 struct test_thread_data {
78227 int opcode;
78228 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78229
78230 case RTTEST_LOCKCONT:
78231 td->mutexes[td->opdata] = 1;
78232 - td->event = atomic_add_return(1, &rttest_event);
78233 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78234 return 0;
78235
78236 case RTTEST_RESET:
78237 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78238 return 0;
78239
78240 case RTTEST_RESETEVENT:
78241 - atomic_set(&rttest_event, 0);
78242 + atomic_set_unchecked(&rttest_event, 0);
78243 return 0;
78244
78245 default:
78246 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78247 return ret;
78248
78249 td->mutexes[id] = 1;
78250 - td->event = atomic_add_return(1, &rttest_event);
78251 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78252 rt_mutex_lock(&mutexes[id]);
78253 - td->event = atomic_add_return(1, &rttest_event);
78254 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78255 td->mutexes[id] = 4;
78256 return 0;
78257
78258 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78259 return ret;
78260
78261 td->mutexes[id] = 1;
78262 - td->event = atomic_add_return(1, &rttest_event);
78263 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78264 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78265 - td->event = atomic_add_return(1, &rttest_event);
78266 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78267 td->mutexes[id] = ret ? 0 : 4;
78268 return ret ? -EINTR : 0;
78269
78270 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78271 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78272 return ret;
78273
78274 - td->event = atomic_add_return(1, &rttest_event);
78275 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78276 rt_mutex_unlock(&mutexes[id]);
78277 - td->event = atomic_add_return(1, &rttest_event);
78278 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78279 td->mutexes[id] = 0;
78280 return 0;
78281
78282 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78283 break;
78284
78285 td->mutexes[dat] = 2;
78286 - td->event = atomic_add_return(1, &rttest_event);
78287 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78288 break;
78289
78290 default:
78291 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78292 return;
78293
78294 td->mutexes[dat] = 3;
78295 - td->event = atomic_add_return(1, &rttest_event);
78296 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78297 break;
78298
78299 case RTTEST_LOCKNOWAIT:
78300 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78301 return;
78302
78303 td->mutexes[dat] = 1;
78304 - td->event = atomic_add_return(1, &rttest_event);
78305 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78306 return;
78307
78308 default:
78309 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78310 index 0984a21..939f183 100644
78311 --- a/kernel/sched/auto_group.c
78312 +++ b/kernel/sched/auto_group.c
78313 @@ -11,7 +11,7 @@
78314
78315 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78316 static struct autogroup autogroup_default;
78317 -static atomic_t autogroup_seq_nr;
78318 +static atomic_unchecked_t autogroup_seq_nr;
78319
78320 void __init autogroup_init(struct task_struct *init_task)
78321 {
78322 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78323
78324 kref_init(&ag->kref);
78325 init_rwsem(&ag->lock);
78326 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78327 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78328 ag->tg = tg;
78329 #ifdef CONFIG_RT_GROUP_SCHED
78330 /*
78331 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78332 index 5e2f7c3..4002d41 100644
78333 --- a/kernel/sched/core.c
78334 +++ b/kernel/sched/core.c
78335 @@ -3369,7 +3369,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78336 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78337 * positive (at least 1, or number of jiffies left till timeout) if completed.
78338 */
78339 -long __sched
78340 +long __sched __intentional_overflow(-1)
78341 wait_for_completion_interruptible_timeout(struct completion *x,
78342 unsigned long timeout)
78343 {
78344 @@ -3386,7 +3386,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78345 *
78346 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78347 */
78348 -int __sched wait_for_completion_killable(struct completion *x)
78349 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78350 {
78351 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78352 if (t == -ERESTARTSYS)
78353 @@ -3407,7 +3407,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78354 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78355 * positive (at least 1, or number of jiffies left till timeout) if completed.
78356 */
78357 -long __sched
78358 +long __sched __intentional_overflow(-1)
78359 wait_for_completion_killable_timeout(struct completion *x,
78360 unsigned long timeout)
78361 {
78362 @@ -3633,6 +3633,8 @@ int can_nice(const struct task_struct *p, const int nice)
78363 /* convert nice value [19,-20] to rlimit style value [1,40] */
78364 int nice_rlim = 20 - nice;
78365
78366 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78367 +
78368 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78369 capable(CAP_SYS_NICE));
78370 }
78371 @@ -3666,7 +3668,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78372 if (nice > 19)
78373 nice = 19;
78374
78375 - if (increment < 0 && !can_nice(current, nice))
78376 + if (increment < 0 && (!can_nice(current, nice) ||
78377 + gr_handle_chroot_nice()))
78378 return -EPERM;
78379
78380 retval = security_task_setnice(current, nice);
78381 @@ -3820,6 +3823,7 @@ recheck:
78382 unsigned long rlim_rtprio =
78383 task_rlimit(p, RLIMIT_RTPRIO);
78384
78385 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78386 /* can't set/change the rt policy */
78387 if (policy != p->policy && !rlim_rtprio)
78388 return -EPERM;
78389 @@ -4903,7 +4907,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78390
78391 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78392
78393 -static struct ctl_table sd_ctl_dir[] = {
78394 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78395 {
78396 .procname = "sched_domain",
78397 .mode = 0555,
78398 @@ -4920,17 +4924,17 @@ static struct ctl_table sd_ctl_root[] = {
78399 {}
78400 };
78401
78402 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78403 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78404 {
78405 - struct ctl_table *entry =
78406 + ctl_table_no_const *entry =
78407 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78408
78409 return entry;
78410 }
78411
78412 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78413 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78414 {
78415 - struct ctl_table *entry;
78416 + ctl_table_no_const *entry;
78417
78418 /*
78419 * In the intermediate directories, both the child directory and
78420 @@ -4938,22 +4942,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78421 * will always be set. In the lowest directory the names are
78422 * static strings and all have proc handlers.
78423 */
78424 - for (entry = *tablep; entry->mode; entry++) {
78425 - if (entry->child)
78426 - sd_free_ctl_entry(&entry->child);
78427 + for (entry = tablep; entry->mode; entry++) {
78428 + if (entry->child) {
78429 + sd_free_ctl_entry(entry->child);
78430 + pax_open_kernel();
78431 + entry->child = NULL;
78432 + pax_close_kernel();
78433 + }
78434 if (entry->proc_handler == NULL)
78435 kfree(entry->procname);
78436 }
78437
78438 - kfree(*tablep);
78439 - *tablep = NULL;
78440 + kfree(tablep);
78441 }
78442
78443 static int min_load_idx = 0;
78444 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78445
78446 static void
78447 -set_table_entry(struct ctl_table *entry,
78448 +set_table_entry(ctl_table_no_const *entry,
78449 const char *procname, void *data, int maxlen,
78450 umode_t mode, proc_handler *proc_handler,
78451 bool load_idx)
78452 @@ -4973,7 +4980,7 @@ set_table_entry(struct ctl_table *entry,
78453 static struct ctl_table *
78454 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78455 {
78456 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78457 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78458
78459 if (table == NULL)
78460 return NULL;
78461 @@ -5008,9 +5015,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78462 return table;
78463 }
78464
78465 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78466 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78467 {
78468 - struct ctl_table *entry, *table;
78469 + ctl_table_no_const *entry, *table;
78470 struct sched_domain *sd;
78471 int domain_num = 0, i;
78472 char buf[32];
78473 @@ -5037,11 +5044,13 @@ static struct ctl_table_header *sd_sysctl_header;
78474 static void register_sched_domain_sysctl(void)
78475 {
78476 int i, cpu_num = num_possible_cpus();
78477 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78478 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78479 char buf[32];
78480
78481 WARN_ON(sd_ctl_dir[0].child);
78482 + pax_open_kernel();
78483 sd_ctl_dir[0].child = entry;
78484 + pax_close_kernel();
78485
78486 if (entry == NULL)
78487 return;
78488 @@ -5064,8 +5073,12 @@ static void unregister_sched_domain_sysctl(void)
78489 if (sd_sysctl_header)
78490 unregister_sysctl_table(sd_sysctl_header);
78491 sd_sysctl_header = NULL;
78492 - if (sd_ctl_dir[0].child)
78493 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78494 + if (sd_ctl_dir[0].child) {
78495 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78496 + pax_open_kernel();
78497 + sd_ctl_dir[0].child = NULL;
78498 + pax_close_kernel();
78499 + }
78500 }
78501 #else
78502 static void register_sched_domain_sysctl(void)
78503 @@ -5164,7 +5177,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78504 * happens before everything else. This has to be lower priority than
78505 * the notifier in the perf_event subsystem, though.
78506 */
78507 -static struct notifier_block __cpuinitdata migration_notifier = {
78508 +static struct notifier_block migration_notifier = {
78509 .notifier_call = migration_call,
78510 .priority = CPU_PRI_MIGRATION,
78511 };
78512 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78513 index 81fa536..6ccf96a 100644
78514 --- a/kernel/sched/fair.c
78515 +++ b/kernel/sched/fair.c
78516 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78517
78518 static void reset_ptenuma_scan(struct task_struct *p)
78519 {
78520 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78521 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78522 p->mm->numa_scan_offset = 0;
78523 }
78524
78525 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78526 */
78527 static int select_idle_sibling(struct task_struct *p, int target)
78528 {
78529 - int cpu = smp_processor_id();
78530 - int prev_cpu = task_cpu(p);
78531 struct sched_domain *sd;
78532 struct sched_group *sg;
78533 - int i;
78534 + int i = task_cpu(p);
78535
78536 - /*
78537 - * If the task is going to be woken-up on this cpu and if it is
78538 - * already idle, then it is the right target.
78539 - */
78540 - if (target == cpu && idle_cpu(cpu))
78541 - return cpu;
78542 + if (idle_cpu(target))
78543 + return target;
78544
78545 /*
78546 - * If the task is going to be woken-up on the cpu where it previously
78547 - * ran and if it is currently idle, then it the right target.
78548 + * If the prevous cpu is cache affine and idle, don't be stupid.
78549 */
78550 - if (target == prev_cpu && idle_cpu(prev_cpu))
78551 - return prev_cpu;
78552 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78553 + return i;
78554
78555 /*
78556 * Otherwise, iterate the domains and find an elegible idle cpu.
78557 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78558 goto next;
78559
78560 for_each_cpu(i, sched_group_cpus(sg)) {
78561 - if (!idle_cpu(i))
78562 + if (i == target || !idle_cpu(i))
78563 goto next;
78564 }
78565
78566 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78567 * run_rebalance_domains is triggered when needed from the scheduler tick.
78568 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78569 */
78570 -static void run_rebalance_domains(struct softirq_action *h)
78571 +static void run_rebalance_domains(void)
78572 {
78573 int this_cpu = smp_processor_id();
78574 struct rq *this_rq = cpu_rq(this_cpu);
78575 diff --git a/kernel/signal.c b/kernel/signal.c
78576 index 50e425c..92c8f65 100644
78577 --- a/kernel/signal.c
78578 +++ b/kernel/signal.c
78579 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78580
78581 int print_fatal_signals __read_mostly;
78582
78583 -static void __user *sig_handler(struct task_struct *t, int sig)
78584 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78585 {
78586 return t->sighand->action[sig - 1].sa.sa_handler;
78587 }
78588
78589 -static int sig_handler_ignored(void __user *handler, int sig)
78590 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78591 {
78592 /* Is it explicitly or implicitly ignored? */
78593 return handler == SIG_IGN ||
78594 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78595
78596 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78597 {
78598 - void __user *handler;
78599 + __sighandler_t handler;
78600
78601 handler = sig_handler(t, sig);
78602
78603 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78604 atomic_inc(&user->sigpending);
78605 rcu_read_unlock();
78606
78607 + if (!override_rlimit)
78608 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78609 +
78610 if (override_rlimit ||
78611 atomic_read(&user->sigpending) <=
78612 task_rlimit(t, RLIMIT_SIGPENDING)) {
78613 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78614
78615 int unhandled_signal(struct task_struct *tsk, int sig)
78616 {
78617 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78618 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78619 if (is_global_init(tsk))
78620 return 1;
78621 if (handler != SIG_IGN && handler != SIG_DFL)
78622 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78623 }
78624 }
78625
78626 + /* allow glibc communication via tgkill to other threads in our
78627 + thread group */
78628 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78629 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78630 + && gr_handle_signal(t, sig))
78631 + return -EPERM;
78632 +
78633 return security_task_kill(t, info, sig, 0);
78634 }
78635
78636 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78637 return send_signal(sig, info, p, 1);
78638 }
78639
78640 -static int
78641 +int
78642 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78643 {
78644 return send_signal(sig, info, t, 0);
78645 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78646 unsigned long int flags;
78647 int ret, blocked, ignored;
78648 struct k_sigaction *action;
78649 + int is_unhandled = 0;
78650
78651 spin_lock_irqsave(&t->sighand->siglock, flags);
78652 action = &t->sighand->action[sig-1];
78653 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78654 }
78655 if (action->sa.sa_handler == SIG_DFL)
78656 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78657 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78658 + is_unhandled = 1;
78659 ret = specific_send_sig_info(sig, info, t);
78660 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78661
78662 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78663 + normal operation */
78664 + if (is_unhandled) {
78665 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78666 + gr_handle_crash(t, sig);
78667 + }
78668 +
78669 return ret;
78670 }
78671
78672 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78673 ret = check_kill_permission(sig, info, p);
78674 rcu_read_unlock();
78675
78676 - if (!ret && sig)
78677 + if (!ret && sig) {
78678 ret = do_send_sig_info(sig, info, p, true);
78679 + if (!ret)
78680 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78681 + }
78682
78683 return ret;
78684 }
78685 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78686 int error = -ESRCH;
78687
78688 rcu_read_lock();
78689 - p = find_task_by_vpid(pid);
78690 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78691 + /* allow glibc communication via tgkill to other threads in our
78692 + thread group */
78693 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78694 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78695 + p = find_task_by_vpid_unrestricted(pid);
78696 + else
78697 +#endif
78698 + p = find_task_by_vpid(pid);
78699 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78700 error = check_kill_permission(sig, info, p);
78701 /*
78702 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78703 }
78704 seg = get_fs();
78705 set_fs(KERNEL_DS);
78706 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78707 - (stack_t __force __user *) &uoss,
78708 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78709 + (stack_t __force_user *) &uoss,
78710 compat_user_stack_pointer());
78711 set_fs(seg);
78712 if (ret >= 0 && uoss_ptr) {
78713 diff --git a/kernel/smp.c b/kernel/smp.c
78714 index 69f38bd..77bbf12 100644
78715 --- a/kernel/smp.c
78716 +++ b/kernel/smp.c
78717 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78718 return NOTIFY_OK;
78719 }
78720
78721 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78722 +static struct notifier_block hotplug_cfd_notifier = {
78723 .notifier_call = hotplug_cfd,
78724 };
78725
78726 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78727 index d6c5fc0..530560c 100644
78728 --- a/kernel/smpboot.c
78729 +++ b/kernel/smpboot.c
78730 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78731 }
78732 smpboot_unpark_thread(plug_thread, cpu);
78733 }
78734 - list_add(&plug_thread->list, &hotplug_threads);
78735 + pax_list_add(&plug_thread->list, &hotplug_threads);
78736 out:
78737 mutex_unlock(&smpboot_threads_lock);
78738 return ret;
78739 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78740 {
78741 get_online_cpus();
78742 mutex_lock(&smpboot_threads_lock);
78743 - list_del(&plug_thread->list);
78744 + pax_list_del(&plug_thread->list);
78745 smpboot_destroy_threads(plug_thread);
78746 mutex_unlock(&smpboot_threads_lock);
78747 put_online_cpus();
78748 diff --git a/kernel/softirq.c b/kernel/softirq.c
78749 index ed567ba..e71dabf 100644
78750 --- a/kernel/softirq.c
78751 +++ b/kernel/softirq.c
78752 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78753 EXPORT_SYMBOL(irq_stat);
78754 #endif
78755
78756 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78757 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78758
78759 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78760
78761 -char *softirq_to_name[NR_SOFTIRQS] = {
78762 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78763 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78764 "TASKLET", "SCHED", "HRTIMER", "RCU"
78765 };
78766 @@ -244,7 +244,7 @@ restart:
78767 kstat_incr_softirqs_this_cpu(vec_nr);
78768
78769 trace_softirq_entry(vec_nr);
78770 - h->action(h);
78771 + h->action();
78772 trace_softirq_exit(vec_nr);
78773 if (unlikely(prev_count != preempt_count())) {
78774 printk(KERN_ERR "huh, entered softirq %u %s %p"
78775 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78776 or_softirq_pending(1UL << nr);
78777 }
78778
78779 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78780 +void __init open_softirq(int nr, void (*action)(void))
78781 {
78782 softirq_vec[nr].action = action;
78783 }
78784 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78785
78786 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78787
78788 -static void tasklet_action(struct softirq_action *a)
78789 +static void tasklet_action(void)
78790 {
78791 struct tasklet_struct *list;
78792
78793 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78794 }
78795 }
78796
78797 -static void tasklet_hi_action(struct softirq_action *a)
78798 +static void tasklet_hi_action(void)
78799 {
78800 struct tasklet_struct *list;
78801
78802 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78803 return NOTIFY_OK;
78804 }
78805
78806 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78807 +static struct notifier_block remote_softirq_cpu_notifier = {
78808 .notifier_call = remote_softirq_cpu_notify,
78809 };
78810
78811 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78812 return NOTIFY_OK;
78813 }
78814
78815 -static struct notifier_block __cpuinitdata cpu_nfb = {
78816 +static struct notifier_block cpu_nfb = {
78817 .notifier_call = cpu_callback
78818 };
78819
78820 -static struct smp_hotplug_thread softirq_threads = {
78821 +static struct smp_hotplug_thread softirq_threads __read_only = {
78822 .store = &ksoftirqd,
78823 .thread_should_run = ksoftirqd_should_run,
78824 .thread_fn = run_ksoftirqd,
78825 diff --git a/kernel/srcu.c b/kernel/srcu.c
78826 index 2b85982..d52ab26 100644
78827 --- a/kernel/srcu.c
78828 +++ b/kernel/srcu.c
78829 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78830 preempt_disable();
78831 idx = rcu_dereference_index_check(sp->completed,
78832 rcu_read_lock_sched_held()) & 0x1;
78833 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78834 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78835 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78836 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78837 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78838 preempt_enable();
78839 return idx;
78840 }
78841 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78842 {
78843 preempt_disable();
78844 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78845 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78846 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78847 preempt_enable();
78848 }
78849 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78850 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78851 index 2f194e9..2c05ea9 100644
78852 --- a/kernel/stop_machine.c
78853 +++ b/kernel/stop_machine.c
78854 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78855 * cpu notifiers. It currently shares the same priority as sched
78856 * migration_notifier.
78857 */
78858 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78859 +static struct notifier_block cpu_stop_cpu_notifier = {
78860 .notifier_call = cpu_stop_cpu_callback,
78861 .priority = 10,
78862 };
78863 diff --git a/kernel/sys.c b/kernel/sys.c
78864 index 47f1d1b..8651bd9 100644
78865 --- a/kernel/sys.c
78866 +++ b/kernel/sys.c
78867 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78868 error = -EACCES;
78869 goto out;
78870 }
78871 +
78872 + if (gr_handle_chroot_setpriority(p, niceval)) {
78873 + error = -EACCES;
78874 + goto out;
78875 + }
78876 +
78877 no_nice = security_task_setnice(p, niceval);
78878 if (no_nice) {
78879 error = no_nice;
78880 @@ -596,6 +602,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78881 goto error;
78882 }
78883
78884 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78885 + goto error;
78886 +
78887 if (rgid != (gid_t) -1 ||
78888 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78889 new->sgid = new->egid;
78890 @@ -631,6 +640,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78891 old = current_cred();
78892
78893 retval = -EPERM;
78894 +
78895 + if (gr_check_group_change(kgid, kgid, kgid))
78896 + goto error;
78897 +
78898 if (nsown_capable(CAP_SETGID))
78899 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78900 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78901 @@ -648,7 +661,7 @@ error:
78902 /*
78903 * change the user struct in a credentials set to match the new UID
78904 */
78905 -static int set_user(struct cred *new)
78906 +int set_user(struct cred *new)
78907 {
78908 struct user_struct *new_user;
78909
78910 @@ -728,6 +741,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78911 goto error;
78912 }
78913
78914 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78915 + goto error;
78916 +
78917 if (!uid_eq(new->uid, old->uid)) {
78918 retval = set_user(new);
78919 if (retval < 0)
78920 @@ -778,6 +794,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78921 old = current_cred();
78922
78923 retval = -EPERM;
78924 +
78925 + if (gr_check_crash_uid(kuid))
78926 + goto error;
78927 + if (gr_check_user_change(kuid, kuid, kuid))
78928 + goto error;
78929 +
78930 if (nsown_capable(CAP_SETUID)) {
78931 new->suid = new->uid = kuid;
78932 if (!uid_eq(kuid, old->uid)) {
78933 @@ -847,6 +869,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78934 goto error;
78935 }
78936
78937 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78938 + goto error;
78939 +
78940 if (ruid != (uid_t) -1) {
78941 new->uid = kruid;
78942 if (!uid_eq(kruid, old->uid)) {
78943 @@ -929,6 +954,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78944 goto error;
78945 }
78946
78947 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78948 + goto error;
78949 +
78950 if (rgid != (gid_t) -1)
78951 new->gid = krgid;
78952 if (egid != (gid_t) -1)
78953 @@ -990,12 +1018,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78954 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78955 nsown_capable(CAP_SETUID)) {
78956 if (!uid_eq(kuid, old->fsuid)) {
78957 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78958 + goto error;
78959 +
78960 new->fsuid = kuid;
78961 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78962 goto change_okay;
78963 }
78964 }
78965
78966 +error:
78967 abort_creds(new);
78968 return old_fsuid;
78969
78970 @@ -1028,12 +1060,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78971 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78972 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78973 nsown_capable(CAP_SETGID)) {
78974 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78975 + goto error;
78976 +
78977 if (!gid_eq(kgid, old->fsgid)) {
78978 new->fsgid = kgid;
78979 goto change_okay;
78980 }
78981 }
78982
78983 +error:
78984 abort_creds(new);
78985 return old_fsgid;
78986
78987 @@ -1341,19 +1377,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78988 return -EFAULT;
78989
78990 down_read(&uts_sem);
78991 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78992 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78993 __OLD_UTS_LEN);
78994 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78995 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78996 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78997 __OLD_UTS_LEN);
78998 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78999 - error |= __copy_to_user(&name->release, &utsname()->release,
79000 + error |= __copy_to_user(name->release, &utsname()->release,
79001 __OLD_UTS_LEN);
79002 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79003 - error |= __copy_to_user(&name->version, &utsname()->version,
79004 + error |= __copy_to_user(name->version, &utsname()->version,
79005 __OLD_UTS_LEN);
79006 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79007 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79008 + error |= __copy_to_user(name->machine, &utsname()->machine,
79009 __OLD_UTS_LEN);
79010 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79011 up_read(&uts_sem);
79012 @@ -1555,6 +1591,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79013 */
79014 new_rlim->rlim_cur = 1;
79015 }
79016 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79017 + is changed to a lower value. Since tasks can be created by the same
79018 + user in between this limit change and an execve by this task, force
79019 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79020 + */
79021 + if (resource == RLIMIT_NPROC)
79022 + tsk->flags |= PF_NPROC_EXCEEDED;
79023 }
79024 if (!retval) {
79025 if (old_rlim)
79026 @@ -2027,7 +2070,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
79027 error = get_dumpable(me->mm);
79028 break;
79029 case PR_SET_DUMPABLE:
79030 - if (arg2 < 0 || arg2 > 1) {
79031 + if (arg2 > 1) {
79032 error = -EINVAL;
79033 break;
79034 }
79035 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79036 index c88878d..e4fa5d1 100644
79037 --- a/kernel/sysctl.c
79038 +++ b/kernel/sysctl.c
79039 @@ -92,7 +92,6 @@
79040
79041
79042 #if defined(CONFIG_SYSCTL)
79043 -
79044 /* External variables not in a header file. */
79045 extern int sysctl_overcommit_memory;
79046 extern int sysctl_overcommit_ratio;
79047 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
79048 void __user *buffer, size_t *lenp, loff_t *ppos);
79049 #endif
79050
79051 -#ifdef CONFIG_PRINTK
79052 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79053 void __user *buffer, size_t *lenp, loff_t *ppos);
79054 -#endif
79055
79056 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79057 void __user *buffer, size_t *lenp, loff_t *ppos);
79058 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79059
79060 #endif
79061
79062 +extern struct ctl_table grsecurity_table[];
79063 +
79064 static struct ctl_table kern_table[];
79065 static struct ctl_table vm_table[];
79066 static struct ctl_table fs_table[];
79067 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
79068 int sysctl_legacy_va_layout;
79069 #endif
79070
79071 +#ifdef CONFIG_PAX_SOFTMODE
79072 +static ctl_table pax_table[] = {
79073 + {
79074 + .procname = "softmode",
79075 + .data = &pax_softmode,
79076 + .maxlen = sizeof(unsigned int),
79077 + .mode = 0600,
79078 + .proc_handler = &proc_dointvec,
79079 + },
79080 +
79081 + { }
79082 +};
79083 +#endif
79084 +
79085 /* The default sysctl tables: */
79086
79087 static struct ctl_table sysctl_base_table[] = {
79088 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
79089 #endif
79090
79091 static struct ctl_table kern_table[] = {
79092 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79093 + {
79094 + .procname = "grsecurity",
79095 + .mode = 0500,
79096 + .child = grsecurity_table,
79097 + },
79098 +#endif
79099 +
79100 +#ifdef CONFIG_PAX_SOFTMODE
79101 + {
79102 + .procname = "pax",
79103 + .mode = 0500,
79104 + .child = pax_table,
79105 + },
79106 +#endif
79107 +
79108 {
79109 .procname = "sched_child_runs_first",
79110 .data = &sysctl_sched_child_runs_first,
79111 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
79112 .data = &modprobe_path,
79113 .maxlen = KMOD_PATH_LEN,
79114 .mode = 0644,
79115 - .proc_handler = proc_dostring,
79116 + .proc_handler = proc_dostring_modpriv,
79117 },
79118 {
79119 .procname = "modules_disabled",
79120 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
79121 .extra1 = &zero,
79122 .extra2 = &one,
79123 },
79124 +#endif
79125 {
79126 .procname = "kptr_restrict",
79127 .data = &kptr_restrict,
79128 .maxlen = sizeof(int),
79129 .mode = 0644,
79130 .proc_handler = proc_dointvec_minmax_sysadmin,
79131 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79132 + .extra1 = &two,
79133 +#else
79134 .extra1 = &zero,
79135 +#endif
79136 .extra2 = &two,
79137 },
79138 -#endif
79139 {
79140 .procname = "ngroups_max",
79141 .data = &ngroups_max,
79142 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79143 .proc_handler = proc_dointvec_minmax,
79144 .extra1 = &zero,
79145 },
79146 + {
79147 + .procname = "heap_stack_gap",
79148 + .data = &sysctl_heap_stack_gap,
79149 + .maxlen = sizeof(sysctl_heap_stack_gap),
79150 + .mode = 0644,
79151 + .proc_handler = proc_doulongvec_minmax,
79152 + },
79153 #else
79154 {
79155 .procname = "nr_trim_pages",
79156 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79157 buffer, lenp, ppos);
79158 }
79159
79160 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79161 + void __user *buffer, size_t *lenp, loff_t *ppos)
79162 +{
79163 + if (write && !capable(CAP_SYS_MODULE))
79164 + return -EPERM;
79165 +
79166 + return _proc_do_string(table->data, table->maxlen, write,
79167 + buffer, lenp, ppos);
79168 +}
79169 +
79170 static size_t proc_skip_spaces(char **buf)
79171 {
79172 size_t ret;
79173 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79174 len = strlen(tmp);
79175 if (len > *size)
79176 len = *size;
79177 + if (len > sizeof(tmp))
79178 + len = sizeof(tmp);
79179 if (copy_to_user(*buf, tmp, len))
79180 return -EFAULT;
79181 *size -= len;
79182 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79183 static int proc_taint(struct ctl_table *table, int write,
79184 void __user *buffer, size_t *lenp, loff_t *ppos)
79185 {
79186 - struct ctl_table t;
79187 + ctl_table_no_const t;
79188 unsigned long tmptaint = get_taint();
79189 int err;
79190
79191 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79192 return err;
79193 }
79194
79195 -#ifdef CONFIG_PRINTK
79196 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79197 void __user *buffer, size_t *lenp, loff_t *ppos)
79198 {
79199 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79200
79201 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79202 }
79203 -#endif
79204
79205 struct do_proc_dointvec_minmax_conv_param {
79206 int *min;
79207 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79208 *i = val;
79209 } else {
79210 val = convdiv * (*i) / convmul;
79211 - if (!first)
79212 + if (!first) {
79213 err = proc_put_char(&buffer, &left, '\t');
79214 + if (err)
79215 + break;
79216 + }
79217 err = proc_put_long(&buffer, &left, val, false);
79218 if (err)
79219 break;
79220 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79221 return -ENOSYS;
79222 }
79223
79224 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79225 + void __user *buffer, size_t *lenp, loff_t *ppos)
79226 +{
79227 + return -ENOSYS;
79228 +}
79229 +
79230 int proc_dointvec(struct ctl_table *table, int write,
79231 void __user *buffer, size_t *lenp, loff_t *ppos)
79232 {
79233 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79234 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79235 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79236 EXPORT_SYMBOL(proc_dostring);
79237 +EXPORT_SYMBOL(proc_dostring_modpriv);
79238 EXPORT_SYMBOL(proc_doulongvec_minmax);
79239 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79240 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79241 index 0ddf3a0..a199f50 100644
79242 --- a/kernel/sysctl_binary.c
79243 +++ b/kernel/sysctl_binary.c
79244 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79245 int i;
79246
79247 set_fs(KERNEL_DS);
79248 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79249 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79250 set_fs(old_fs);
79251 if (result < 0)
79252 goto out_kfree;
79253 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79254 }
79255
79256 set_fs(KERNEL_DS);
79257 - result = vfs_write(file, buffer, str - buffer, &pos);
79258 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79259 set_fs(old_fs);
79260 if (result < 0)
79261 goto out_kfree;
79262 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79263 int i;
79264
79265 set_fs(KERNEL_DS);
79266 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79267 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79268 set_fs(old_fs);
79269 if (result < 0)
79270 goto out_kfree;
79271 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79272 }
79273
79274 set_fs(KERNEL_DS);
79275 - result = vfs_write(file, buffer, str - buffer, &pos);
79276 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79277 set_fs(old_fs);
79278 if (result < 0)
79279 goto out_kfree;
79280 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79281 int i;
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 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79290 __le16 dnaddr;
79291
79292 set_fs(KERNEL_DS);
79293 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79294 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79295 set_fs(old_fs);
79296 if (result < 0)
79297 goto out;
79298 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79299 le16_to_cpu(dnaddr) & 0x3ff);
79300
79301 set_fs(KERNEL_DS);
79302 - result = vfs_write(file, buf, len, &pos);
79303 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79304 set_fs(old_fs);
79305 if (result < 0)
79306 goto out;
79307 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79308 index 145bb4d..b2aa969 100644
79309 --- a/kernel/taskstats.c
79310 +++ b/kernel/taskstats.c
79311 @@ -28,9 +28,12 @@
79312 #include <linux/fs.h>
79313 #include <linux/file.h>
79314 #include <linux/pid_namespace.h>
79315 +#include <linux/grsecurity.h>
79316 #include <net/genetlink.h>
79317 #include <linux/atomic.h>
79318
79319 +extern int gr_is_taskstats_denied(int pid);
79320 +
79321 /*
79322 * Maximum length of a cpumask that can be specified in
79323 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79324 @@ -570,6 +573,9 @@ err:
79325
79326 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79327 {
79328 + if (gr_is_taskstats_denied(current->pid))
79329 + return -EACCES;
79330 +
79331 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79332 return cmd_attr_register_cpumask(info);
79333 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79334 diff --git a/kernel/time.c b/kernel/time.c
79335 index d226c6a..2f0d217 100644
79336 --- a/kernel/time.c
79337 +++ b/kernel/time.c
79338 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79339 return error;
79340
79341 if (tz) {
79342 + /* we log in do_settimeofday called below, so don't log twice
79343 + */
79344 + if (!tv)
79345 + gr_log_timechange();
79346 +
79347 sys_tz = *tz;
79348 update_vsyscall_tz();
79349 if (firsttime) {
79350 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79351 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79352 * value to a scaled second value.
79353 */
79354 -unsigned long
79355 +unsigned long __intentional_overflow(-1)
79356 timespec_to_jiffies(const struct timespec *value)
79357 {
79358 unsigned long sec = value->tv_sec;
79359 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79360 index f11d83b..d016d91 100644
79361 --- a/kernel/time/alarmtimer.c
79362 +++ b/kernel/time/alarmtimer.c
79363 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79364 struct platform_device *pdev;
79365 int error = 0;
79366 int i;
79367 - struct k_clock alarm_clock = {
79368 + static struct k_clock alarm_clock = {
79369 .clock_getres = alarm_clock_getres,
79370 .clock_get = alarm_clock_get,
79371 .timer_create = alarm_timer_create,
79372 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79373 index 239a323..2c78cf0 100644
79374 --- a/kernel/time/tick-broadcast.c
79375 +++ b/kernel/time/tick-broadcast.c
79376 @@ -120,7 +120,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79377 * then clear the broadcast bit.
79378 */
79379 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79380 - int cpu = smp_processor_id();
79381 + cpu = smp_processor_id();
79382
79383 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79384 tick_broadcast_clear_oneshot(cpu);
79385 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79386 index cbc6acb..3a77191 100644
79387 --- a/kernel/time/timekeeping.c
79388 +++ b/kernel/time/timekeeping.c
79389 @@ -15,6 +15,7 @@
79390 #include <linux/init.h>
79391 #include <linux/mm.h>
79392 #include <linux/sched.h>
79393 +#include <linux/grsecurity.h>
79394 #include <linux/syscore_ops.h>
79395 #include <linux/clocksource.h>
79396 #include <linux/jiffies.h>
79397 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79398 if (!timespec_valid_strict(tv))
79399 return -EINVAL;
79400
79401 + gr_log_timechange();
79402 +
79403 write_seqlock_irqsave(&tk->lock, flags);
79404
79405 timekeeping_forward_now(tk);
79406 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79407 index af5a7e9..715611a 100644
79408 --- a/kernel/time/timer_list.c
79409 +++ b/kernel/time/timer_list.c
79410 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79411
79412 static void print_name_offset(struct seq_file *m, void *sym)
79413 {
79414 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79415 + SEQ_printf(m, "<%p>", NULL);
79416 +#else
79417 char symname[KSYM_NAME_LEN];
79418
79419 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79420 SEQ_printf(m, "<%pK>", sym);
79421 else
79422 SEQ_printf(m, "%s", symname);
79423 +#endif
79424 }
79425
79426 static void
79427 @@ -112,7 +116,11 @@ next_one:
79428 static void
79429 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79430 {
79431 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79432 + SEQ_printf(m, " .base: %p\n", NULL);
79433 +#else
79434 SEQ_printf(m, " .base: %pK\n", base);
79435 +#endif
79436 SEQ_printf(m, " .index: %d\n",
79437 base->index);
79438 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79439 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79440 {
79441 struct proc_dir_entry *pe;
79442
79443 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79444 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79445 +#else
79446 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79447 +#endif
79448 if (!pe)
79449 return -ENOMEM;
79450 return 0;
79451 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79452 index 0b537f2..40d6c20 100644
79453 --- a/kernel/time/timer_stats.c
79454 +++ b/kernel/time/timer_stats.c
79455 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79456 static unsigned long nr_entries;
79457 static struct entry entries[MAX_ENTRIES];
79458
79459 -static atomic_t overflow_count;
79460 +static atomic_unchecked_t overflow_count;
79461
79462 /*
79463 * The entries are in a hash-table, for fast lookup:
79464 @@ -140,7 +140,7 @@ static void reset_entries(void)
79465 nr_entries = 0;
79466 memset(entries, 0, sizeof(entries));
79467 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79468 - atomic_set(&overflow_count, 0);
79469 + atomic_set_unchecked(&overflow_count, 0);
79470 }
79471
79472 static struct entry *alloc_entry(void)
79473 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79474 if (likely(entry))
79475 entry->count++;
79476 else
79477 - atomic_inc(&overflow_count);
79478 + atomic_inc_unchecked(&overflow_count);
79479
79480 out_unlock:
79481 raw_spin_unlock_irqrestore(lock, flags);
79482 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79483
79484 static void print_name_offset(struct seq_file *m, unsigned long addr)
79485 {
79486 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79487 + seq_printf(m, "<%p>", NULL);
79488 +#else
79489 char symname[KSYM_NAME_LEN];
79490
79491 if (lookup_symbol_name(addr, symname) < 0)
79492 - seq_printf(m, "<%p>", (void *)addr);
79493 + seq_printf(m, "<%pK>", (void *)addr);
79494 else
79495 seq_printf(m, "%s", symname);
79496 +#endif
79497 }
79498
79499 static int tstats_show(struct seq_file *m, void *v)
79500 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79501
79502 seq_puts(m, "Timer Stats Version: v0.2\n");
79503 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79504 - if (atomic_read(&overflow_count))
79505 + if (atomic_read_unchecked(&overflow_count))
79506 seq_printf(m, "Overflow: %d entries\n",
79507 - atomic_read(&overflow_count));
79508 + atomic_read_unchecked(&overflow_count));
79509
79510 for (i = 0; i < nr_entries; i++) {
79511 entry = entries + i;
79512 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79513 {
79514 struct proc_dir_entry *pe;
79515
79516 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79517 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79518 +#else
79519 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79520 +#endif
79521 if (!pe)
79522 return -ENOMEM;
79523 return 0;
79524 diff --git a/kernel/timer.c b/kernel/timer.c
79525 index 367d008..5dee98f 100644
79526 --- a/kernel/timer.c
79527 +++ b/kernel/timer.c
79528 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79529 /*
79530 * This function runs timers and the timer-tq in bottom half context.
79531 */
79532 -static void run_timer_softirq(struct softirq_action *h)
79533 +static void run_timer_softirq(void)
79534 {
79535 struct tvec_base *base = __this_cpu_read(tvec_bases);
79536
79537 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79538 *
79539 * In all cases the return value is guaranteed to be non-negative.
79540 */
79541 -signed long __sched schedule_timeout(signed long timeout)
79542 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79543 {
79544 struct timer_list timer;
79545 unsigned long expire;
79546 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79547 return NOTIFY_OK;
79548 }
79549
79550 -static struct notifier_block __cpuinitdata timers_nb = {
79551 +static struct notifier_block timers_nb = {
79552 .notifier_call = timer_cpu_notify,
79553 };
79554
79555 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79556 index c0bd030..62a1927 100644
79557 --- a/kernel/trace/blktrace.c
79558 +++ b/kernel/trace/blktrace.c
79559 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79560 struct blk_trace *bt = filp->private_data;
79561 char buf[16];
79562
79563 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79564 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79565
79566 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79567 }
79568 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79569 return 1;
79570
79571 bt = buf->chan->private_data;
79572 - atomic_inc(&bt->dropped);
79573 + atomic_inc_unchecked(&bt->dropped);
79574 return 0;
79575 }
79576
79577 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79578
79579 bt->dir = dir;
79580 bt->dev = dev;
79581 - atomic_set(&bt->dropped, 0);
79582 + atomic_set_unchecked(&bt->dropped, 0);
79583
79584 ret = -EIO;
79585 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79586 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79587 index 03dbc77..e6bd484 100644
79588 --- a/kernel/trace/ftrace.c
79589 +++ b/kernel/trace/ftrace.c
79590 @@ -1886,12 +1886,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79591 if (unlikely(ftrace_disabled))
79592 return 0;
79593
79594 + ret = ftrace_arch_code_modify_prepare();
79595 + FTRACE_WARN_ON(ret);
79596 + if (ret)
79597 + return 0;
79598 +
79599 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79600 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79601 if (ret) {
79602 ftrace_bug(ret, ip);
79603 - return 0;
79604 }
79605 - return 1;
79606 + return ret ? 0 : 1;
79607 }
79608
79609 /*
79610 @@ -2964,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79611
79612 int
79613 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79614 - void *data)
79615 + void *data)
79616 {
79617 struct ftrace_func_probe *entry;
79618 struct ftrace_page *pg;
79619 @@ -3832,8 +3837,10 @@ static int ftrace_process_locs(struct module *mod,
79620 if (!count)
79621 return 0;
79622
79623 + pax_open_kernel();
79624 sort(start, count, sizeof(*start),
79625 ftrace_cmp_ips, ftrace_swap_ips);
79626 + pax_close_kernel();
79627
79628 start_pg = ftrace_allocate_pages(count);
79629 if (!start_pg)
79630 @@ -4555,8 +4562,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79631 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79632
79633 static int ftrace_graph_active;
79634 -static struct notifier_block ftrace_suspend_notifier;
79635 -
79636 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79637 {
79638 return 0;
79639 @@ -4700,6 +4705,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79640 return NOTIFY_DONE;
79641 }
79642
79643 +static struct notifier_block ftrace_suspend_notifier = {
79644 + .notifier_call = ftrace_suspend_notifier_call
79645 +};
79646 +
79647 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79648 trace_func_graph_ent_t entryfunc)
79649 {
79650 @@ -4713,7 +4722,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79651 goto out;
79652 }
79653
79654 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79655 register_pm_notifier(&ftrace_suspend_notifier);
79656
79657 ftrace_graph_active++;
79658 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79659 index ce8514f..8233573 100644
79660 --- a/kernel/trace/ring_buffer.c
79661 +++ b/kernel/trace/ring_buffer.c
79662 @@ -346,9 +346,9 @@ struct buffer_data_page {
79663 */
79664 struct buffer_page {
79665 struct list_head list; /* list of buffer pages */
79666 - local_t write; /* index for next write */
79667 + local_unchecked_t write; /* index for next write */
79668 unsigned read; /* index for next read */
79669 - local_t entries; /* entries on this page */
79670 + local_unchecked_t entries; /* entries on this page */
79671 unsigned long real_end; /* real end of data */
79672 struct buffer_data_page *page; /* Actual data page */
79673 };
79674 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79675 unsigned long last_overrun;
79676 local_t entries_bytes;
79677 local_t entries;
79678 - local_t overrun;
79679 - local_t commit_overrun;
79680 + local_unchecked_t overrun;
79681 + local_unchecked_t commit_overrun;
79682 local_t dropped_events;
79683 local_t committing;
79684 local_t commits;
79685 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79686 *
79687 * We add a counter to the write field to denote this.
79688 */
79689 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79690 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79691 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79692 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79693
79694 /*
79695 * Just make sure we have seen our old_write and synchronize
79696 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79697 * cmpxchg to only update if an interrupt did not already
79698 * do it for us. If the cmpxchg fails, we don't care.
79699 */
79700 - (void)local_cmpxchg(&next_page->write, old_write, val);
79701 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79702 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79703 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79704
79705 /*
79706 * No need to worry about races with clearing out the commit.
79707 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79708
79709 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79710 {
79711 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79712 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79713 }
79714
79715 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79716 {
79717 - return local_read(&bpage->write) & RB_WRITE_MASK;
79718 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79719 }
79720
79721 static int
79722 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79723 * bytes consumed in ring buffer from here.
79724 * Increment overrun to account for the lost events.
79725 */
79726 - local_add(page_entries, &cpu_buffer->overrun);
79727 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79728 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79729 }
79730
79731 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79732 * it is our responsibility to update
79733 * the counters.
79734 */
79735 - local_add(entries, &cpu_buffer->overrun);
79736 + local_add_unchecked(entries, &cpu_buffer->overrun);
79737 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79738
79739 /*
79740 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79741 if (tail == BUF_PAGE_SIZE)
79742 tail_page->real_end = 0;
79743
79744 - local_sub(length, &tail_page->write);
79745 + local_sub_unchecked(length, &tail_page->write);
79746 return;
79747 }
79748
79749 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79750 rb_event_set_padding(event);
79751
79752 /* Set the write back to the previous setting */
79753 - local_sub(length, &tail_page->write);
79754 + local_sub_unchecked(length, &tail_page->write);
79755 return;
79756 }
79757
79758 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79759
79760 /* Set write to end of buffer */
79761 length = (tail + length) - BUF_PAGE_SIZE;
79762 - local_sub(length, &tail_page->write);
79763 + local_sub_unchecked(length, &tail_page->write);
79764 }
79765
79766 /*
79767 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79768 * about it.
79769 */
79770 if (unlikely(next_page == commit_page)) {
79771 - local_inc(&cpu_buffer->commit_overrun);
79772 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79773 goto out_reset;
79774 }
79775
79776 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79777 cpu_buffer->tail_page) &&
79778 (cpu_buffer->commit_page ==
79779 cpu_buffer->reader_page))) {
79780 - local_inc(&cpu_buffer->commit_overrun);
79781 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79782 goto out_reset;
79783 }
79784 }
79785 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79786 length += RB_LEN_TIME_EXTEND;
79787
79788 tail_page = cpu_buffer->tail_page;
79789 - write = local_add_return(length, &tail_page->write);
79790 + write = local_add_return_unchecked(length, &tail_page->write);
79791
79792 /* set write to only the index of the write */
79793 write &= RB_WRITE_MASK;
79794 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79795 kmemcheck_annotate_bitfield(event, bitfield);
79796 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79797
79798 - local_inc(&tail_page->entries);
79799 + local_inc_unchecked(&tail_page->entries);
79800
79801 /*
79802 * If this is the first commit on the page, then update
79803 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79804
79805 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79806 unsigned long write_mask =
79807 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79808 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79809 unsigned long event_length = rb_event_length(event);
79810 /*
79811 * This is on the tail page. It is possible that
79812 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79813 */
79814 old_index += write_mask;
79815 new_index += write_mask;
79816 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79817 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79818 if (index == old_index) {
79819 /* update counters */
79820 local_sub(event_length, &cpu_buffer->entries_bytes);
79821 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79822
79823 /* Do the likely case first */
79824 if (likely(bpage->page == (void *)addr)) {
79825 - local_dec(&bpage->entries);
79826 + local_dec_unchecked(&bpage->entries);
79827 return;
79828 }
79829
79830 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79831 start = bpage;
79832 do {
79833 if (bpage->page == (void *)addr) {
79834 - local_dec(&bpage->entries);
79835 + local_dec_unchecked(&bpage->entries);
79836 return;
79837 }
79838 rb_inc_page(cpu_buffer, &bpage);
79839 @@ -2926,7 +2926,7 @@ static inline unsigned long
79840 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79841 {
79842 return local_read(&cpu_buffer->entries) -
79843 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79844 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79845 }
79846
79847 /**
79848 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79849 return 0;
79850
79851 cpu_buffer = buffer->buffers[cpu];
79852 - ret = local_read(&cpu_buffer->overrun);
79853 + ret = local_read_unchecked(&cpu_buffer->overrun);
79854
79855 return ret;
79856 }
79857 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79858 return 0;
79859
79860 cpu_buffer = buffer->buffers[cpu];
79861 - ret = local_read(&cpu_buffer->commit_overrun);
79862 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79863
79864 return ret;
79865 }
79866 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79867 /* if you care about this being correct, lock the buffer */
79868 for_each_buffer_cpu(buffer, cpu) {
79869 cpu_buffer = buffer->buffers[cpu];
79870 - overruns += local_read(&cpu_buffer->overrun);
79871 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79872 }
79873
79874 return overruns;
79875 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79876 /*
79877 * Reset the reader page to size zero.
79878 */
79879 - local_set(&cpu_buffer->reader_page->write, 0);
79880 - local_set(&cpu_buffer->reader_page->entries, 0);
79881 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79882 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79883 local_set(&cpu_buffer->reader_page->page->commit, 0);
79884 cpu_buffer->reader_page->real_end = 0;
79885
79886 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79887 * want to compare with the last_overrun.
79888 */
79889 smp_mb();
79890 - overwrite = local_read(&(cpu_buffer->overrun));
79891 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79892
79893 /*
79894 * Here's the tricky part.
79895 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79896
79897 cpu_buffer->head_page
79898 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79899 - local_set(&cpu_buffer->head_page->write, 0);
79900 - local_set(&cpu_buffer->head_page->entries, 0);
79901 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79902 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79903 local_set(&cpu_buffer->head_page->page->commit, 0);
79904
79905 cpu_buffer->head_page->read = 0;
79906 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79907
79908 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79909 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79910 - local_set(&cpu_buffer->reader_page->write, 0);
79911 - local_set(&cpu_buffer->reader_page->entries, 0);
79912 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79913 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79914 local_set(&cpu_buffer->reader_page->page->commit, 0);
79915 cpu_buffer->reader_page->read = 0;
79916
79917 local_set(&cpu_buffer->entries_bytes, 0);
79918 - local_set(&cpu_buffer->overrun, 0);
79919 - local_set(&cpu_buffer->commit_overrun, 0);
79920 + local_set_unchecked(&cpu_buffer->overrun, 0);
79921 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79922 local_set(&cpu_buffer->dropped_events, 0);
79923 local_set(&cpu_buffer->entries, 0);
79924 local_set(&cpu_buffer->committing, 0);
79925 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79926 rb_init_page(bpage);
79927 bpage = reader->page;
79928 reader->page = *data_page;
79929 - local_set(&reader->write, 0);
79930 - local_set(&reader->entries, 0);
79931 + local_set_unchecked(&reader->write, 0);
79932 + local_set_unchecked(&reader->entries, 0);
79933 reader->read = 0;
79934 *data_page = bpage;
79935
79936 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79937 index 1c82852..1cd5af2 100644
79938 --- a/kernel/trace/trace.c
79939 +++ b/kernel/trace/trace.c
79940 @@ -2845,7 +2845,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
79941 return 0;
79942 }
79943
79944 -int set_tracer_flag(unsigned int mask, int enabled)
79945 +int set_tracer_flag(unsigned long mask, int enabled)
79946 {
79947 /* do nothing if flag is already set */
79948 if (!!(trace_flags & mask) == !!enabled)
79949 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79950 };
79951 #endif
79952
79953 -static struct dentry *d_tracer;
79954 -
79955 struct dentry *tracing_init_dentry(void)
79956 {
79957 + static struct dentry *d_tracer;
79958 static int once;
79959
79960 if (d_tracer)
79961 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79962 return d_tracer;
79963 }
79964
79965 -static struct dentry *d_percpu;
79966 -
79967 struct dentry *tracing_dentry_percpu(void)
79968 {
79969 + static struct dentry *d_percpu;
79970 static int once;
79971 struct dentry *d_tracer;
79972
79973 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
79974 index 23f1d2c..6ca7a9b 100644
79975 --- a/kernel/trace/trace.h
79976 +++ b/kernel/trace/trace.h
79977 @@ -840,7 +840,7 @@ extern const char *__stop___trace_bprintk_fmt[];
79978 void trace_printk_init_buffers(void);
79979 void trace_printk_start_comm(void);
79980 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
79981 -int set_tracer_flag(unsigned int mask, int enabled);
79982 +int set_tracer_flag(unsigned long mask, int enabled);
79983
79984 #undef FTRACE_ENTRY
79985 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
79986 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79987 index 880073d..42db7c3 100644
79988 --- a/kernel/trace/trace_events.c
79989 +++ b/kernel/trace/trace_events.c
79990 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79991 struct ftrace_module_file_ops {
79992 struct list_head list;
79993 struct module *mod;
79994 - struct file_operations id;
79995 - struct file_operations enable;
79996 - struct file_operations format;
79997 - struct file_operations filter;
79998 };
79999
80000 static struct ftrace_module_file_ops *
80001 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
80002
80003 file_ops->mod = mod;
80004
80005 - file_ops->id = ftrace_event_id_fops;
80006 - file_ops->id.owner = mod;
80007 -
80008 - file_ops->enable = ftrace_enable_fops;
80009 - file_ops->enable.owner = mod;
80010 -
80011 - file_ops->filter = ftrace_event_filter_fops;
80012 - file_ops->filter.owner = mod;
80013 -
80014 - file_ops->format = ftrace_event_format_fops;
80015 - file_ops->format.owner = mod;
80016 + pax_open_kernel();
80017 + mod->trace_id.owner = mod;
80018 + mod->trace_enable.owner = mod;
80019 + mod->trace_filter.owner = mod;
80020 + mod->trace_format.owner = mod;
80021 + pax_close_kernel();
80022
80023 list_add(&file_ops->list, &ftrace_module_file_list);
80024
80025 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
80026
80027 for_each_event(call, start, end) {
80028 __trace_add_event_call(*call, mod,
80029 - &file_ops->id, &file_ops->enable,
80030 - &file_ops->filter, &file_ops->format);
80031 + &mod->trace_id, &mod->trace_enable,
80032 + &mod->trace_filter, &mod->trace_format);
80033 }
80034 }
80035
80036 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80037 index fd3c8aa..5f324a6 100644
80038 --- a/kernel/trace/trace_mmiotrace.c
80039 +++ b/kernel/trace/trace_mmiotrace.c
80040 @@ -24,7 +24,7 @@ struct header_iter {
80041 static struct trace_array *mmio_trace_array;
80042 static bool overrun_detected;
80043 static unsigned long prev_overruns;
80044 -static atomic_t dropped_count;
80045 +static atomic_unchecked_t dropped_count;
80046
80047 static void mmio_reset_data(struct trace_array *tr)
80048 {
80049 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80050
80051 static unsigned long count_overruns(struct trace_iterator *iter)
80052 {
80053 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80054 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80055 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
80056
80057 if (over > prev_overruns)
80058 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80059 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80060 sizeof(*entry), 0, pc);
80061 if (!event) {
80062 - atomic_inc(&dropped_count);
80063 + atomic_inc_unchecked(&dropped_count);
80064 return;
80065 }
80066 entry = ring_buffer_event_data(event);
80067 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80068 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80069 sizeof(*entry), 0, pc);
80070 if (!event) {
80071 - atomic_inc(&dropped_count);
80072 + atomic_inc_unchecked(&dropped_count);
80073 return;
80074 }
80075 entry = ring_buffer_event_data(event);
80076 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80077 index 194d796..76edb8f 100644
80078 --- a/kernel/trace/trace_output.c
80079 +++ b/kernel/trace/trace_output.c
80080 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80081
80082 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80083 if (!IS_ERR(p)) {
80084 - p = mangle_path(s->buffer + s->len, p, "\n");
80085 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80086 if (p) {
80087 s->len = p - s->buffer;
80088 return 1;
80089 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
80090 goto out;
80091 }
80092
80093 + pax_open_kernel();
80094 if (event->funcs->trace == NULL)
80095 - event->funcs->trace = trace_nop_print;
80096 + *(void **)&event->funcs->trace = trace_nop_print;
80097 if (event->funcs->raw == NULL)
80098 - event->funcs->raw = trace_nop_print;
80099 + *(void **)&event->funcs->raw = trace_nop_print;
80100 if (event->funcs->hex == NULL)
80101 - event->funcs->hex = trace_nop_print;
80102 + *(void **)&event->funcs->hex = trace_nop_print;
80103 if (event->funcs->binary == NULL)
80104 - event->funcs->binary = trace_nop_print;
80105 + *(void **)&event->funcs->binary = trace_nop_print;
80106 + pax_close_kernel();
80107
80108 key = event->type & (EVENT_HASHSIZE - 1);
80109
80110 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80111 index b20428c..4845a10 100644
80112 --- a/kernel/trace/trace_stack.c
80113 +++ b/kernel/trace/trace_stack.c
80114 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80115 return;
80116
80117 /* we do not handle interrupt stacks yet */
80118 - if (!object_is_on_stack(stack))
80119 + if (!object_starts_on_stack(stack))
80120 return;
80121
80122 local_irq_save(flags);
80123 diff --git a/kernel/user.c b/kernel/user.c
80124 index 7f6ff2b..1ac8f18 100644
80125 --- a/kernel/user.c
80126 +++ b/kernel/user.c
80127 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
80128 .count = 4294967295U,
80129 },
80130 },
80131 - .kref = {
80132 - .refcount = ATOMIC_INIT(3),
80133 - },
80134 + .count = ATOMIC_INIT(3),
80135 .owner = GLOBAL_ROOT_UID,
80136 .group = GLOBAL_ROOT_GID,
80137 .proc_inum = PROC_USER_INIT_INO,
80138 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80139 index f359dc7..ddc606a 100644
80140 --- a/kernel/user_namespace.c
80141 +++ b/kernel/user_namespace.c
80142 @@ -89,7 +89,7 @@ int create_user_ns(struct cred *new)
80143 return ret;
80144 }
80145
80146 - kref_init(&ns->kref);
80147 + atomic_set(&ns->count, 1);
80148 /* Leave the new->user_ns reference with the new user namespace. */
80149 ns->parent = parent_ns;
80150 ns->owner = owner;
80151 @@ -117,15 +117,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80152 return create_user_ns(cred);
80153 }
80154
80155 -void free_user_ns(struct kref *kref)
80156 +void free_user_ns(struct user_namespace *ns)
80157 {
80158 - struct user_namespace *parent, *ns =
80159 - container_of(kref, struct user_namespace, kref);
80160 + struct user_namespace *parent;
80161
80162 - parent = ns->parent;
80163 - proc_free_inum(ns->proc_inum);
80164 - kmem_cache_free(user_ns_cachep, ns);
80165 - put_user_ns(parent);
80166 + do {
80167 + parent = ns->parent;
80168 + proc_free_inum(ns->proc_inum);
80169 + kmem_cache_free(user_ns_cachep, ns);
80170 + ns = parent;
80171 + } while (atomic_dec_and_test(&parent->count));
80172 }
80173 EXPORT_SYMBOL(free_user_ns);
80174
80175 @@ -819,7 +820,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80176 if (atomic_read(&current->mm->mm_users) > 1)
80177 return -EINVAL;
80178
80179 - if (current->fs->users != 1)
80180 + if (atomic_read(&current->fs->users) != 1)
80181 return -EINVAL;
80182
80183 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80184 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80185 index 63da38c..639904e 100644
80186 --- a/kernel/utsname_sysctl.c
80187 +++ b/kernel/utsname_sysctl.c
80188 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80189 static int proc_do_uts_string(ctl_table *table, int write,
80190 void __user *buffer, size_t *lenp, loff_t *ppos)
80191 {
80192 - struct ctl_table uts_table;
80193 + ctl_table_no_const uts_table;
80194 int r;
80195 memcpy(&uts_table, table, sizeof(uts_table));
80196 uts_table.data = get_uts(table, write);
80197 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80198 index 75a2ab3..5961da7 100644
80199 --- a/kernel/watchdog.c
80200 +++ b/kernel/watchdog.c
80201 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80202 }
80203 #endif /* CONFIG_SYSCTL */
80204
80205 -static struct smp_hotplug_thread watchdog_threads = {
80206 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80207 .store = &softlockup_watchdog,
80208 .thread_should_run = watchdog_should_run,
80209 .thread_fn = watchdog,
80210 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80211 index 67604e5..fe94fb1 100644
80212 --- a/lib/Kconfig.debug
80213 +++ b/lib/Kconfig.debug
80214 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80215
80216 config DEBUG_LOCK_ALLOC
80217 bool "Lock debugging: detect incorrect freeing of live locks"
80218 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80219 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80220 select DEBUG_SPINLOCK
80221 select DEBUG_MUTEXES
80222 select LOCKDEP
80223 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80224
80225 config PROVE_LOCKING
80226 bool "Lock debugging: prove locking correctness"
80227 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80228 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80229 select LOCKDEP
80230 select DEBUG_SPINLOCK
80231 select DEBUG_MUTEXES
80232 @@ -670,7 +670,7 @@ config LOCKDEP
80233
80234 config LOCK_STAT
80235 bool "Lock usage statistics"
80236 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80237 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80238 select LOCKDEP
80239 select DEBUG_SPINLOCK
80240 select DEBUG_MUTEXES
80241 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80242 depends on DEBUG_KERNEL
80243 depends on STACKTRACE_SUPPORT
80244 depends on PROC_FS
80245 + depends on !GRKERNSEC_HIDESYM
80246 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80247 select KALLSYMS
80248 select KALLSYMS_ALL
80249 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80250
80251 config PROVIDE_OHCI1394_DMA_INIT
80252 bool "Remote debugging over FireWire early on boot"
80253 - depends on PCI && X86
80254 + depends on PCI && X86 && !GRKERNSEC
80255 help
80256 If you want to debug problems which hang or crash the kernel early
80257 on boot and the crashing machine has a FireWire port, you can use
80258 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80259
80260 config FIREWIRE_OHCI_REMOTE_DMA
80261 bool "Remote debugging over FireWire with firewire-ohci"
80262 - depends on FIREWIRE_OHCI
80263 + depends on FIREWIRE_OHCI && !GRKERNSEC
80264 help
80265 This option lets you use the FireWire bus for remote debugging
80266 with help of the firewire-ohci driver. It enables unfiltered
80267 diff --git a/lib/Makefile b/lib/Makefile
80268 index 02ed6c0..bd243da 100644
80269 --- a/lib/Makefile
80270 +++ b/lib/Makefile
80271 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80272
80273 obj-$(CONFIG_BTREE) += btree.o
80274 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80275 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80276 +obj-y += list_debug.o
80277 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80278
80279 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80280 diff --git a/lib/bitmap.c b/lib/bitmap.c
80281 index 06f7e4f..f3cf2b0 100644
80282 --- a/lib/bitmap.c
80283 +++ b/lib/bitmap.c
80284 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80285 {
80286 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80287 u32 chunk;
80288 - const char __user __force *ubuf = (const char __user __force *)buf;
80289 + const char __user *ubuf = (const char __force_user *)buf;
80290
80291 bitmap_zero(maskp, nmaskbits);
80292
80293 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80294 {
80295 if (!access_ok(VERIFY_READ, ubuf, ulen))
80296 return -EFAULT;
80297 - return __bitmap_parse((const char __force *)ubuf,
80298 + return __bitmap_parse((const char __force_kernel *)ubuf,
80299 ulen, 1, maskp, nmaskbits);
80300
80301 }
80302 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80303 {
80304 unsigned a, b;
80305 int c, old_c, totaldigits;
80306 - const char __user __force *ubuf = (const char __user __force *)buf;
80307 + const char __user *ubuf = (const char __force_user *)buf;
80308 int exp_digit, in_range;
80309
80310 totaldigits = c = 0;
80311 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80312 {
80313 if (!access_ok(VERIFY_READ, ubuf, ulen))
80314 return -EFAULT;
80315 - return __bitmap_parselist((const char __force *)ubuf,
80316 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80317 ulen, 1, maskp, nmaskbits);
80318 }
80319 EXPORT_SYMBOL(bitmap_parselist_user);
80320 diff --git a/lib/bug.c b/lib/bug.c
80321 index d0cdf14..4d07bd2 100644
80322 --- a/lib/bug.c
80323 +++ b/lib/bug.c
80324 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80325 return BUG_TRAP_TYPE_NONE;
80326
80327 bug = find_bug(bugaddr);
80328 + if (!bug)
80329 + return BUG_TRAP_TYPE_NONE;
80330
80331 file = NULL;
80332 line = 0;
80333 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80334 index d11808c..dc2d6f8 100644
80335 --- a/lib/debugobjects.c
80336 +++ b/lib/debugobjects.c
80337 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80338 if (limit > 4)
80339 return;
80340
80341 - is_on_stack = object_is_on_stack(addr);
80342 + is_on_stack = object_starts_on_stack(addr);
80343 if (is_on_stack == onstack)
80344 return;
80345
80346 diff --git a/lib/devres.c b/lib/devres.c
80347 index 80b9c76..9e32279 100644
80348 --- a/lib/devres.c
80349 +++ b/lib/devres.c
80350 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80351 void devm_iounmap(struct device *dev, void __iomem *addr)
80352 {
80353 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80354 - (void *)addr));
80355 + (void __force *)addr));
80356 iounmap(addr);
80357 }
80358 EXPORT_SYMBOL(devm_iounmap);
80359 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80360 {
80361 ioport_unmap(addr);
80362 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80363 - devm_ioport_map_match, (void *)addr));
80364 + devm_ioport_map_match, (void __force *)addr));
80365 }
80366 EXPORT_SYMBOL(devm_ioport_unmap);
80367
80368 diff --git a/lib/div64.c b/lib/div64.c
80369 index a163b6c..9618fa5 100644
80370 --- a/lib/div64.c
80371 +++ b/lib/div64.c
80372 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80373 EXPORT_SYMBOL(__div64_32);
80374
80375 #ifndef div_s64_rem
80376 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80377 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80378 {
80379 u64 quotient;
80380
80381 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80382 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80383 */
80384 #ifndef div64_u64
80385 -u64 div64_u64(u64 dividend, u64 divisor)
80386 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80387 {
80388 u32 high = divisor >> 32;
80389 u64 quot;
80390 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80391 index 5e396ac..58d5de1 100644
80392 --- a/lib/dma-debug.c
80393 +++ b/lib/dma-debug.c
80394 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80395
80396 void dma_debug_add_bus(struct bus_type *bus)
80397 {
80398 - struct notifier_block *nb;
80399 + notifier_block_no_const *nb;
80400
80401 if (global_disable)
80402 return;
80403 @@ -942,7 +942,7 @@ out:
80404
80405 static void check_for_stack(struct device *dev, void *addr)
80406 {
80407 - if (object_is_on_stack(addr))
80408 + if (object_starts_on_stack(addr))
80409 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80410 "stack [addr=%p]\n", addr);
80411 }
80412 diff --git a/lib/inflate.c b/lib/inflate.c
80413 index 013a761..c28f3fc 100644
80414 --- a/lib/inflate.c
80415 +++ b/lib/inflate.c
80416 @@ -269,7 +269,7 @@ static void free(void *where)
80417 malloc_ptr = free_mem_ptr;
80418 }
80419 #else
80420 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80421 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80422 #define free(a) kfree(a)
80423 #endif
80424
80425 diff --git a/lib/ioremap.c b/lib/ioremap.c
80426 index 0c9216c..863bd89 100644
80427 --- a/lib/ioremap.c
80428 +++ b/lib/ioremap.c
80429 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80430 unsigned long next;
80431
80432 phys_addr -= addr;
80433 - pmd = pmd_alloc(&init_mm, pud, addr);
80434 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80435 if (!pmd)
80436 return -ENOMEM;
80437 do {
80438 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80439 unsigned long next;
80440
80441 phys_addr -= addr;
80442 - pud = pud_alloc(&init_mm, pgd, addr);
80443 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80444 if (!pud)
80445 return -ENOMEM;
80446 do {
80447 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80448 index bd2bea9..6b3c95e 100644
80449 --- a/lib/is_single_threaded.c
80450 +++ b/lib/is_single_threaded.c
80451 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80452 struct task_struct *p, *t;
80453 bool ret;
80454
80455 + if (!mm)
80456 + return true;
80457 +
80458 if (atomic_read(&task->signal->live) != 1)
80459 return false;
80460
80461 diff --git a/lib/kobject.c b/lib/kobject.c
80462 index a654866..a4fd13d 100644
80463 --- a/lib/kobject.c
80464 +++ b/lib/kobject.c
80465 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80466
80467
80468 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80469 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80470 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80471
80472 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80473 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80474 {
80475 enum kobj_ns_type type = ops->type;
80476 int error;
80477 diff --git a/lib/list_debug.c b/lib/list_debug.c
80478 index c24c2f7..06e070b 100644
80479 --- a/lib/list_debug.c
80480 +++ b/lib/list_debug.c
80481 @@ -11,7 +11,9 @@
80482 #include <linux/bug.h>
80483 #include <linux/kernel.h>
80484 #include <linux/rculist.h>
80485 +#include <linux/mm.h>
80486
80487 +#ifdef CONFIG_DEBUG_LIST
80488 /*
80489 * Insert a new entry between two known consecutive entries.
80490 *
80491 @@ -19,21 +21,32 @@
80492 * the prev/next entries already!
80493 */
80494
80495 -void __list_add(struct list_head *new,
80496 - struct list_head *prev,
80497 - struct list_head *next)
80498 +static bool __list_add_debug(struct list_head *new,
80499 + struct list_head *prev,
80500 + struct list_head *next)
80501 {
80502 - WARN(next->prev != prev,
80503 + if (WARN(next->prev != prev,
80504 "list_add corruption. next->prev should be "
80505 "prev (%p), but was %p. (next=%p).\n",
80506 - prev, next->prev, next);
80507 - WARN(prev->next != next,
80508 + prev, next->prev, next) ||
80509 + WARN(prev->next != next,
80510 "list_add corruption. prev->next should be "
80511 "next (%p), but was %p. (prev=%p).\n",
80512 - next, prev->next, prev);
80513 - WARN(new == prev || new == next,
80514 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80515 - new, prev, next);
80516 + next, prev->next, prev) ||
80517 + WARN(new == prev || new == next,
80518 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80519 + new, prev, next))
80520 + return false;
80521 + return true;
80522 +}
80523 +
80524 +void __list_add(struct list_head *new,
80525 + struct list_head *prev,
80526 + struct list_head *next)
80527 +{
80528 + if (!__list_add_debug(new, prev, next))
80529 + return;
80530 +
80531 next->prev = new;
80532 new->next = next;
80533 new->prev = prev;
80534 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80535 }
80536 EXPORT_SYMBOL(__list_add);
80537
80538 -void __list_del_entry(struct list_head *entry)
80539 +static bool __list_del_entry_debug(struct list_head *entry)
80540 {
80541 struct list_head *prev, *next;
80542
80543 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80544 WARN(next->prev != entry,
80545 "list_del corruption. next->prev should be %p, "
80546 "but was %p\n", entry, next->prev))
80547 + return false;
80548 + return true;
80549 +}
80550 +
80551 +void __list_del_entry(struct list_head *entry)
80552 +{
80553 + if (!__list_del_entry_debug(entry))
80554 return;
80555
80556 - __list_del(prev, next);
80557 + __list_del(entry->prev, entry->next);
80558 }
80559 EXPORT_SYMBOL(__list_del_entry);
80560
80561 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80562 void __list_add_rcu(struct list_head *new,
80563 struct list_head *prev, struct list_head *next)
80564 {
80565 - WARN(next->prev != prev,
80566 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80567 - prev, next->prev, next);
80568 - WARN(prev->next != next,
80569 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80570 - next, prev->next, prev);
80571 + if (!__list_add_debug(new, prev, next))
80572 + return;
80573 +
80574 new->next = next;
80575 new->prev = prev;
80576 rcu_assign_pointer(list_next_rcu(prev), new);
80577 next->prev = new;
80578 }
80579 EXPORT_SYMBOL(__list_add_rcu);
80580 +#endif
80581 +
80582 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80583 +{
80584 +#ifdef CONFIG_DEBUG_LIST
80585 + if (!__list_add_debug(new, prev, next))
80586 + return;
80587 +#endif
80588 +
80589 + pax_open_kernel();
80590 + next->prev = new;
80591 + new->next = next;
80592 + new->prev = prev;
80593 + prev->next = new;
80594 + pax_close_kernel();
80595 +}
80596 +EXPORT_SYMBOL(__pax_list_add);
80597 +
80598 +void pax_list_del(struct list_head *entry)
80599 +{
80600 +#ifdef CONFIG_DEBUG_LIST
80601 + if (!__list_del_entry_debug(entry))
80602 + return;
80603 +#endif
80604 +
80605 + pax_open_kernel();
80606 + __list_del(entry->prev, entry->next);
80607 + entry->next = LIST_POISON1;
80608 + entry->prev = LIST_POISON2;
80609 + pax_close_kernel();
80610 +}
80611 +EXPORT_SYMBOL(pax_list_del);
80612 +
80613 +void pax_list_del_init(struct list_head *entry)
80614 +{
80615 + pax_open_kernel();
80616 + __list_del(entry->prev, entry->next);
80617 + INIT_LIST_HEAD(entry);
80618 + pax_close_kernel();
80619 +}
80620 +EXPORT_SYMBOL(pax_list_del_init);
80621 +
80622 +void __pax_list_add_rcu(struct list_head *new,
80623 + struct list_head *prev, struct list_head *next)
80624 +{
80625 +#ifdef CONFIG_DEBUG_LIST
80626 + if (!__list_add_debug(new, prev, next))
80627 + return;
80628 +#endif
80629 +
80630 + pax_open_kernel();
80631 + new->next = next;
80632 + new->prev = prev;
80633 + rcu_assign_pointer(list_next_rcu(prev), new);
80634 + next->prev = new;
80635 + pax_close_kernel();
80636 +}
80637 +EXPORT_SYMBOL(__pax_list_add_rcu);
80638 +
80639 +void pax_list_del_rcu(struct list_head *entry)
80640 +{
80641 +#ifdef CONFIG_DEBUG_LIST
80642 + if (!__list_del_entry_debug(entry))
80643 + return;
80644 +#endif
80645 +
80646 + pax_open_kernel();
80647 + __list_del(entry->prev, entry->next);
80648 + entry->next = LIST_POISON1;
80649 + entry->prev = LIST_POISON2;
80650 + pax_close_kernel();
80651 +}
80652 +EXPORT_SYMBOL(pax_list_del_rcu);
80653 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80654 index e796429..6e38f9f 100644
80655 --- a/lib/radix-tree.c
80656 +++ b/lib/radix-tree.c
80657 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80658 int nr;
80659 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80660 };
80661 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80662 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80663
80664 static inline void *ptr_to_indirect(void *ptr)
80665 {
80666 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80667 index bb2b201..46abaf9 100644
80668 --- a/lib/strncpy_from_user.c
80669 +++ b/lib/strncpy_from_user.c
80670 @@ -21,7 +21,7 @@
80671 */
80672 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80673 {
80674 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80675 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80676 long res = 0;
80677
80678 /*
80679 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80680 index a28df52..3d55877 100644
80681 --- a/lib/strnlen_user.c
80682 +++ b/lib/strnlen_user.c
80683 @@ -26,7 +26,7 @@
80684 */
80685 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80686 {
80687 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80688 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80689 long align, res = 0;
80690 unsigned long c;
80691
80692 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80693 index 196b069..358f342 100644
80694 --- a/lib/swiotlb.c
80695 +++ b/lib/swiotlb.c
80696 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80697
80698 void
80699 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80700 - dma_addr_t dev_addr)
80701 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80702 {
80703 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80704
80705 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80706 index fab33a9..3b5fe68 100644
80707 --- a/lib/vsprintf.c
80708 +++ b/lib/vsprintf.c
80709 @@ -16,6 +16,9 @@
80710 * - scnprintf and vscnprintf
80711 */
80712
80713 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80714 +#define __INCLUDED_BY_HIDESYM 1
80715 +#endif
80716 #include <stdarg.h>
80717 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80718 #include <linux/types.h>
80719 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80720 char sym[KSYM_SYMBOL_LEN];
80721 if (ext == 'B')
80722 sprint_backtrace(sym, value);
80723 - else if (ext != 'f' && ext != 's')
80724 + else if (ext != 'f' && ext != 's' && ext != 'a')
80725 sprint_symbol(sym, value);
80726 else
80727 sprint_symbol_no_offset(sym, value);
80728 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80729 return number(buf, end, *(const netdev_features_t *)addr, spec);
80730 }
80731
80732 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80733 +int kptr_restrict __read_mostly = 2;
80734 +#else
80735 int kptr_restrict __read_mostly;
80736 +#endif
80737
80738 /*
80739 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80740 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80741 * - 'S' For symbolic direct pointers with offset
80742 * - 's' For symbolic direct pointers without offset
80743 * - 'B' For backtraced symbolic direct pointers with offset
80744 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80745 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80746 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80747 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80748 * - 'M' For a 6-byte MAC address, it prints the address in the
80749 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80750
80751 if (!ptr && *fmt != 'K') {
80752 /*
80753 - * Print (null) with the same width as a pointer so it makes
80754 + * Print (nil) with the same width as a pointer so it makes
80755 * tabular output look nice.
80756 */
80757 if (spec.field_width == -1)
80758 spec.field_width = default_width;
80759 - return string(buf, end, "(null)", spec);
80760 + return string(buf, end, "(nil)", spec);
80761 }
80762
80763 switch (*fmt) {
80764 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80765 /* Fallthrough */
80766 case 'S':
80767 case 's':
80768 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80769 + break;
80770 +#else
80771 + return symbol_string(buf, end, ptr, spec, *fmt);
80772 +#endif
80773 + case 'A':
80774 + case 'a':
80775 case 'B':
80776 return symbol_string(buf, end, ptr, spec, *fmt);
80777 case 'R':
80778 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80779 va_end(va);
80780 return buf;
80781 }
80782 + case 'P':
80783 + break;
80784 case 'K':
80785 /*
80786 * %pK cannot be used in IRQ context because its test
80787 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80788 }
80789 break;
80790 }
80791 +
80792 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80793 + /* 'P' = approved pointers to copy to userland,
80794 + as in the /proc/kallsyms case, as we make it display nothing
80795 + for non-root users, and the real contents for root users
80796 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80797 + above
80798 + */
80799 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80800 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80801 + dump_stack();
80802 + ptr = NULL;
80803 + }
80804 +#endif
80805 +
80806 spec.flags |= SMALL;
80807 if (spec.field_width == -1) {
80808 spec.field_width = default_width;
80809 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80810 typeof(type) value; \
80811 if (sizeof(type) == 8) { \
80812 args = PTR_ALIGN(args, sizeof(u32)); \
80813 - *(u32 *)&value = *(u32 *)args; \
80814 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80815 + *(u32 *)&value = *(const u32 *)args; \
80816 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80817 } else { \
80818 args = PTR_ALIGN(args, sizeof(type)); \
80819 - value = *(typeof(type) *)args; \
80820 + value = *(const typeof(type) *)args; \
80821 } \
80822 args += sizeof(type); \
80823 value; \
80824 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80825 case FORMAT_TYPE_STR: {
80826 const char *str_arg = args;
80827 args += strlen(str_arg) + 1;
80828 - str = string(str, end, (char *)str_arg, spec);
80829 + str = string(str, end, str_arg, spec);
80830 break;
80831 }
80832
80833 diff --git a/localversion-grsec b/localversion-grsec
80834 new file mode 100644
80835 index 0000000..7cd6065
80836 --- /dev/null
80837 +++ b/localversion-grsec
80838 @@ -0,0 +1 @@
80839 +-grsec
80840 diff --git a/mm/Kconfig b/mm/Kconfig
80841 index 278e3ab..87c384d 100644
80842 --- a/mm/Kconfig
80843 +++ b/mm/Kconfig
80844 @@ -286,10 +286,10 @@ config KSM
80845 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80846
80847 config DEFAULT_MMAP_MIN_ADDR
80848 - int "Low address space to protect from user allocation"
80849 + int "Low address space to protect from user allocation"
80850 depends on MMU
80851 - default 4096
80852 - help
80853 + default 65536
80854 + help
80855 This is the portion of low virtual memory which should be protected
80856 from userspace allocation. Keeping a user from writing to low pages
80857 can help reduce the impact of kernel NULL pointer bugs.
80858 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80859
80860 config HWPOISON_INJECT
80861 tristate "HWPoison pages injector"
80862 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80863 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80864 select PROC_PAGE_MONITOR
80865
80866 config NOMMU_INITIAL_TRIM_EXCESS
80867 diff --git a/mm/filemap.c b/mm/filemap.c
80868 index 83efee7..3f99381 100644
80869 --- a/mm/filemap.c
80870 +++ b/mm/filemap.c
80871 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80872 struct address_space *mapping = file->f_mapping;
80873
80874 if (!mapping->a_ops->readpage)
80875 - return -ENOEXEC;
80876 + return -ENODEV;
80877 file_accessed(file);
80878 vma->vm_ops = &generic_file_vm_ops;
80879 return 0;
80880 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80881 *pos = i_size_read(inode);
80882
80883 if (limit != RLIM_INFINITY) {
80884 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80885 if (*pos >= limit) {
80886 send_sig(SIGXFSZ, current, 0);
80887 return -EFBIG;
80888 diff --git a/mm/fremap.c b/mm/fremap.c
80889 index a0aaf0e..20325c3 100644
80890 --- a/mm/fremap.c
80891 +++ b/mm/fremap.c
80892 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80893 retry:
80894 vma = find_vma(mm, start);
80895
80896 +#ifdef CONFIG_PAX_SEGMEXEC
80897 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80898 + goto out;
80899 +#endif
80900 +
80901 /*
80902 * Make sure the vma is shared, that it supports prefaulting,
80903 * and that the remapped range is valid and fully within
80904 diff --git a/mm/highmem.c b/mm/highmem.c
80905 index b32b70c..e512eb0 100644
80906 --- a/mm/highmem.c
80907 +++ b/mm/highmem.c
80908 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80909 * So no dangers, even with speculative execution.
80910 */
80911 page = pte_page(pkmap_page_table[i]);
80912 + pax_open_kernel();
80913 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80914 -
80915 + pax_close_kernel();
80916 set_page_address(page, NULL);
80917 need_flush = 1;
80918 }
80919 @@ -198,9 +199,11 @@ start:
80920 }
80921 }
80922 vaddr = PKMAP_ADDR(last_pkmap_nr);
80923 +
80924 + pax_open_kernel();
80925 set_pte_at(&init_mm, vaddr,
80926 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80927 -
80928 + pax_close_kernel();
80929 pkmap_count[last_pkmap_nr] = 1;
80930 set_page_address(page, (void *)vaddr);
80931
80932 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80933 index 88eb939..0bd9e7d 100644
80934 --- a/mm/hugetlb.c
80935 +++ b/mm/hugetlb.c
80936 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80937 struct hstate *h = &default_hstate;
80938 unsigned long tmp;
80939 int ret;
80940 + ctl_table_no_const hugetlb_table;
80941
80942 tmp = h->max_huge_pages;
80943
80944 if (write && h->order >= MAX_ORDER)
80945 return -EINVAL;
80946
80947 - table->data = &tmp;
80948 - table->maxlen = sizeof(unsigned long);
80949 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80950 + hugetlb_table = *table;
80951 + hugetlb_table.data = &tmp;
80952 + hugetlb_table.maxlen = sizeof(unsigned long);
80953 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80954 if (ret)
80955 goto out;
80956
80957 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80958 struct hstate *h = &default_hstate;
80959 unsigned long tmp;
80960 int ret;
80961 + ctl_table_no_const hugetlb_table;
80962
80963 tmp = h->nr_overcommit_huge_pages;
80964
80965 if (write && h->order >= MAX_ORDER)
80966 return -EINVAL;
80967
80968 - table->data = &tmp;
80969 - table->maxlen = sizeof(unsigned long);
80970 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80971 + hugetlb_table = *table;
80972 + hugetlb_table.data = &tmp;
80973 + hugetlb_table.maxlen = sizeof(unsigned long);
80974 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80975 if (ret)
80976 goto out;
80977
80978 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80979 return 1;
80980 }
80981
80982 +#ifdef CONFIG_PAX_SEGMEXEC
80983 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80984 +{
80985 + struct mm_struct *mm = vma->vm_mm;
80986 + struct vm_area_struct *vma_m;
80987 + unsigned long address_m;
80988 + pte_t *ptep_m;
80989 +
80990 + vma_m = pax_find_mirror_vma(vma);
80991 + if (!vma_m)
80992 + return;
80993 +
80994 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80995 + address_m = address + SEGMEXEC_TASK_SIZE;
80996 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80997 + get_page(page_m);
80998 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80999 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81000 +}
81001 +#endif
81002 +
81003 /*
81004 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81005 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81006 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
81007 make_huge_pte(vma, new_page, 1));
81008 page_remove_rmap(old_page);
81009 hugepage_add_new_anon_rmap(new_page, vma, address);
81010 +
81011 +#ifdef CONFIG_PAX_SEGMEXEC
81012 + pax_mirror_huge_pte(vma, address, new_page);
81013 +#endif
81014 +
81015 /* Make the old page be freed below */
81016 new_page = old_page;
81017 }
81018 @@ -2792,6 +2822,10 @@ retry:
81019 && (vma->vm_flags & VM_SHARED)));
81020 set_huge_pte_at(mm, address, ptep, new_pte);
81021
81022 +#ifdef CONFIG_PAX_SEGMEXEC
81023 + pax_mirror_huge_pte(vma, address, page);
81024 +#endif
81025 +
81026 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81027 /* Optimization, do the COW without a second fault */
81028 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81029 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81030 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81031 struct hstate *h = hstate_vma(vma);
81032
81033 +#ifdef CONFIG_PAX_SEGMEXEC
81034 + struct vm_area_struct *vma_m;
81035 +#endif
81036 +
81037 address &= huge_page_mask(h);
81038
81039 ptep = huge_pte_offset(mm, address);
81040 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81041 VM_FAULT_SET_HINDEX(hstate_index(h));
81042 }
81043
81044 +#ifdef CONFIG_PAX_SEGMEXEC
81045 + vma_m = pax_find_mirror_vma(vma);
81046 + if (vma_m) {
81047 + unsigned long address_m;
81048 +
81049 + if (vma->vm_start > vma_m->vm_start) {
81050 + address_m = address;
81051 + address -= SEGMEXEC_TASK_SIZE;
81052 + vma = vma_m;
81053 + h = hstate_vma(vma);
81054 + } else
81055 + address_m = address + SEGMEXEC_TASK_SIZE;
81056 +
81057 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81058 + return VM_FAULT_OOM;
81059 + address_m &= HPAGE_MASK;
81060 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81061 + }
81062 +#endif
81063 +
81064 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81065 if (!ptep)
81066 return VM_FAULT_OOM;
81067 diff --git a/mm/internal.h b/mm/internal.h
81068 index 9ba2110..eaf0674 100644
81069 --- a/mm/internal.h
81070 +++ b/mm/internal.h
81071 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81072 * in mm/page_alloc.c
81073 */
81074 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81075 +extern void free_compound_page(struct page *page);
81076 extern void prep_compound_page(struct page *page, unsigned long order);
81077 #ifdef CONFIG_MEMORY_FAILURE
81078 extern bool is_free_buddy_page(struct page *page);
81079 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81080 index 752a705..6c3102e 100644
81081 --- a/mm/kmemleak.c
81082 +++ b/mm/kmemleak.c
81083 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81084
81085 for (i = 0; i < object->trace_len; i++) {
81086 void *ptr = (void *)object->trace[i];
81087 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81088 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81089 }
81090 }
81091
81092 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
81093 return -ENOMEM;
81094 }
81095
81096 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81097 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81098 &kmemleak_fops);
81099 if (!dentry)
81100 pr_warning("Failed to create the debugfs kmemleak file\n");
81101 diff --git a/mm/maccess.c b/mm/maccess.c
81102 index d53adf9..03a24bf 100644
81103 --- a/mm/maccess.c
81104 +++ b/mm/maccess.c
81105 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81106 set_fs(KERNEL_DS);
81107 pagefault_disable();
81108 ret = __copy_from_user_inatomic(dst,
81109 - (__force const void __user *)src, size);
81110 + (const void __force_user *)src, size);
81111 pagefault_enable();
81112 set_fs(old_fs);
81113
81114 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81115
81116 set_fs(KERNEL_DS);
81117 pagefault_disable();
81118 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81119 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81120 pagefault_enable();
81121 set_fs(old_fs);
81122
81123 diff --git a/mm/madvise.c b/mm/madvise.c
81124 index 03dfa5c..b032917 100644
81125 --- a/mm/madvise.c
81126 +++ b/mm/madvise.c
81127 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81128 pgoff_t pgoff;
81129 unsigned long new_flags = vma->vm_flags;
81130
81131 +#ifdef CONFIG_PAX_SEGMEXEC
81132 + struct vm_area_struct *vma_m;
81133 +#endif
81134 +
81135 switch (behavior) {
81136 case MADV_NORMAL:
81137 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81138 @@ -123,6 +127,13 @@ success:
81139 /*
81140 * vm_flags is protected by the mmap_sem held in write mode.
81141 */
81142 +
81143 +#ifdef CONFIG_PAX_SEGMEXEC
81144 + vma_m = pax_find_mirror_vma(vma);
81145 + if (vma_m)
81146 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81147 +#endif
81148 +
81149 vma->vm_flags = new_flags;
81150
81151 out:
81152 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81153 struct vm_area_struct ** prev,
81154 unsigned long start, unsigned long end)
81155 {
81156 +
81157 +#ifdef CONFIG_PAX_SEGMEXEC
81158 + struct vm_area_struct *vma_m;
81159 +#endif
81160 +
81161 *prev = vma;
81162 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81163 return -EINVAL;
81164 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81165 zap_page_range(vma, start, end - start, &details);
81166 } else
81167 zap_page_range(vma, start, end - start, NULL);
81168 +
81169 +#ifdef CONFIG_PAX_SEGMEXEC
81170 + vma_m = pax_find_mirror_vma(vma);
81171 + if (vma_m) {
81172 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81173 + struct zap_details details = {
81174 + .nonlinear_vma = vma_m,
81175 + .last_index = ULONG_MAX,
81176 + };
81177 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81178 + } else
81179 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81180 + }
81181 +#endif
81182 +
81183 return 0;
81184 }
81185
81186 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81187 if (end < start)
81188 goto out;
81189
81190 +#ifdef CONFIG_PAX_SEGMEXEC
81191 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81192 + if (end > SEGMEXEC_TASK_SIZE)
81193 + goto out;
81194 + } else
81195 +#endif
81196 +
81197 + if (end > TASK_SIZE)
81198 + goto out;
81199 +
81200 error = 0;
81201 if (end == start)
81202 goto out;
81203 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81204 index c6e4dd3..1f41988 100644
81205 --- a/mm/memory-failure.c
81206 +++ b/mm/memory-failure.c
81207 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81208
81209 int sysctl_memory_failure_recovery __read_mostly = 1;
81210
81211 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81212 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81213
81214 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81215
81216 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81217 pfn, t->comm, t->pid);
81218 si.si_signo = SIGBUS;
81219 si.si_errno = 0;
81220 - si.si_addr = (void *)addr;
81221 + si.si_addr = (void __user *)addr;
81222 #ifdef __ARCH_SI_TRAPNO
81223 si.si_trapno = trapno;
81224 #endif
81225 @@ -760,7 +760,7 @@ static struct page_state {
81226 unsigned long res;
81227 char *msg;
81228 int (*action)(struct page *p, unsigned long pfn);
81229 -} error_states[] = {
81230 +} __do_const error_states[] = {
81231 { reserved, reserved, "reserved kernel", me_kernel },
81232 /*
81233 * free pages are specially detected outside this table:
81234 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81235 }
81236
81237 nr_pages = 1 << compound_trans_order(hpage);
81238 - atomic_long_add(nr_pages, &mce_bad_pages);
81239 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81240
81241 /*
81242 * We need/can do nothing about count=0 pages.
81243 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81244 if (!PageHWPoison(hpage)
81245 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81246 || (p != hpage && TestSetPageHWPoison(hpage))) {
81247 - atomic_long_sub(nr_pages, &mce_bad_pages);
81248 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81249 return 0;
81250 }
81251 set_page_hwpoison_huge_page(hpage);
81252 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81253 }
81254 if (hwpoison_filter(p)) {
81255 if (TestClearPageHWPoison(p))
81256 - atomic_long_sub(nr_pages, &mce_bad_pages);
81257 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81258 unlock_page(hpage);
81259 put_page(hpage);
81260 return 0;
81261 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81262 return 0;
81263 }
81264 if (TestClearPageHWPoison(p))
81265 - atomic_long_sub(nr_pages, &mce_bad_pages);
81266 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81267 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81268 return 0;
81269 }
81270 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81271 */
81272 if (TestClearPageHWPoison(page)) {
81273 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81274 - atomic_long_sub(nr_pages, &mce_bad_pages);
81275 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81276 freeit = 1;
81277 if (PageHuge(page))
81278 clear_page_hwpoison_huge_page(page);
81279 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81280 }
81281 done:
81282 if (!PageHWPoison(hpage))
81283 - atomic_long_add(1 << compound_trans_order(hpage),
81284 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81285 &mce_bad_pages);
81286 set_page_hwpoison_huge_page(hpage);
81287 dequeue_hwpoisoned_huge_page(hpage);
81288 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81289 return ret;
81290
81291 done:
81292 - atomic_long_add(1, &mce_bad_pages);
81293 + atomic_long_add_unchecked(1, &mce_bad_pages);
81294 SetPageHWPoison(page);
81295 /* keep elevated page count for bad page */
81296 return ret;
81297 diff --git a/mm/memory.c b/mm/memory.c
81298 index 32a495a..8042dce 100644
81299 --- a/mm/memory.c
81300 +++ b/mm/memory.c
81301 @@ -434,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81302 free_pte_range(tlb, pmd, addr);
81303 } while (pmd++, addr = next, addr != end);
81304
81305 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81306 start &= PUD_MASK;
81307 if (start < floor)
81308 return;
81309 @@ -448,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81310 pmd = pmd_offset(pud, start);
81311 pud_clear(pud);
81312 pmd_free_tlb(tlb, pmd, start);
81313 +#endif
81314 +
81315 }
81316
81317 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81318 @@ -467,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81319 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81320 } while (pud++, addr = next, addr != end);
81321
81322 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81323 start &= PGDIR_MASK;
81324 if (start < floor)
81325 return;
81326 @@ -481,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81327 pud = pud_offset(pgd, start);
81328 pgd_clear(pgd);
81329 pud_free_tlb(tlb, pud, start);
81330 +#endif
81331 +
81332 }
81333
81334 /*
81335 @@ -1619,12 +1625,6 @@ no_page_table:
81336 return page;
81337 }
81338
81339 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81340 -{
81341 - return stack_guard_page_start(vma, addr) ||
81342 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81343 -}
81344 -
81345 /**
81346 * __get_user_pages() - pin user pages in memory
81347 * @tsk: task_struct of target task
81348 @@ -1710,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81349
81350 i = 0;
81351
81352 - do {
81353 + while (nr_pages) {
81354 struct vm_area_struct *vma;
81355
81356 - vma = find_extend_vma(mm, start);
81357 + vma = find_vma(mm, start);
81358 if (!vma && in_gate_area(mm, start)) {
81359 unsigned long pg = start & PAGE_MASK;
81360 pgd_t *pgd;
81361 @@ -1761,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81362 goto next_page;
81363 }
81364
81365 - if (!vma ||
81366 + if (!vma || start < vma->vm_start ||
81367 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81368 !(vm_flags & vma->vm_flags))
81369 return i ? : -EFAULT;
81370 @@ -1788,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81371 int ret;
81372 unsigned int fault_flags = 0;
81373
81374 - /* For mlock, just skip the stack guard page. */
81375 - if (foll_flags & FOLL_MLOCK) {
81376 - if (stack_guard_page(vma, start))
81377 - goto next_page;
81378 - }
81379 if (foll_flags & FOLL_WRITE)
81380 fault_flags |= FAULT_FLAG_WRITE;
81381 if (nonblocking)
81382 @@ -1866,7 +1861,7 @@ next_page:
81383 start += PAGE_SIZE;
81384 nr_pages--;
81385 } while (nr_pages && start < vma->vm_end);
81386 - } while (nr_pages);
81387 + }
81388 return i;
81389 }
81390 EXPORT_SYMBOL(__get_user_pages);
81391 @@ -2073,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81392 page_add_file_rmap(page);
81393 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81394
81395 +#ifdef CONFIG_PAX_SEGMEXEC
81396 + pax_mirror_file_pte(vma, addr, page, ptl);
81397 +#endif
81398 +
81399 retval = 0;
81400 pte_unmap_unlock(pte, ptl);
81401 return retval;
81402 @@ -2117,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81403 if (!page_count(page))
81404 return -EINVAL;
81405 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81406 +
81407 +#ifdef CONFIG_PAX_SEGMEXEC
81408 + struct vm_area_struct *vma_m;
81409 +#endif
81410 +
81411 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81412 BUG_ON(vma->vm_flags & VM_PFNMAP);
81413 vma->vm_flags |= VM_MIXEDMAP;
81414 +
81415 +#ifdef CONFIG_PAX_SEGMEXEC
81416 + vma_m = pax_find_mirror_vma(vma);
81417 + if (vma_m)
81418 + vma_m->vm_flags |= VM_MIXEDMAP;
81419 +#endif
81420 +
81421 }
81422 return insert_page(vma, addr, page, vma->vm_page_prot);
81423 }
81424 @@ -2202,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81425 unsigned long pfn)
81426 {
81427 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81428 + BUG_ON(vma->vm_mirror);
81429
81430 if (addr < vma->vm_start || addr >= vma->vm_end)
81431 return -EFAULT;
81432 @@ -2449,7 +2461,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81433
81434 BUG_ON(pud_huge(*pud));
81435
81436 - pmd = pmd_alloc(mm, pud, addr);
81437 + pmd = (mm == &init_mm) ?
81438 + pmd_alloc_kernel(mm, pud, addr) :
81439 + pmd_alloc(mm, pud, addr);
81440 if (!pmd)
81441 return -ENOMEM;
81442 do {
81443 @@ -2469,7 +2483,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81444 unsigned long next;
81445 int err;
81446
81447 - pud = pud_alloc(mm, pgd, addr);
81448 + pud = (mm == &init_mm) ?
81449 + pud_alloc_kernel(mm, pgd, addr) :
81450 + pud_alloc(mm, pgd, addr);
81451 if (!pud)
81452 return -ENOMEM;
81453 do {
81454 @@ -2557,6 +2573,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81455 copy_user_highpage(dst, src, va, vma);
81456 }
81457
81458 +#ifdef CONFIG_PAX_SEGMEXEC
81459 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81460 +{
81461 + struct mm_struct *mm = vma->vm_mm;
81462 + spinlock_t *ptl;
81463 + pte_t *pte, entry;
81464 +
81465 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81466 + entry = *pte;
81467 + if (!pte_present(entry)) {
81468 + if (!pte_none(entry)) {
81469 + BUG_ON(pte_file(entry));
81470 + free_swap_and_cache(pte_to_swp_entry(entry));
81471 + pte_clear_not_present_full(mm, address, pte, 0);
81472 + }
81473 + } else {
81474 + struct page *page;
81475 +
81476 + flush_cache_page(vma, address, pte_pfn(entry));
81477 + entry = ptep_clear_flush(vma, address, pte);
81478 + BUG_ON(pte_dirty(entry));
81479 + page = vm_normal_page(vma, address, entry);
81480 + if (page) {
81481 + update_hiwater_rss(mm);
81482 + if (PageAnon(page))
81483 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81484 + else
81485 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81486 + page_remove_rmap(page);
81487 + page_cache_release(page);
81488 + }
81489 + }
81490 + pte_unmap_unlock(pte, ptl);
81491 +}
81492 +
81493 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81494 + *
81495 + * the ptl of the lower mapped page is held on entry and is not released on exit
81496 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81497 + */
81498 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81499 +{
81500 + struct mm_struct *mm = vma->vm_mm;
81501 + unsigned long address_m;
81502 + spinlock_t *ptl_m;
81503 + struct vm_area_struct *vma_m;
81504 + pmd_t *pmd_m;
81505 + pte_t *pte_m, entry_m;
81506 +
81507 + BUG_ON(!page_m || !PageAnon(page_m));
81508 +
81509 + vma_m = pax_find_mirror_vma(vma);
81510 + if (!vma_m)
81511 + return;
81512 +
81513 + BUG_ON(!PageLocked(page_m));
81514 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81515 + address_m = address + SEGMEXEC_TASK_SIZE;
81516 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81517 + pte_m = pte_offset_map(pmd_m, address_m);
81518 + ptl_m = pte_lockptr(mm, pmd_m);
81519 + if (ptl != ptl_m) {
81520 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81521 + if (!pte_none(*pte_m))
81522 + goto out;
81523 + }
81524 +
81525 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81526 + page_cache_get(page_m);
81527 + page_add_anon_rmap(page_m, vma_m, address_m);
81528 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81529 + set_pte_at(mm, address_m, pte_m, entry_m);
81530 + update_mmu_cache(vma_m, address_m, entry_m);
81531 +out:
81532 + if (ptl != ptl_m)
81533 + spin_unlock(ptl_m);
81534 + pte_unmap(pte_m);
81535 + unlock_page(page_m);
81536 +}
81537 +
81538 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81539 +{
81540 + struct mm_struct *mm = vma->vm_mm;
81541 + unsigned long address_m;
81542 + spinlock_t *ptl_m;
81543 + struct vm_area_struct *vma_m;
81544 + pmd_t *pmd_m;
81545 + pte_t *pte_m, entry_m;
81546 +
81547 + BUG_ON(!page_m || PageAnon(page_m));
81548 +
81549 + vma_m = pax_find_mirror_vma(vma);
81550 + if (!vma_m)
81551 + return;
81552 +
81553 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81554 + address_m = address + SEGMEXEC_TASK_SIZE;
81555 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81556 + pte_m = pte_offset_map(pmd_m, address_m);
81557 + ptl_m = pte_lockptr(mm, pmd_m);
81558 + if (ptl != ptl_m) {
81559 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81560 + if (!pte_none(*pte_m))
81561 + goto out;
81562 + }
81563 +
81564 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81565 + page_cache_get(page_m);
81566 + page_add_file_rmap(page_m);
81567 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81568 + set_pte_at(mm, address_m, pte_m, entry_m);
81569 + update_mmu_cache(vma_m, address_m, entry_m);
81570 +out:
81571 + if (ptl != ptl_m)
81572 + spin_unlock(ptl_m);
81573 + pte_unmap(pte_m);
81574 +}
81575 +
81576 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81577 +{
81578 + struct mm_struct *mm = vma->vm_mm;
81579 + unsigned long address_m;
81580 + spinlock_t *ptl_m;
81581 + struct vm_area_struct *vma_m;
81582 + pmd_t *pmd_m;
81583 + pte_t *pte_m, entry_m;
81584 +
81585 + vma_m = pax_find_mirror_vma(vma);
81586 + if (!vma_m)
81587 + return;
81588 +
81589 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81590 + address_m = address + SEGMEXEC_TASK_SIZE;
81591 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81592 + pte_m = pte_offset_map(pmd_m, address_m);
81593 + ptl_m = pte_lockptr(mm, pmd_m);
81594 + if (ptl != ptl_m) {
81595 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81596 + if (!pte_none(*pte_m))
81597 + goto out;
81598 + }
81599 +
81600 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81601 + set_pte_at(mm, address_m, pte_m, entry_m);
81602 +out:
81603 + if (ptl != ptl_m)
81604 + spin_unlock(ptl_m);
81605 + pte_unmap(pte_m);
81606 +}
81607 +
81608 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81609 +{
81610 + struct page *page_m;
81611 + pte_t entry;
81612 +
81613 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81614 + goto out;
81615 +
81616 + entry = *pte;
81617 + page_m = vm_normal_page(vma, address, entry);
81618 + if (!page_m)
81619 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81620 + else if (PageAnon(page_m)) {
81621 + if (pax_find_mirror_vma(vma)) {
81622 + pte_unmap_unlock(pte, ptl);
81623 + lock_page(page_m);
81624 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81625 + if (pte_same(entry, *pte))
81626 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81627 + else
81628 + unlock_page(page_m);
81629 + }
81630 + } else
81631 + pax_mirror_file_pte(vma, address, page_m, ptl);
81632 +
81633 +out:
81634 + pte_unmap_unlock(pte, ptl);
81635 +}
81636 +#endif
81637 +
81638 /*
81639 * This routine handles present pages, when users try to write
81640 * to a shared page. It is done by copying the page to a new address
81641 @@ -2773,6 +2969,12 @@ gotten:
81642 */
81643 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81644 if (likely(pte_same(*page_table, orig_pte))) {
81645 +
81646 +#ifdef CONFIG_PAX_SEGMEXEC
81647 + if (pax_find_mirror_vma(vma))
81648 + BUG_ON(!trylock_page(new_page));
81649 +#endif
81650 +
81651 if (old_page) {
81652 if (!PageAnon(old_page)) {
81653 dec_mm_counter_fast(mm, MM_FILEPAGES);
81654 @@ -2824,6 +3026,10 @@ gotten:
81655 page_remove_rmap(old_page);
81656 }
81657
81658 +#ifdef CONFIG_PAX_SEGMEXEC
81659 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81660 +#endif
81661 +
81662 /* Free the old page.. */
81663 new_page = old_page;
81664 ret |= VM_FAULT_WRITE;
81665 @@ -3099,6 +3305,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81666 swap_free(entry);
81667 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81668 try_to_free_swap(page);
81669 +
81670 +#ifdef CONFIG_PAX_SEGMEXEC
81671 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81672 +#endif
81673 +
81674 unlock_page(page);
81675 if (swapcache) {
81676 /*
81677 @@ -3122,6 +3333,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81678
81679 /* No need to invalidate - it was non-present before */
81680 update_mmu_cache(vma, address, page_table);
81681 +
81682 +#ifdef CONFIG_PAX_SEGMEXEC
81683 + pax_mirror_anon_pte(vma, address, page, ptl);
81684 +#endif
81685 +
81686 unlock:
81687 pte_unmap_unlock(page_table, ptl);
81688 out:
81689 @@ -3141,40 +3357,6 @@ out_release:
81690 }
81691
81692 /*
81693 - * This is like a special single-page "expand_{down|up}wards()",
81694 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81695 - * doesn't hit another vma.
81696 - */
81697 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81698 -{
81699 - address &= PAGE_MASK;
81700 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81701 - struct vm_area_struct *prev = vma->vm_prev;
81702 -
81703 - /*
81704 - * Is there a mapping abutting this one below?
81705 - *
81706 - * That's only ok if it's the same stack mapping
81707 - * that has gotten split..
81708 - */
81709 - if (prev && prev->vm_end == address)
81710 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81711 -
81712 - expand_downwards(vma, address - PAGE_SIZE);
81713 - }
81714 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81715 - struct vm_area_struct *next = vma->vm_next;
81716 -
81717 - /* As VM_GROWSDOWN but s/below/above/ */
81718 - if (next && next->vm_start == address + PAGE_SIZE)
81719 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81720 -
81721 - expand_upwards(vma, address + PAGE_SIZE);
81722 - }
81723 - return 0;
81724 -}
81725 -
81726 -/*
81727 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81728 * but allow concurrent faults), and pte mapped but not yet locked.
81729 * We return with mmap_sem still held, but pte unmapped and unlocked.
81730 @@ -3183,27 +3365,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81731 unsigned long address, pte_t *page_table, pmd_t *pmd,
81732 unsigned int flags)
81733 {
81734 - struct page *page;
81735 + struct page *page = NULL;
81736 spinlock_t *ptl;
81737 pte_t entry;
81738
81739 - pte_unmap(page_table);
81740 -
81741 - /* Check if we need to add a guard page to the stack */
81742 - if (check_stack_guard_page(vma, address) < 0)
81743 - return VM_FAULT_SIGBUS;
81744 -
81745 - /* Use the zero-page for reads */
81746 if (!(flags & FAULT_FLAG_WRITE)) {
81747 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81748 vma->vm_page_prot));
81749 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81750 + ptl = pte_lockptr(mm, pmd);
81751 + spin_lock(ptl);
81752 if (!pte_none(*page_table))
81753 goto unlock;
81754 goto setpte;
81755 }
81756
81757 /* Allocate our own private page. */
81758 + pte_unmap(page_table);
81759 +
81760 if (unlikely(anon_vma_prepare(vma)))
81761 goto oom;
81762 page = alloc_zeroed_user_highpage_movable(vma, address);
81763 @@ -3222,6 +3400,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81764 if (!pte_none(*page_table))
81765 goto release;
81766
81767 +#ifdef CONFIG_PAX_SEGMEXEC
81768 + if (pax_find_mirror_vma(vma))
81769 + BUG_ON(!trylock_page(page));
81770 +#endif
81771 +
81772 inc_mm_counter_fast(mm, MM_ANONPAGES);
81773 page_add_new_anon_rmap(page, vma, address);
81774 setpte:
81775 @@ -3229,6 +3412,12 @@ setpte:
81776
81777 /* No need to invalidate - it was non-present before */
81778 update_mmu_cache(vma, address, page_table);
81779 +
81780 +#ifdef CONFIG_PAX_SEGMEXEC
81781 + if (page)
81782 + pax_mirror_anon_pte(vma, address, page, ptl);
81783 +#endif
81784 +
81785 unlock:
81786 pte_unmap_unlock(page_table, ptl);
81787 return 0;
81788 @@ -3372,6 +3561,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81789 */
81790 /* Only go through if we didn't race with anybody else... */
81791 if (likely(pte_same(*page_table, orig_pte))) {
81792 +
81793 +#ifdef CONFIG_PAX_SEGMEXEC
81794 + if (anon && pax_find_mirror_vma(vma))
81795 + BUG_ON(!trylock_page(page));
81796 +#endif
81797 +
81798 flush_icache_page(vma, page);
81799 entry = mk_pte(page, vma->vm_page_prot);
81800 if (flags & FAULT_FLAG_WRITE)
81801 @@ -3391,6 +3586,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81802
81803 /* no need to invalidate: a not-present page won't be cached */
81804 update_mmu_cache(vma, address, page_table);
81805 +
81806 +#ifdef CONFIG_PAX_SEGMEXEC
81807 + if (anon)
81808 + pax_mirror_anon_pte(vma, address, page, ptl);
81809 + else
81810 + pax_mirror_file_pte(vma, address, page, ptl);
81811 +#endif
81812 +
81813 } else {
81814 if (cow_page)
81815 mem_cgroup_uncharge_page(cow_page);
81816 @@ -3712,6 +3915,12 @@ int handle_pte_fault(struct mm_struct *mm,
81817 if (flags & FAULT_FLAG_WRITE)
81818 flush_tlb_fix_spurious_fault(vma, address);
81819 }
81820 +
81821 +#ifdef CONFIG_PAX_SEGMEXEC
81822 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81823 + return 0;
81824 +#endif
81825 +
81826 unlock:
81827 pte_unmap_unlock(pte, ptl);
81828 return 0;
81829 @@ -3728,6 +3937,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81830 pmd_t *pmd;
81831 pte_t *pte;
81832
81833 +#ifdef CONFIG_PAX_SEGMEXEC
81834 + struct vm_area_struct *vma_m;
81835 +#endif
81836 +
81837 __set_current_state(TASK_RUNNING);
81838
81839 count_vm_event(PGFAULT);
81840 @@ -3739,6 +3952,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81841 if (unlikely(is_vm_hugetlb_page(vma)))
81842 return hugetlb_fault(mm, vma, address, flags);
81843
81844 +#ifdef CONFIG_PAX_SEGMEXEC
81845 + vma_m = pax_find_mirror_vma(vma);
81846 + if (vma_m) {
81847 + unsigned long address_m;
81848 + pgd_t *pgd_m;
81849 + pud_t *pud_m;
81850 + pmd_t *pmd_m;
81851 +
81852 + if (vma->vm_start > vma_m->vm_start) {
81853 + address_m = address;
81854 + address -= SEGMEXEC_TASK_SIZE;
81855 + vma = vma_m;
81856 + } else
81857 + address_m = address + SEGMEXEC_TASK_SIZE;
81858 +
81859 + pgd_m = pgd_offset(mm, address_m);
81860 + pud_m = pud_alloc(mm, pgd_m, address_m);
81861 + if (!pud_m)
81862 + return VM_FAULT_OOM;
81863 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81864 + if (!pmd_m)
81865 + return VM_FAULT_OOM;
81866 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81867 + return VM_FAULT_OOM;
81868 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81869 + }
81870 +#endif
81871 +
81872 retry:
81873 pgd = pgd_offset(mm, address);
81874 pud = pud_alloc(mm, pgd, address);
81875 @@ -3837,6 +4078,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81876 spin_unlock(&mm->page_table_lock);
81877 return 0;
81878 }
81879 +
81880 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81881 +{
81882 + pud_t *new = pud_alloc_one(mm, address);
81883 + if (!new)
81884 + return -ENOMEM;
81885 +
81886 + smp_wmb(); /* See comment in __pte_alloc */
81887 +
81888 + spin_lock(&mm->page_table_lock);
81889 + if (pgd_present(*pgd)) /* Another has populated it */
81890 + pud_free(mm, new);
81891 + else
81892 + pgd_populate_kernel(mm, pgd, new);
81893 + spin_unlock(&mm->page_table_lock);
81894 + return 0;
81895 +}
81896 #endif /* __PAGETABLE_PUD_FOLDED */
81897
81898 #ifndef __PAGETABLE_PMD_FOLDED
81899 @@ -3867,11 +4125,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81900 spin_unlock(&mm->page_table_lock);
81901 return 0;
81902 }
81903 +
81904 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81905 +{
81906 + pmd_t *new = pmd_alloc_one(mm, address);
81907 + if (!new)
81908 + return -ENOMEM;
81909 +
81910 + smp_wmb(); /* See comment in __pte_alloc */
81911 +
81912 + spin_lock(&mm->page_table_lock);
81913 +#ifndef __ARCH_HAS_4LEVEL_HACK
81914 + if (pud_present(*pud)) /* Another has populated it */
81915 + pmd_free(mm, new);
81916 + else
81917 + pud_populate_kernel(mm, pud, new);
81918 +#else
81919 + if (pgd_present(*pud)) /* Another has populated it */
81920 + pmd_free(mm, new);
81921 + else
81922 + pgd_populate_kernel(mm, pud, new);
81923 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81924 + spin_unlock(&mm->page_table_lock);
81925 + return 0;
81926 +}
81927 #endif /* __PAGETABLE_PMD_FOLDED */
81928
81929 -int make_pages_present(unsigned long addr, unsigned long end)
81930 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81931 {
81932 - int ret, len, write;
81933 + ssize_t ret, len, write;
81934 struct vm_area_struct * vma;
81935
81936 vma = find_vma(current->mm, addr);
81937 @@ -3904,7 +4186,7 @@ static int __init gate_vma_init(void)
81938 gate_vma.vm_start = FIXADDR_USER_START;
81939 gate_vma.vm_end = FIXADDR_USER_END;
81940 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81941 - gate_vma.vm_page_prot = __P101;
81942 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81943
81944 return 0;
81945 }
81946 @@ -4038,8 +4320,8 @@ out:
81947 return ret;
81948 }
81949
81950 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81951 - void *buf, int len, int write)
81952 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81953 + void *buf, size_t len, int write)
81954 {
81955 resource_size_t phys_addr;
81956 unsigned long prot = 0;
81957 @@ -4064,8 +4346,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81958 * Access another process' address space as given in mm. If non-NULL, use the
81959 * given task for page fault accounting.
81960 */
81961 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81962 - unsigned long addr, void *buf, int len, int write)
81963 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81964 + unsigned long addr, void *buf, size_t len, int write)
81965 {
81966 struct vm_area_struct *vma;
81967 void *old_buf = buf;
81968 @@ -4073,7 +4355,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81969 down_read(&mm->mmap_sem);
81970 /* ignore errors, just check how much was successfully transferred */
81971 while (len) {
81972 - int bytes, ret, offset;
81973 + ssize_t bytes, ret, offset;
81974 void *maddr;
81975 struct page *page = NULL;
81976
81977 @@ -4132,8 +4414,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81978 *
81979 * The caller must hold a reference on @mm.
81980 */
81981 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81982 - void *buf, int len, int write)
81983 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81984 + void *buf, size_t len, int write)
81985 {
81986 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81987 }
81988 @@ -4143,11 +4425,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81989 * Source/target buffer must be kernel space,
81990 * Do not walk the page table directly, use get_user_pages
81991 */
81992 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81993 - void *buf, int len, int write)
81994 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81995 + void *buf, size_t len, int write)
81996 {
81997 struct mm_struct *mm;
81998 - int ret;
81999 + ssize_t ret;
82000
82001 mm = get_task_mm(tsk);
82002 if (!mm)
82003 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82004 index 3df6d12..a11056a 100644
82005 --- a/mm/mempolicy.c
82006 +++ b/mm/mempolicy.c
82007 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82008 unsigned long vmstart;
82009 unsigned long vmend;
82010
82011 +#ifdef CONFIG_PAX_SEGMEXEC
82012 + struct vm_area_struct *vma_m;
82013 +#endif
82014 +
82015 vma = find_vma(mm, start);
82016 if (!vma || vma->vm_start > start)
82017 return -EFAULT;
82018 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82019 if (err)
82020 goto out;
82021 }
82022 +
82023 err = vma_replace_policy(vma, new_pol);
82024 if (err)
82025 goto out;
82026 +
82027 +#ifdef CONFIG_PAX_SEGMEXEC
82028 + vma_m = pax_find_mirror_vma(vma);
82029 + if (vma_m) {
82030 + err = vma_replace_policy(vma_m, new_pol);
82031 + if (err)
82032 + goto out;
82033 + }
82034 +#endif
82035 +
82036 }
82037
82038 out:
82039 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82040
82041 if (end < start)
82042 return -EINVAL;
82043 +
82044 +#ifdef CONFIG_PAX_SEGMEXEC
82045 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82046 + if (end > SEGMEXEC_TASK_SIZE)
82047 + return -EINVAL;
82048 + } else
82049 +#endif
82050 +
82051 + if (end > TASK_SIZE)
82052 + return -EINVAL;
82053 +
82054 if (end == start)
82055 return 0;
82056
82057 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82058 */
82059 tcred = __task_cred(task);
82060 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82061 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82062 - !capable(CAP_SYS_NICE)) {
82063 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82064 rcu_read_unlock();
82065 err = -EPERM;
82066 goto out_put;
82067 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82068 goto out;
82069 }
82070
82071 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82072 + if (mm != current->mm &&
82073 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82074 + mmput(mm);
82075 + err = -EPERM;
82076 + goto out;
82077 + }
82078 +#endif
82079 +
82080 err = do_migrate_pages(mm, old, new,
82081 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82082
82083 diff --git a/mm/migrate.c b/mm/migrate.c
82084 index 2fd8b4a..d70358f 100644
82085 --- a/mm/migrate.c
82086 +++ b/mm/migrate.c
82087 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82088 */
82089 tcred = __task_cred(task);
82090 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82091 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82092 - !capable(CAP_SYS_NICE)) {
82093 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82094 rcu_read_unlock();
82095 err = -EPERM;
82096 goto out;
82097 diff --git a/mm/mlock.c b/mm/mlock.c
82098 index c9bd528..da8d069 100644
82099 --- a/mm/mlock.c
82100 +++ b/mm/mlock.c
82101 @@ -13,6 +13,7 @@
82102 #include <linux/pagemap.h>
82103 #include <linux/mempolicy.h>
82104 #include <linux/syscalls.h>
82105 +#include <linux/security.h>
82106 #include <linux/sched.h>
82107 #include <linux/export.h>
82108 #include <linux/rmap.h>
82109 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82110 {
82111 unsigned long nstart, end, tmp;
82112 struct vm_area_struct * vma, * prev;
82113 - int error;
82114 + int error = 0;
82115
82116 VM_BUG_ON(start & ~PAGE_MASK);
82117 VM_BUG_ON(len != PAGE_ALIGN(len));
82118 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82119 return -EINVAL;
82120 if (end == start)
82121 return 0;
82122 + if (end > TASK_SIZE)
82123 + return -EINVAL;
82124 +
82125 vma = find_vma(current->mm, start);
82126 if (!vma || vma->vm_start > start)
82127 return -ENOMEM;
82128 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82129 for (nstart = start ; ; ) {
82130 vm_flags_t newflags;
82131
82132 +#ifdef CONFIG_PAX_SEGMEXEC
82133 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82134 + break;
82135 +#endif
82136 +
82137 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82138
82139 newflags = vma->vm_flags | VM_LOCKED;
82140 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82141 lock_limit >>= PAGE_SHIFT;
82142
82143 /* check against resource limits */
82144 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82145 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82146 error = do_mlock(start, len, 1);
82147 up_write(&current->mm->mmap_sem);
82148 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82149 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82150 vm_flags_t newflags;
82151
82152 +#ifdef CONFIG_PAX_SEGMEXEC
82153 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82154 + break;
82155 +#endif
82156 +
82157 + BUG_ON(vma->vm_end > TASK_SIZE);
82158 newflags = vma->vm_flags | VM_LOCKED;
82159 if (!(flags & MCL_CURRENT))
82160 newflags &= ~VM_LOCKED;
82161 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82162 lock_limit >>= PAGE_SHIFT;
82163
82164 ret = -ENOMEM;
82165 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82166 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82167 capable(CAP_IPC_LOCK))
82168 ret = do_mlockall(flags);
82169 diff --git a/mm/mmap.c b/mm/mmap.c
82170 index 32f3372..254d5f3 100644
82171 --- a/mm/mmap.c
82172 +++ b/mm/mmap.c
82173 @@ -32,6 +32,7 @@
82174 #include <linux/khugepaged.h>
82175 #include <linux/uprobes.h>
82176 #include <linux/rbtree_augmented.h>
82177 +#include <linux/random.h>
82178
82179 #include <asm/uaccess.h>
82180 #include <asm/cacheflush.h>
82181 @@ -48,6 +49,16 @@
82182 #define arch_rebalance_pgtables(addr, len) (addr)
82183 #endif
82184
82185 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82186 +{
82187 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82188 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82189 + up_read(&mm->mmap_sem);
82190 + BUG();
82191 + }
82192 +#endif
82193 +}
82194 +
82195 static void unmap_region(struct mm_struct *mm,
82196 struct vm_area_struct *vma, struct vm_area_struct *prev,
82197 unsigned long start, unsigned long end);
82198 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82199 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82200 *
82201 */
82202 -pgprot_t protection_map[16] = {
82203 +pgprot_t protection_map[16] __read_only = {
82204 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82205 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82206 };
82207
82208 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82209 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82210 {
82211 - return __pgprot(pgprot_val(protection_map[vm_flags &
82212 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82213 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82214 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82215 +
82216 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82217 + if (!(__supported_pte_mask & _PAGE_NX) &&
82218 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82219 + (vm_flags & (VM_READ | VM_WRITE)))
82220 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82221 +#endif
82222 +
82223 + return prot;
82224 }
82225 EXPORT_SYMBOL(vm_get_page_prot);
82226
82227 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82228 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82229 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82230 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82231 /*
82232 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82233 * other variables. It can be updated by several CPUs frequently.
82234 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82235 struct vm_area_struct *next = vma->vm_next;
82236
82237 might_sleep();
82238 + BUG_ON(vma->vm_mirror);
82239 if (vma->vm_ops && vma->vm_ops->close)
82240 vma->vm_ops->close(vma);
82241 if (vma->vm_file)
82242 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82243 * not page aligned -Ram Gupta
82244 */
82245 rlim = rlimit(RLIMIT_DATA);
82246 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82247 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82248 (mm->end_data - mm->start_data) > rlim)
82249 goto out;
82250 @@ -888,6 +911,12 @@ static int
82251 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82252 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82253 {
82254 +
82255 +#ifdef CONFIG_PAX_SEGMEXEC
82256 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82257 + return 0;
82258 +#endif
82259 +
82260 if (is_mergeable_vma(vma, file, vm_flags) &&
82261 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82262 if (vma->vm_pgoff == vm_pgoff)
82263 @@ -907,6 +936,12 @@ static int
82264 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82265 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82266 {
82267 +
82268 +#ifdef CONFIG_PAX_SEGMEXEC
82269 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82270 + return 0;
82271 +#endif
82272 +
82273 if (is_mergeable_vma(vma, file, vm_flags) &&
82274 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82275 pgoff_t vm_pglen;
82276 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82277 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82278 struct vm_area_struct *prev, unsigned long addr,
82279 unsigned long end, unsigned long vm_flags,
82280 - struct anon_vma *anon_vma, struct file *file,
82281 + struct anon_vma *anon_vma, struct file *file,
82282 pgoff_t pgoff, struct mempolicy *policy)
82283 {
82284 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82285 struct vm_area_struct *area, *next;
82286 int err;
82287
82288 +#ifdef CONFIG_PAX_SEGMEXEC
82289 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82290 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82291 +
82292 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82293 +#endif
82294 +
82295 /*
82296 * We later require that vma->vm_flags == vm_flags,
82297 * so this tests vma->vm_flags & VM_SPECIAL, too.
82298 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82299 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82300 next = next->vm_next;
82301
82302 +#ifdef CONFIG_PAX_SEGMEXEC
82303 + if (prev)
82304 + prev_m = pax_find_mirror_vma(prev);
82305 + if (area)
82306 + area_m = pax_find_mirror_vma(area);
82307 + if (next)
82308 + next_m = pax_find_mirror_vma(next);
82309 +#endif
82310 +
82311 /*
82312 * Can it merge with the predecessor?
82313 */
82314 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82315 /* cases 1, 6 */
82316 err = vma_adjust(prev, prev->vm_start,
82317 next->vm_end, prev->vm_pgoff, NULL);
82318 - } else /* cases 2, 5, 7 */
82319 +
82320 +#ifdef CONFIG_PAX_SEGMEXEC
82321 + if (!err && prev_m)
82322 + err = vma_adjust(prev_m, prev_m->vm_start,
82323 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82324 +#endif
82325 +
82326 + } else { /* cases 2, 5, 7 */
82327 err = vma_adjust(prev, prev->vm_start,
82328 end, prev->vm_pgoff, NULL);
82329 +
82330 +#ifdef CONFIG_PAX_SEGMEXEC
82331 + if (!err && prev_m)
82332 + err = vma_adjust(prev_m, prev_m->vm_start,
82333 + end_m, prev_m->vm_pgoff, NULL);
82334 +#endif
82335 +
82336 + }
82337 if (err)
82338 return NULL;
82339 khugepaged_enter_vma_merge(prev);
82340 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82341 mpol_equal(policy, vma_policy(next)) &&
82342 can_vma_merge_before(next, vm_flags,
82343 anon_vma, file, pgoff+pglen)) {
82344 - if (prev && addr < prev->vm_end) /* case 4 */
82345 + if (prev && addr < prev->vm_end) { /* case 4 */
82346 err = vma_adjust(prev, prev->vm_start,
82347 addr, prev->vm_pgoff, NULL);
82348 - else /* cases 3, 8 */
82349 +
82350 +#ifdef CONFIG_PAX_SEGMEXEC
82351 + if (!err && prev_m)
82352 + err = vma_adjust(prev_m, prev_m->vm_start,
82353 + addr_m, prev_m->vm_pgoff, NULL);
82354 +#endif
82355 +
82356 + } else { /* cases 3, 8 */
82357 err = vma_adjust(area, addr, next->vm_end,
82358 next->vm_pgoff - pglen, NULL);
82359 +
82360 +#ifdef CONFIG_PAX_SEGMEXEC
82361 + if (!err && area_m)
82362 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82363 + next_m->vm_pgoff - pglen, NULL);
82364 +#endif
82365 +
82366 + }
82367 if (err)
82368 return NULL;
82369 khugepaged_enter_vma_merge(area);
82370 @@ -1120,8 +1201,10 @@ none:
82371 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82372 struct file *file, long pages)
82373 {
82374 - const unsigned long stack_flags
82375 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82376 +
82377 +#ifdef CONFIG_PAX_RANDMMAP
82378 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82379 +#endif
82380
82381 mm->total_vm += pages;
82382
82383 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82384 mm->shared_vm += pages;
82385 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82386 mm->exec_vm += pages;
82387 - } else if (flags & stack_flags)
82388 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82389 mm->stack_vm += pages;
82390 }
82391 #endif /* CONFIG_PROC_FS */
82392 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82393 * (the exception is when the underlying filesystem is noexec
82394 * mounted, in which case we dont add PROT_EXEC.)
82395 */
82396 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82397 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82398 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82399 prot |= PROT_EXEC;
82400
82401 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82402 /* Obtain the address to map to. we verify (or select) it and ensure
82403 * that it represents a valid section of the address space.
82404 */
82405 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82406 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82407 if (addr & ~PAGE_MASK)
82408 return addr;
82409
82410 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82411 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82412 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82413
82414 +#ifdef CONFIG_PAX_MPROTECT
82415 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82416 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82417 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82418 + gr_log_rwxmmap(file);
82419 +
82420 +#ifdef CONFIG_PAX_EMUPLT
82421 + vm_flags &= ~VM_EXEC;
82422 +#else
82423 + return -EPERM;
82424 +#endif
82425 +
82426 + }
82427 +
82428 + if (!(vm_flags & VM_EXEC))
82429 + vm_flags &= ~VM_MAYEXEC;
82430 +#else
82431 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82432 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82433 +#endif
82434 + else
82435 + vm_flags &= ~VM_MAYWRITE;
82436 + }
82437 +#endif
82438 +
82439 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82440 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82441 + vm_flags &= ~VM_PAGEEXEC;
82442 +#endif
82443 +
82444 if (flags & MAP_LOCKED)
82445 if (!can_do_mlock())
82446 return -EPERM;
82447 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82448 locked += mm->locked_vm;
82449 lock_limit = rlimit(RLIMIT_MEMLOCK);
82450 lock_limit >>= PAGE_SHIFT;
82451 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82452 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82453 return -EAGAIN;
82454 }
82455 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82456 }
82457 }
82458
82459 + if (!gr_acl_handle_mmap(file, prot))
82460 + return -EACCES;
82461 +
82462 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82463 }
82464
82465 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82466 vm_flags_t vm_flags = vma->vm_flags;
82467
82468 /* If it was private or non-writable, the write bit is already clear */
82469 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82470 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82471 return 0;
82472
82473 /* The backer wishes to know when pages are first written to? */
82474 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82475 unsigned long charged = 0;
82476 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82477
82478 +#ifdef CONFIG_PAX_SEGMEXEC
82479 + struct vm_area_struct *vma_m = NULL;
82480 +#endif
82481 +
82482 + /*
82483 + * mm->mmap_sem is required to protect against another thread
82484 + * changing the mappings in case we sleep.
82485 + */
82486 + verify_mm_writelocked(mm);
82487 +
82488 /* Clear old maps */
82489 error = -ENOMEM;
82490 -munmap_back:
82491 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82492 if (do_munmap(mm, addr, len))
82493 return -ENOMEM;
82494 - goto munmap_back;
82495 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82496 }
82497
82498 /* Check against address space limit. */
82499 +
82500 +#ifdef CONFIG_PAX_RANDMMAP
82501 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82502 +#endif
82503 +
82504 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82505 return -ENOMEM;
82506
82507 @@ -1460,6 +1591,16 @@ munmap_back:
82508 goto unacct_error;
82509 }
82510
82511 +#ifdef CONFIG_PAX_SEGMEXEC
82512 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82513 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82514 + if (!vma_m) {
82515 + error = -ENOMEM;
82516 + goto free_vma;
82517 + }
82518 + }
82519 +#endif
82520 +
82521 vma->vm_mm = mm;
82522 vma->vm_start = addr;
82523 vma->vm_end = addr + len;
82524 @@ -1484,6 +1625,13 @@ munmap_back:
82525 if (error)
82526 goto unmap_and_free_vma;
82527
82528 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82529 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82530 + vma->vm_flags |= VM_PAGEEXEC;
82531 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82532 + }
82533 +#endif
82534 +
82535 /* Can addr have changed??
82536 *
82537 * Answer: Yes, several device drivers can do it in their
82538 @@ -1522,6 +1670,11 @@ munmap_back:
82539 vma_link(mm, vma, prev, rb_link, rb_parent);
82540 file = vma->vm_file;
82541
82542 +#ifdef CONFIG_PAX_SEGMEXEC
82543 + if (vma_m)
82544 + BUG_ON(pax_mirror_vma(vma_m, vma));
82545 +#endif
82546 +
82547 /* Once vma denies write, undo our temporary denial count */
82548 if (correct_wcount)
82549 atomic_inc(&inode->i_writecount);
82550 @@ -1529,6 +1682,7 @@ out:
82551 perf_event_mmap(vma);
82552
82553 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82554 + track_exec_limit(mm, addr, addr + len, vm_flags);
82555 if (vm_flags & VM_LOCKED) {
82556 if (!mlock_vma_pages_range(vma, addr, addr + len))
82557 mm->locked_vm += (len >> PAGE_SHIFT);
82558 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82559 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82560 charged = 0;
82561 free_vma:
82562 +
82563 +#ifdef CONFIG_PAX_SEGMEXEC
82564 + if (vma_m)
82565 + kmem_cache_free(vm_area_cachep, vma_m);
82566 +#endif
82567 +
82568 kmem_cache_free(vm_area_cachep, vma);
82569 unacct_error:
82570 if (charged)
82571 @@ -1557,6 +1717,62 @@ unacct_error:
82572 return error;
82573 }
82574
82575 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82576 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82577 +{
82578 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82579 + return (random32() & 0xFF) << PAGE_SHIFT;
82580 +
82581 + return 0;
82582 +}
82583 +#endif
82584 +
82585 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82586 +{
82587 + if (!vma) {
82588 +#ifdef CONFIG_STACK_GROWSUP
82589 + if (addr > sysctl_heap_stack_gap)
82590 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82591 + else
82592 + vma = find_vma(current->mm, 0);
82593 + if (vma && (vma->vm_flags & VM_GROWSUP))
82594 + return false;
82595 +#endif
82596 + return true;
82597 + }
82598 +
82599 + if (addr + len > vma->vm_start)
82600 + return false;
82601 +
82602 + if (vma->vm_flags & VM_GROWSDOWN)
82603 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82604 +#ifdef CONFIG_STACK_GROWSUP
82605 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82606 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82607 +#endif
82608 + else if (offset)
82609 + return offset <= vma->vm_start - addr - len;
82610 +
82611 + return true;
82612 +}
82613 +
82614 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82615 +{
82616 + if (vma->vm_start < len)
82617 + return -ENOMEM;
82618 +
82619 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82620 + if (offset <= vma->vm_start - len)
82621 + return vma->vm_start - len - offset;
82622 + else
82623 + return -ENOMEM;
82624 + }
82625 +
82626 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82627 + return vma->vm_start - len - sysctl_heap_stack_gap;
82628 + return -ENOMEM;
82629 +}
82630 +
82631 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82632 {
82633 /*
82634 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82635 struct mm_struct *mm = current->mm;
82636 struct vm_area_struct *vma;
82637 struct vm_unmapped_area_info info;
82638 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82639
82640 if (len > TASK_SIZE)
82641 return -ENOMEM;
82642 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82643 if (flags & MAP_FIXED)
82644 return addr;
82645
82646 +#ifdef CONFIG_PAX_RANDMMAP
82647 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82648 +#endif
82649 +
82650 if (addr) {
82651 addr = PAGE_ALIGN(addr);
82652 vma = find_vma(mm, addr);
82653 - if (TASK_SIZE - len >= addr &&
82654 - (!vma || addr + len <= vma->vm_start))
82655 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82656 return addr;
82657 }
82658
82659 info.flags = 0;
82660 info.length = len;
82661 info.low_limit = TASK_UNMAPPED_BASE;
82662 +
82663 +#ifdef CONFIG_PAX_RANDMMAP
82664 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82665 + info.low_limit += mm->delta_mmap;
82666 +#endif
82667 +
82668 info.high_limit = TASK_SIZE;
82669 info.align_mask = 0;
82670 return vm_unmapped_area(&info);
82671 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82672
82673 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82674 {
82675 +
82676 +#ifdef CONFIG_PAX_SEGMEXEC
82677 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82678 + return;
82679 +#endif
82680 +
82681 /*
82682 * Is this a new hole at the lowest possible address?
82683 */
82684 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82685 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82686 mm->free_area_cache = addr;
82687 }
82688
82689 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82690 struct mm_struct *mm = current->mm;
82691 unsigned long addr = addr0;
82692 struct vm_unmapped_area_info info;
82693 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82694
82695 /* requested length too big for entire address space */
82696 if (len > TASK_SIZE)
82697 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82698 if (flags & MAP_FIXED)
82699 return addr;
82700
82701 +#ifdef CONFIG_PAX_RANDMMAP
82702 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82703 +#endif
82704 +
82705 /* requesting a specific address */
82706 if (addr) {
82707 addr = PAGE_ALIGN(addr);
82708 vma = find_vma(mm, addr);
82709 - if (TASK_SIZE - len >= addr &&
82710 - (!vma || addr + len <= vma->vm_start))
82711 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82712 return addr;
82713 }
82714
82715 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82716 VM_BUG_ON(addr != -ENOMEM);
82717 info.flags = 0;
82718 info.low_limit = TASK_UNMAPPED_BASE;
82719 +
82720 +#ifdef CONFIG_PAX_RANDMMAP
82721 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82722 + info.low_limit += mm->delta_mmap;
82723 +#endif
82724 +
82725 info.high_limit = TASK_SIZE;
82726 addr = vm_unmapped_area(&info);
82727 }
82728 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82729
82730 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82731 {
82732 +
82733 +#ifdef CONFIG_PAX_SEGMEXEC
82734 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82735 + return;
82736 +#endif
82737 +
82738 /*
82739 * Is this a new hole at the highest possible address?
82740 */
82741 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82742 mm->free_area_cache = addr;
82743
82744 /* dont allow allocations above current base */
82745 - if (mm->free_area_cache > mm->mmap_base)
82746 + if (mm->free_area_cache > mm->mmap_base) {
82747 mm->free_area_cache = mm->mmap_base;
82748 + mm->cached_hole_size = ~0UL;
82749 + }
82750 }
82751
82752 unsigned long
82753 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82754 return vma;
82755 }
82756
82757 +#ifdef CONFIG_PAX_SEGMEXEC
82758 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82759 +{
82760 + struct vm_area_struct *vma_m;
82761 +
82762 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82763 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82764 + BUG_ON(vma->vm_mirror);
82765 + return NULL;
82766 + }
82767 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82768 + vma_m = vma->vm_mirror;
82769 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82770 + BUG_ON(vma->vm_file != vma_m->vm_file);
82771 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82772 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82773 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82774 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82775 + return vma_m;
82776 +}
82777 +#endif
82778 +
82779 /*
82780 * Verify that the stack growth is acceptable and
82781 * update accounting. This is shared with both the
82782 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82783 return -ENOMEM;
82784
82785 /* Stack limit test */
82786 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82787 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82788 return -ENOMEM;
82789
82790 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82791 locked = mm->locked_vm + grow;
82792 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82793 limit >>= PAGE_SHIFT;
82794 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82795 if (locked > limit && !capable(CAP_IPC_LOCK))
82796 return -ENOMEM;
82797 }
82798 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82799 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82800 * vma is the last one with address > vma->vm_end. Have to extend vma.
82801 */
82802 +#ifndef CONFIG_IA64
82803 +static
82804 +#endif
82805 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82806 {
82807 int error;
82808 + bool locknext;
82809
82810 if (!(vma->vm_flags & VM_GROWSUP))
82811 return -EFAULT;
82812
82813 + /* Also guard against wrapping around to address 0. */
82814 + if (address < PAGE_ALIGN(address+1))
82815 + address = PAGE_ALIGN(address+1);
82816 + else
82817 + return -ENOMEM;
82818 +
82819 /*
82820 * We must make sure the anon_vma is allocated
82821 * so that the anon_vma locking is not a noop.
82822 */
82823 if (unlikely(anon_vma_prepare(vma)))
82824 return -ENOMEM;
82825 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82826 + if (locknext && anon_vma_prepare(vma->vm_next))
82827 + return -ENOMEM;
82828 vma_lock_anon_vma(vma);
82829 + if (locknext)
82830 + vma_lock_anon_vma(vma->vm_next);
82831
82832 /*
82833 * vma->vm_start/vm_end cannot change under us because the caller
82834 * is required to hold the mmap_sem in read mode. We need the
82835 - * anon_vma lock to serialize against concurrent expand_stacks.
82836 - * Also guard against wrapping around to address 0.
82837 + * anon_vma locks to serialize against concurrent expand_stacks
82838 + * and expand_upwards.
82839 */
82840 - if (address < PAGE_ALIGN(address+4))
82841 - address = PAGE_ALIGN(address+4);
82842 - else {
82843 - vma_unlock_anon_vma(vma);
82844 - return -ENOMEM;
82845 - }
82846 error = 0;
82847
82848 /* Somebody else might have raced and expanded it already */
82849 - if (address > vma->vm_end) {
82850 + 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)
82851 + error = -ENOMEM;
82852 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82853 unsigned long size, grow;
82854
82855 size = address - vma->vm_start;
82856 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82857 }
82858 }
82859 }
82860 + if (locknext)
82861 + vma_unlock_anon_vma(vma->vm_next);
82862 vma_unlock_anon_vma(vma);
82863 khugepaged_enter_vma_merge(vma);
82864 validate_mm(vma->vm_mm);
82865 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82866 unsigned long address)
82867 {
82868 int error;
82869 + bool lockprev = false;
82870 + struct vm_area_struct *prev;
82871
82872 /*
82873 * We must make sure the anon_vma is allocated
82874 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82875 if (error)
82876 return error;
82877
82878 + prev = vma->vm_prev;
82879 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82880 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82881 +#endif
82882 + if (lockprev && anon_vma_prepare(prev))
82883 + return -ENOMEM;
82884 + if (lockprev)
82885 + vma_lock_anon_vma(prev);
82886 +
82887 vma_lock_anon_vma(vma);
82888
82889 /*
82890 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82891 */
82892
82893 /* Somebody else might have raced and expanded it already */
82894 - if (address < vma->vm_start) {
82895 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82896 + error = -ENOMEM;
82897 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82898 unsigned long size, grow;
82899
82900 +#ifdef CONFIG_PAX_SEGMEXEC
82901 + struct vm_area_struct *vma_m;
82902 +
82903 + vma_m = pax_find_mirror_vma(vma);
82904 +#endif
82905 +
82906 size = vma->vm_end - address;
82907 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82908
82909 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82910 vma->vm_pgoff -= grow;
82911 anon_vma_interval_tree_post_update_vma(vma);
82912 vma_gap_update(vma);
82913 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82914 +
82915 +#ifdef CONFIG_PAX_SEGMEXEC
82916 + if (vma_m) {
82917 + anon_vma_interval_tree_pre_update_vma(vma_m);
82918 + vma_m->vm_start -= grow << PAGE_SHIFT;
82919 + vma_m->vm_pgoff -= grow;
82920 + anon_vma_interval_tree_post_update_vma(vma_m);
82921 + vma_gap_update(vma_m);
82922 + }
82923 +#endif
82924 +
82925 spin_unlock(&vma->vm_mm->page_table_lock);
82926
82927 perf_event_mmap(vma);
82928 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82929 do {
82930 long nrpages = vma_pages(vma);
82931
82932 +#ifdef CONFIG_PAX_SEGMEXEC
82933 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82934 + vma = remove_vma(vma);
82935 + continue;
82936 + }
82937 +#endif
82938 +
82939 if (vma->vm_flags & VM_ACCOUNT)
82940 nr_accounted += nrpages;
82941 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82942 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82943 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82944 vma->vm_prev = NULL;
82945 do {
82946 +
82947 +#ifdef CONFIG_PAX_SEGMEXEC
82948 + if (vma->vm_mirror) {
82949 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82950 + vma->vm_mirror->vm_mirror = NULL;
82951 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82952 + vma->vm_mirror = NULL;
82953 + }
82954 +#endif
82955 +
82956 vma_rb_erase(vma, &mm->mm_rb);
82957 mm->map_count--;
82958 tail_vma = vma;
82959 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82960 struct vm_area_struct *new;
82961 int err = -ENOMEM;
82962
82963 +#ifdef CONFIG_PAX_SEGMEXEC
82964 + struct vm_area_struct *vma_m, *new_m = NULL;
82965 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82966 +#endif
82967 +
82968 if (is_vm_hugetlb_page(vma) && (addr &
82969 ~(huge_page_mask(hstate_vma(vma)))))
82970 return -EINVAL;
82971
82972 +#ifdef CONFIG_PAX_SEGMEXEC
82973 + vma_m = pax_find_mirror_vma(vma);
82974 +#endif
82975 +
82976 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82977 if (!new)
82978 goto out_err;
82979
82980 +#ifdef CONFIG_PAX_SEGMEXEC
82981 + if (vma_m) {
82982 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82983 + if (!new_m) {
82984 + kmem_cache_free(vm_area_cachep, new);
82985 + goto out_err;
82986 + }
82987 + }
82988 +#endif
82989 +
82990 /* most fields are the same, copy all, and then fixup */
82991 *new = *vma;
82992
82993 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82994 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82995 }
82996
82997 +#ifdef CONFIG_PAX_SEGMEXEC
82998 + if (vma_m) {
82999 + *new_m = *vma_m;
83000 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83001 + new_m->vm_mirror = new;
83002 + new->vm_mirror = new_m;
83003 +
83004 + if (new_below)
83005 + new_m->vm_end = addr_m;
83006 + else {
83007 + new_m->vm_start = addr_m;
83008 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83009 + }
83010 + }
83011 +#endif
83012 +
83013 pol = mpol_dup(vma_policy(vma));
83014 if (IS_ERR(pol)) {
83015 err = PTR_ERR(pol);
83016 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83017 else
83018 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83019
83020 +#ifdef CONFIG_PAX_SEGMEXEC
83021 + if (!err && vma_m) {
83022 + if (anon_vma_clone(new_m, vma_m))
83023 + goto out_free_mpol;
83024 +
83025 + mpol_get(pol);
83026 + vma_set_policy(new_m, pol);
83027 +
83028 + if (new_m->vm_file)
83029 + get_file(new_m->vm_file);
83030 +
83031 + if (new_m->vm_ops && new_m->vm_ops->open)
83032 + new_m->vm_ops->open(new_m);
83033 +
83034 + if (new_below)
83035 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83036 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83037 + else
83038 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83039 +
83040 + if (err) {
83041 + if (new_m->vm_ops && new_m->vm_ops->close)
83042 + new_m->vm_ops->close(new_m);
83043 + if (new_m->vm_file)
83044 + fput(new_m->vm_file);
83045 + mpol_put(pol);
83046 + }
83047 + }
83048 +#endif
83049 +
83050 /* Success. */
83051 if (!err)
83052 return 0;
83053 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83054 new->vm_ops->close(new);
83055 if (new->vm_file)
83056 fput(new->vm_file);
83057 - unlink_anon_vmas(new);
83058 out_free_mpol:
83059 mpol_put(pol);
83060 out_free_vma:
83061 +
83062 +#ifdef CONFIG_PAX_SEGMEXEC
83063 + if (new_m) {
83064 + unlink_anon_vmas(new_m);
83065 + kmem_cache_free(vm_area_cachep, new_m);
83066 + }
83067 +#endif
83068 +
83069 + unlink_anon_vmas(new);
83070 kmem_cache_free(vm_area_cachep, new);
83071 out_err:
83072 return err;
83073 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83074 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83075 unsigned long addr, int new_below)
83076 {
83077 +
83078 +#ifdef CONFIG_PAX_SEGMEXEC
83079 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83080 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83081 + if (mm->map_count >= sysctl_max_map_count-1)
83082 + return -ENOMEM;
83083 + } else
83084 +#endif
83085 +
83086 if (mm->map_count >= sysctl_max_map_count)
83087 return -ENOMEM;
83088
83089 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83090 * work. This now handles partial unmappings.
83091 * Jeremy Fitzhardinge <jeremy@goop.org>
83092 */
83093 +#ifdef CONFIG_PAX_SEGMEXEC
83094 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83095 {
83096 + int ret = __do_munmap(mm, start, len);
83097 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83098 + return ret;
83099 +
83100 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83101 +}
83102 +
83103 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83104 +#else
83105 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83106 +#endif
83107 +{
83108 unsigned long end;
83109 struct vm_area_struct *vma, *prev, *last;
83110
83111 + /*
83112 + * mm->mmap_sem is required to protect against another thread
83113 + * changing the mappings in case we sleep.
83114 + */
83115 + verify_mm_writelocked(mm);
83116 +
83117 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83118 return -EINVAL;
83119
83120 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83121 /* Fix up all other VM information */
83122 remove_vma_list(mm, vma);
83123
83124 + track_exec_limit(mm, start, end, 0UL);
83125 +
83126 return 0;
83127 }
83128
83129 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83130 int ret;
83131 struct mm_struct *mm = current->mm;
83132
83133 +
83134 +#ifdef CONFIG_PAX_SEGMEXEC
83135 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83136 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83137 + return -EINVAL;
83138 +#endif
83139 +
83140 down_write(&mm->mmap_sem);
83141 ret = do_munmap(mm, start, len);
83142 up_write(&mm->mmap_sem);
83143 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83144 return vm_munmap(addr, len);
83145 }
83146
83147 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83148 -{
83149 -#ifdef CONFIG_DEBUG_VM
83150 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83151 - WARN_ON(1);
83152 - up_read(&mm->mmap_sem);
83153 - }
83154 -#endif
83155 -}
83156 -
83157 /*
83158 * this is really a simplified "do_mmap". it only handles
83159 * anonymous maps. eventually we may be able to do some
83160 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83161 struct rb_node ** rb_link, * rb_parent;
83162 pgoff_t pgoff = addr >> PAGE_SHIFT;
83163 int error;
83164 + unsigned long charged;
83165
83166 len = PAGE_ALIGN(len);
83167 if (!len)
83168 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83169
83170 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83171
83172 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83173 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83174 + flags &= ~VM_EXEC;
83175 +
83176 +#ifdef CONFIG_PAX_MPROTECT
83177 + if (mm->pax_flags & MF_PAX_MPROTECT)
83178 + flags &= ~VM_MAYEXEC;
83179 +#endif
83180 +
83181 + }
83182 +#endif
83183 +
83184 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83185 if (error & ~PAGE_MASK)
83186 return error;
83187
83188 + charged = len >> PAGE_SHIFT;
83189 +
83190 /*
83191 * mlock MCL_FUTURE?
83192 */
83193 if (mm->def_flags & VM_LOCKED) {
83194 unsigned long locked, lock_limit;
83195 - locked = len >> PAGE_SHIFT;
83196 + locked = charged;
83197 locked += mm->locked_vm;
83198 lock_limit = rlimit(RLIMIT_MEMLOCK);
83199 lock_limit >>= PAGE_SHIFT;
83200 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83201 /*
83202 * Clear old maps. this also does some error checking for us
83203 */
83204 - munmap_back:
83205 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83206 if (do_munmap(mm, addr, len))
83207 return -ENOMEM;
83208 - goto munmap_back;
83209 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83210 }
83211
83212 /* Check against address space limits *after* clearing old maps... */
83213 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83214 + if (!may_expand_vm(mm, charged))
83215 return -ENOMEM;
83216
83217 if (mm->map_count > sysctl_max_map_count)
83218 return -ENOMEM;
83219
83220 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83221 + if (security_vm_enough_memory_mm(mm, charged))
83222 return -ENOMEM;
83223
83224 /* Can we just expand an old private anonymous mapping? */
83225 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83226 */
83227 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83228 if (!vma) {
83229 - vm_unacct_memory(len >> PAGE_SHIFT);
83230 + vm_unacct_memory(charged);
83231 return -ENOMEM;
83232 }
83233
83234 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83235 vma_link(mm, vma, prev, rb_link, rb_parent);
83236 out:
83237 perf_event_mmap(vma);
83238 - mm->total_vm += len >> PAGE_SHIFT;
83239 + mm->total_vm += charged;
83240 if (flags & VM_LOCKED) {
83241 if (!mlock_vma_pages_range(vma, addr, addr + len))
83242 - mm->locked_vm += (len >> PAGE_SHIFT);
83243 + mm->locked_vm += charged;
83244 }
83245 + track_exec_limit(mm, addr, addr + len, flags);
83246 return addr;
83247 }
83248
83249 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83250 while (vma) {
83251 if (vma->vm_flags & VM_ACCOUNT)
83252 nr_accounted += vma_pages(vma);
83253 + vma->vm_mirror = NULL;
83254 vma = remove_vma(vma);
83255 }
83256 vm_unacct_memory(nr_accounted);
83257 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83258 struct vm_area_struct *prev;
83259 struct rb_node **rb_link, *rb_parent;
83260
83261 +#ifdef CONFIG_PAX_SEGMEXEC
83262 + struct vm_area_struct *vma_m = NULL;
83263 +#endif
83264 +
83265 + if (security_mmap_addr(vma->vm_start))
83266 + return -EPERM;
83267 +
83268 /*
83269 * The vm_pgoff of a purely anonymous vma should be irrelevant
83270 * until its first write fault, when page's anon_vma and index
83271 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83272 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83273 return -ENOMEM;
83274
83275 +#ifdef CONFIG_PAX_SEGMEXEC
83276 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83277 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83278 + if (!vma_m)
83279 + return -ENOMEM;
83280 + }
83281 +#endif
83282 +
83283 vma_link(mm, vma, prev, rb_link, rb_parent);
83284 +
83285 +#ifdef CONFIG_PAX_SEGMEXEC
83286 + if (vma_m)
83287 + BUG_ON(pax_mirror_vma(vma_m, vma));
83288 +#endif
83289 +
83290 return 0;
83291 }
83292
83293 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83294 struct mempolicy *pol;
83295 bool faulted_in_anon_vma = true;
83296
83297 + BUG_ON(vma->vm_mirror);
83298 +
83299 /*
83300 * If anonymous vma has not yet been faulted, update new pgoff
83301 * to match new location, to increase its chance of merging.
83302 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83303 return NULL;
83304 }
83305
83306 +#ifdef CONFIG_PAX_SEGMEXEC
83307 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83308 +{
83309 + struct vm_area_struct *prev_m;
83310 + struct rb_node **rb_link_m, *rb_parent_m;
83311 + struct mempolicy *pol_m;
83312 +
83313 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83314 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83315 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83316 + *vma_m = *vma;
83317 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83318 + if (anon_vma_clone(vma_m, vma))
83319 + return -ENOMEM;
83320 + pol_m = vma_policy(vma_m);
83321 + mpol_get(pol_m);
83322 + vma_set_policy(vma_m, pol_m);
83323 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83324 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83325 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83326 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83327 + if (vma_m->vm_file)
83328 + get_file(vma_m->vm_file);
83329 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83330 + vma_m->vm_ops->open(vma_m);
83331 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83332 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83333 + vma_m->vm_mirror = vma;
83334 + vma->vm_mirror = vma_m;
83335 + return 0;
83336 +}
83337 +#endif
83338 +
83339 /*
83340 * Return true if the calling process may expand its vm space by the passed
83341 * number of pages
83342 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83343
83344 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83345
83346 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83347 if (cur + npages > lim)
83348 return 0;
83349 return 1;
83350 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83351 vma->vm_start = addr;
83352 vma->vm_end = addr + len;
83353
83354 +#ifdef CONFIG_PAX_MPROTECT
83355 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83356 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83357 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83358 + return -EPERM;
83359 + if (!(vm_flags & VM_EXEC))
83360 + vm_flags &= ~VM_MAYEXEC;
83361 +#else
83362 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83363 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83364 +#endif
83365 + else
83366 + vm_flags &= ~VM_MAYWRITE;
83367 + }
83368 +#endif
83369 +
83370 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83371 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83372
83373 diff --git a/mm/mprotect.c b/mm/mprotect.c
83374 index 94722a4..9837984 100644
83375 --- a/mm/mprotect.c
83376 +++ b/mm/mprotect.c
83377 @@ -23,10 +23,17 @@
83378 #include <linux/mmu_notifier.h>
83379 #include <linux/migrate.h>
83380 #include <linux/perf_event.h>
83381 +
83382 +#ifdef CONFIG_PAX_MPROTECT
83383 +#include <linux/elf.h>
83384 +#include <linux/binfmts.h>
83385 +#endif
83386 +
83387 #include <asm/uaccess.h>
83388 #include <asm/pgtable.h>
83389 #include <asm/cacheflush.h>
83390 #include <asm/tlbflush.h>
83391 +#include <asm/mmu_context.h>
83392
83393 #ifndef pgprot_modify
83394 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83395 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83396 return pages;
83397 }
83398
83399 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83400 +/* called while holding the mmap semaphor for writing except stack expansion */
83401 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83402 +{
83403 + unsigned long oldlimit, newlimit = 0UL;
83404 +
83405 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83406 + return;
83407 +
83408 + spin_lock(&mm->page_table_lock);
83409 + oldlimit = mm->context.user_cs_limit;
83410 + if ((prot & VM_EXEC) && oldlimit < end)
83411 + /* USER_CS limit moved up */
83412 + newlimit = end;
83413 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83414 + /* USER_CS limit moved down */
83415 + newlimit = start;
83416 +
83417 + if (newlimit) {
83418 + mm->context.user_cs_limit = newlimit;
83419 +
83420 +#ifdef CONFIG_SMP
83421 + wmb();
83422 + cpus_clear(mm->context.cpu_user_cs_mask);
83423 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83424 +#endif
83425 +
83426 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83427 + }
83428 + spin_unlock(&mm->page_table_lock);
83429 + if (newlimit == end) {
83430 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83431 +
83432 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83433 + if (is_vm_hugetlb_page(vma))
83434 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83435 + else
83436 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83437 + }
83438 +}
83439 +#endif
83440 +
83441 int
83442 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83443 unsigned long start, unsigned long end, unsigned long newflags)
83444 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83445 int error;
83446 int dirty_accountable = 0;
83447
83448 +#ifdef CONFIG_PAX_SEGMEXEC
83449 + struct vm_area_struct *vma_m = NULL;
83450 + unsigned long start_m, end_m;
83451 +
83452 + start_m = start + SEGMEXEC_TASK_SIZE;
83453 + end_m = end + SEGMEXEC_TASK_SIZE;
83454 +#endif
83455 +
83456 if (newflags == oldflags) {
83457 *pprev = vma;
83458 return 0;
83459 }
83460
83461 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83462 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83463 +
83464 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83465 + return -ENOMEM;
83466 +
83467 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83468 + return -ENOMEM;
83469 + }
83470 +
83471 /*
83472 * If we make a private mapping writable we increase our commit;
83473 * but (without finer accounting) cannot reduce our commit if we
83474 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83475 }
83476 }
83477
83478 +#ifdef CONFIG_PAX_SEGMEXEC
83479 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83480 + if (start != vma->vm_start) {
83481 + error = split_vma(mm, vma, start, 1);
83482 + if (error)
83483 + goto fail;
83484 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83485 + *pprev = (*pprev)->vm_next;
83486 + }
83487 +
83488 + if (end != vma->vm_end) {
83489 + error = split_vma(mm, vma, end, 0);
83490 + if (error)
83491 + goto fail;
83492 + }
83493 +
83494 + if (pax_find_mirror_vma(vma)) {
83495 + error = __do_munmap(mm, start_m, end_m - start_m);
83496 + if (error)
83497 + goto fail;
83498 + } else {
83499 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83500 + if (!vma_m) {
83501 + error = -ENOMEM;
83502 + goto fail;
83503 + }
83504 + vma->vm_flags = newflags;
83505 + error = pax_mirror_vma(vma_m, vma);
83506 + if (error) {
83507 + vma->vm_flags = oldflags;
83508 + goto fail;
83509 + }
83510 + }
83511 + }
83512 +#endif
83513 +
83514 /*
83515 * First try to merge with previous and/or next vma.
83516 */
83517 @@ -296,9 +399,21 @@ success:
83518 * vm_flags and vm_page_prot are protected by the mmap_sem
83519 * held in write mode.
83520 */
83521 +
83522 +#ifdef CONFIG_PAX_SEGMEXEC
83523 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83524 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83525 +#endif
83526 +
83527 vma->vm_flags = newflags;
83528 +
83529 +#ifdef CONFIG_PAX_MPROTECT
83530 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83531 + mm->binfmt->handle_mprotect(vma, newflags);
83532 +#endif
83533 +
83534 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83535 - vm_get_page_prot(newflags));
83536 + vm_get_page_prot(vma->vm_flags));
83537
83538 if (vma_wants_writenotify(vma)) {
83539 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83540 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83541 end = start + len;
83542 if (end <= start)
83543 return -ENOMEM;
83544 +
83545 +#ifdef CONFIG_PAX_SEGMEXEC
83546 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83547 + if (end > SEGMEXEC_TASK_SIZE)
83548 + return -EINVAL;
83549 + } else
83550 +#endif
83551 +
83552 + if (end > TASK_SIZE)
83553 + return -EINVAL;
83554 +
83555 if (!arch_validate_prot(prot))
83556 return -EINVAL;
83557
83558 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83559 /*
83560 * Does the application expect PROT_READ to imply PROT_EXEC:
83561 */
83562 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83563 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83564 prot |= PROT_EXEC;
83565
83566 vm_flags = calc_vm_prot_bits(prot);
83567 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83568 if (start > vma->vm_start)
83569 prev = vma;
83570
83571 +#ifdef CONFIG_PAX_MPROTECT
83572 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83573 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83574 +#endif
83575 +
83576 for (nstart = start ; ; ) {
83577 unsigned long newflags;
83578
83579 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83580
83581 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83582 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83583 + if (prot & (PROT_WRITE | PROT_EXEC))
83584 + gr_log_rwxmprotect(vma->vm_file);
83585 +
83586 + error = -EACCES;
83587 + goto out;
83588 + }
83589 +
83590 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83591 error = -EACCES;
83592 goto out;
83593 }
83594 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83595 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83596 if (error)
83597 goto out;
83598 +
83599 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83600 +
83601 nstart = tmp;
83602
83603 if (nstart < prev->vm_end)
83604 diff --git a/mm/mremap.c b/mm/mremap.c
83605 index e1031e1..1f2a0a1 100644
83606 --- a/mm/mremap.c
83607 +++ b/mm/mremap.c
83608 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83609 continue;
83610 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83611 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83612 +
83613 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83614 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83615 + pte = pte_exprotect(pte);
83616 +#endif
83617 +
83618 set_pte_at(mm, new_addr, new_pte, pte);
83619 }
83620
83621 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83622 if (is_vm_hugetlb_page(vma))
83623 goto Einval;
83624
83625 +#ifdef CONFIG_PAX_SEGMEXEC
83626 + if (pax_find_mirror_vma(vma))
83627 + goto Einval;
83628 +#endif
83629 +
83630 /* We can't remap across vm area boundaries */
83631 if (old_len > vma->vm_end - addr)
83632 goto Efault;
83633 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83634 unsigned long ret = -EINVAL;
83635 unsigned long charged = 0;
83636 unsigned long map_flags;
83637 + unsigned long pax_task_size = TASK_SIZE;
83638
83639 if (new_addr & ~PAGE_MASK)
83640 goto out;
83641
83642 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83643 +#ifdef CONFIG_PAX_SEGMEXEC
83644 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83645 + pax_task_size = SEGMEXEC_TASK_SIZE;
83646 +#endif
83647 +
83648 + pax_task_size -= PAGE_SIZE;
83649 +
83650 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83651 goto out;
83652
83653 /* Check if the location we're moving into overlaps the
83654 * old location at all, and fail if it does.
83655 */
83656 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83657 - goto out;
83658 -
83659 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83660 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83661 goto out;
83662
83663 ret = do_munmap(mm, new_addr, new_len);
83664 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83665 struct vm_area_struct *vma;
83666 unsigned long ret = -EINVAL;
83667 unsigned long charged = 0;
83668 + unsigned long pax_task_size = TASK_SIZE;
83669
83670 down_write(&current->mm->mmap_sem);
83671
83672 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83673 if (!new_len)
83674 goto out;
83675
83676 +#ifdef CONFIG_PAX_SEGMEXEC
83677 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83678 + pax_task_size = SEGMEXEC_TASK_SIZE;
83679 +#endif
83680 +
83681 + pax_task_size -= PAGE_SIZE;
83682 +
83683 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83684 + old_len > pax_task_size || addr > pax_task_size-old_len)
83685 + goto out;
83686 +
83687 if (flags & MREMAP_FIXED) {
83688 if (flags & MREMAP_MAYMOVE)
83689 ret = mremap_to(addr, old_len, new_addr, new_len);
83690 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83691 addr + new_len);
83692 }
83693 ret = addr;
83694 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83695 goto out;
83696 }
83697 }
83698 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83699 goto out;
83700 }
83701
83702 + map_flags = vma->vm_flags;
83703 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83704 + if (!(ret & ~PAGE_MASK)) {
83705 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83706 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83707 + }
83708 }
83709 out:
83710 if (ret & ~PAGE_MASK)
83711 diff --git a/mm/nommu.c b/mm/nommu.c
83712 index bbe1f3f..b2601ea 100644
83713 --- a/mm/nommu.c
83714 +++ b/mm/nommu.c
83715 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83716 int sysctl_overcommit_ratio = 50; /* default is 50% */
83717 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83718 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83719 -int heap_stack_gap = 0;
83720
83721 atomic_long_t mmap_pages_allocated;
83722
83723 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83724 EXPORT_SYMBOL(find_vma);
83725
83726 /*
83727 - * find a VMA
83728 - * - we don't extend stack VMAs under NOMMU conditions
83729 - */
83730 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83731 -{
83732 - return find_vma(mm, addr);
83733 -}
83734 -
83735 -/*
83736 * expand a stack to a given address
83737 * - not supported under NOMMU conditions
83738 */
83739 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83740
83741 /* most fields are the same, copy all, and then fixup */
83742 *new = *vma;
83743 + INIT_LIST_HEAD(&new->anon_vma_chain);
83744 *region = *vma->vm_region;
83745 new->vm_region = region;
83746
83747 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83748 }
83749 EXPORT_SYMBOL(generic_file_remap_pages);
83750
83751 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83752 - unsigned long addr, void *buf, int len, int write)
83753 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83754 + unsigned long addr, void *buf, size_t len, int write)
83755 {
83756 struct vm_area_struct *vma;
83757
83758 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83759 *
83760 * The caller must hold a reference on @mm.
83761 */
83762 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83763 - void *buf, int len, int write)
83764 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83765 + void *buf, size_t len, int write)
83766 {
83767 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83768 }
83769 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83770 * Access another process' address space.
83771 * - source/target buffer must be kernel space
83772 */
83773 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83774 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83775 {
83776 struct mm_struct *mm;
83777
83778 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83779 index 0713bfb..b95bb87 100644
83780 --- a/mm/page-writeback.c
83781 +++ b/mm/page-writeback.c
83782 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83783 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83784 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83785 */
83786 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83787 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83788 unsigned long thresh,
83789 unsigned long bg_thresh,
83790 unsigned long dirty,
83791 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83792 }
83793 }
83794
83795 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83796 +static struct notifier_block ratelimit_nb = {
83797 .notifier_call = ratelimit_handler,
83798 .next = NULL,
83799 };
83800 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83801 index 6a83cd3..4cc7b16 100644
83802 --- a/mm/page_alloc.c
83803 +++ b/mm/page_alloc.c
83804 @@ -58,6 +58,7 @@
83805 #include <linux/prefetch.h>
83806 #include <linux/migrate.h>
83807 #include <linux/page-debug-flags.h>
83808 +#include <linux/random.h>
83809
83810 #include <asm/tlbflush.h>
83811 #include <asm/div64.h>
83812 @@ -338,7 +339,7 @@ out:
83813 * This usage means that zero-order pages may not be compound.
83814 */
83815
83816 -static void free_compound_page(struct page *page)
83817 +void free_compound_page(struct page *page)
83818 {
83819 __free_pages_ok(page, compound_order(page));
83820 }
83821 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83822 int i;
83823 int bad = 0;
83824
83825 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83826 + unsigned long index = 1UL << order;
83827 +#endif
83828 +
83829 trace_mm_page_free(page, order);
83830 kmemcheck_free_shadow(page, order);
83831
83832 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83833 debug_check_no_obj_freed(page_address(page),
83834 PAGE_SIZE << order);
83835 }
83836 +
83837 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83838 + for (; index; --index)
83839 + sanitize_highpage(page + index - 1);
83840 +#endif
83841 +
83842 arch_free_page(page, order);
83843 kernel_map_pages(page, 1 << order, 0);
83844
83845 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83846 local_irq_restore(flags);
83847 }
83848
83849 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83850 +bool __meminitdata extra_latent_entropy;
83851 +
83852 +static int __init setup_pax_extra_latent_entropy(char *str)
83853 +{
83854 + extra_latent_entropy = true;
83855 + return 0;
83856 +}
83857 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83858 +
83859 +volatile u64 latent_entropy;
83860 +#endif
83861 +
83862 /*
83863 * Read access to zone->managed_pages is safe because it's unsigned long,
83864 * but we still need to serialize writers. Currently all callers of
83865 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83866 set_page_count(p, 0);
83867 }
83868
83869 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83870 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83871 + u64 hash = 0;
83872 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83873 + const u64 *data = lowmem_page_address(page);
83874 +
83875 + for (index = 0; index < end; index++)
83876 + hash ^= hash + data[index];
83877 + latent_entropy ^= hash;
83878 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83879 + }
83880 +#endif
83881 +
83882 page_zone(page)->managed_pages += 1 << order;
83883 set_page_refcounted(page);
83884 __free_pages(page, order);
83885 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83886 arch_alloc_page(page, order);
83887 kernel_map_pages(page, 1 << order, 1);
83888
83889 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83890 if (gfp_flags & __GFP_ZERO)
83891 prep_zero_page(page, order, gfp_flags);
83892 +#endif
83893
83894 if (order && (gfp_flags & __GFP_COMP))
83895 prep_compound_page(page, order);
83896 diff --git a/mm/percpu.c b/mm/percpu.c
83897 index 8c8e08f..73a5cda 100644
83898 --- a/mm/percpu.c
83899 +++ b/mm/percpu.c
83900 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83901 static unsigned int pcpu_high_unit_cpu __read_mostly;
83902
83903 /* the address of the first chunk which starts with the kernel static area */
83904 -void *pcpu_base_addr __read_mostly;
83905 +void *pcpu_base_addr __read_only;
83906 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83907
83908 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83909 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83910 index fd26d04..0cea1b0 100644
83911 --- a/mm/process_vm_access.c
83912 +++ b/mm/process_vm_access.c
83913 @@ -13,6 +13,7 @@
83914 #include <linux/uio.h>
83915 #include <linux/sched.h>
83916 #include <linux/highmem.h>
83917 +#include <linux/security.h>
83918 #include <linux/ptrace.h>
83919 #include <linux/slab.h>
83920 #include <linux/syscalls.h>
83921 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83922 size_t iov_l_curr_offset = 0;
83923 ssize_t iov_len;
83924
83925 + return -ENOSYS; // PaX: until properly audited
83926 +
83927 /*
83928 * Work out how many pages of struct pages we're going to need
83929 * when eventually calling get_user_pages
83930 */
83931 for (i = 0; i < riovcnt; i++) {
83932 iov_len = rvec[i].iov_len;
83933 - if (iov_len > 0) {
83934 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83935 - + iov_len)
83936 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83937 - / PAGE_SIZE + 1;
83938 - nr_pages = max(nr_pages, nr_pages_iov);
83939 - }
83940 + if (iov_len <= 0)
83941 + continue;
83942 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83943 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83944 + nr_pages = max(nr_pages, nr_pages_iov);
83945 }
83946
83947 if (nr_pages == 0)
83948 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83949 goto free_proc_pages;
83950 }
83951
83952 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83953 + rc = -EPERM;
83954 + goto put_task_struct;
83955 + }
83956 +
83957 mm = mm_access(task, PTRACE_MODE_ATTACH);
83958 if (!mm || IS_ERR(mm)) {
83959 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83960 diff --git a/mm/rmap.c b/mm/rmap.c
83961 index 2c78f8c..9e9c624 100644
83962 --- a/mm/rmap.c
83963 +++ b/mm/rmap.c
83964 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83965 struct anon_vma *anon_vma = vma->anon_vma;
83966 struct anon_vma_chain *avc;
83967
83968 +#ifdef CONFIG_PAX_SEGMEXEC
83969 + struct anon_vma_chain *avc_m = NULL;
83970 +#endif
83971 +
83972 might_sleep();
83973 if (unlikely(!anon_vma)) {
83974 struct mm_struct *mm = vma->vm_mm;
83975 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83976 if (!avc)
83977 goto out_enomem;
83978
83979 +#ifdef CONFIG_PAX_SEGMEXEC
83980 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83981 + if (!avc_m)
83982 + goto out_enomem_free_avc;
83983 +#endif
83984 +
83985 anon_vma = find_mergeable_anon_vma(vma);
83986 allocated = NULL;
83987 if (!anon_vma) {
83988 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83989 /* page_table_lock to protect against threads */
83990 spin_lock(&mm->page_table_lock);
83991 if (likely(!vma->anon_vma)) {
83992 +
83993 +#ifdef CONFIG_PAX_SEGMEXEC
83994 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83995 +
83996 + if (vma_m) {
83997 + BUG_ON(vma_m->anon_vma);
83998 + vma_m->anon_vma = anon_vma;
83999 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84000 + avc_m = NULL;
84001 + }
84002 +#endif
84003 +
84004 vma->anon_vma = anon_vma;
84005 anon_vma_chain_link(vma, avc, anon_vma);
84006 allocated = NULL;
84007 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84008
84009 if (unlikely(allocated))
84010 put_anon_vma(allocated);
84011 +
84012 +#ifdef CONFIG_PAX_SEGMEXEC
84013 + if (unlikely(avc_m))
84014 + anon_vma_chain_free(avc_m);
84015 +#endif
84016 +
84017 if (unlikely(avc))
84018 anon_vma_chain_free(avc);
84019 }
84020 return 0;
84021
84022 out_enomem_free_avc:
84023 +
84024 +#ifdef CONFIG_PAX_SEGMEXEC
84025 + if (avc_m)
84026 + anon_vma_chain_free(avc_m);
84027 +#endif
84028 +
84029 anon_vma_chain_free(avc);
84030 out_enomem:
84031 return -ENOMEM;
84032 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84033 * Attach the anon_vmas from src to dst.
84034 * Returns 0 on success, -ENOMEM on failure.
84035 */
84036 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84037 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84038 {
84039 struct anon_vma_chain *avc, *pavc;
84040 struct anon_vma *root = NULL;
84041 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84042 * the corresponding VMA in the parent process is attached to.
84043 * Returns 0 on success, non-zero on failure.
84044 */
84045 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84046 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84047 {
84048 struct anon_vma_chain *avc;
84049 struct anon_vma *anon_vma;
84050 diff --git a/mm/shmem.c b/mm/shmem.c
84051 index efd0b3a..994b702 100644
84052 --- a/mm/shmem.c
84053 +++ b/mm/shmem.c
84054 @@ -31,7 +31,7 @@
84055 #include <linux/export.h>
84056 #include <linux/swap.h>
84057
84058 -static struct vfsmount *shm_mnt;
84059 +struct vfsmount *shm_mnt;
84060
84061 #ifdef CONFIG_SHMEM
84062 /*
84063 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
84064 #define BOGO_DIRENT_SIZE 20
84065
84066 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84067 -#define SHORT_SYMLINK_LEN 128
84068 +#define SHORT_SYMLINK_LEN 64
84069
84070 /*
84071 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84072 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84073 static int shmem_xattr_validate(const char *name)
84074 {
84075 struct { const char *prefix; size_t len; } arr[] = {
84076 +
84077 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84078 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84079 +#endif
84080 +
84081 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84082 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84083 };
84084 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84085 if (err)
84086 return err;
84087
84088 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84089 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84090 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84091 + return -EOPNOTSUPP;
84092 + if (size > 8)
84093 + return -EINVAL;
84094 + }
84095 +#endif
84096 +
84097 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84098 }
84099
84100 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84101 int err = -ENOMEM;
84102
84103 /* Round up to L1_CACHE_BYTES to resist false sharing */
84104 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84105 - L1_CACHE_BYTES), GFP_KERNEL);
84106 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84107 if (!sbinfo)
84108 return -ENOMEM;
84109
84110 diff --git a/mm/slab.c b/mm/slab.c
84111 index e7667a3..a48e73b 100644
84112 --- a/mm/slab.c
84113 +++ b/mm/slab.c
84114 @@ -306,7 +306,7 @@ struct kmem_list3 {
84115 * Need this for bootstrapping a per node allocator.
84116 */
84117 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84118 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84119 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84120 #define CACHE_CACHE 0
84121 #define SIZE_AC MAX_NUMNODES
84122 #define SIZE_L3 (2 * MAX_NUMNODES)
84123 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84124 if ((x)->max_freeable < i) \
84125 (x)->max_freeable = i; \
84126 } while (0)
84127 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84128 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84129 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84130 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84131 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84132 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84133 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84134 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84135 #else
84136 #define STATS_INC_ACTIVE(x) do { } while (0)
84137 #define STATS_DEC_ACTIVE(x) do { } while (0)
84138 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84139 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84140 */
84141 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84142 - const struct slab *slab, void *obj)
84143 + const struct slab *slab, const void *obj)
84144 {
84145 u32 offset = (obj - slab->s_mem);
84146 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84147 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84148 struct cache_names {
84149 char *name;
84150 char *name_dma;
84151 + char *name_usercopy;
84152 };
84153
84154 static struct cache_names __initdata cache_names[] = {
84155 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84156 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84157 #include <linux/kmalloc_sizes.h>
84158 - {NULL,}
84159 + {NULL}
84160 #undef CACHE
84161 };
84162
84163 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84164 if (unlikely(gfpflags & GFP_DMA))
84165 return csizep->cs_dmacachep;
84166 #endif
84167 +
84168 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84169 + if (unlikely(gfpflags & GFP_USERCOPY))
84170 + return csizep->cs_usercopycachep;
84171 +#endif
84172 +
84173 return csizep->cs_cachep;
84174 }
84175
84176 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84177 return notifier_from_errno(err);
84178 }
84179
84180 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84181 +static struct notifier_block cpucache_notifier = {
84182 &cpuup_callback, NULL, 0
84183 };
84184
84185 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84186 */
84187
84188 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84189 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84190 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84191
84192 if (INDEX_AC != INDEX_L3)
84193 sizes[INDEX_L3].cs_cachep =
84194 create_kmalloc_cache(names[INDEX_L3].name,
84195 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84196 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84197
84198 slab_early_init = 0;
84199
84200 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84201 */
84202 if (!sizes->cs_cachep)
84203 sizes->cs_cachep = create_kmalloc_cache(names->name,
84204 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84205 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84206
84207 #ifdef CONFIG_ZONE_DMA
84208 sizes->cs_dmacachep = create_kmalloc_cache(
84209 names->name_dma, sizes->cs_size,
84210 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84211 #endif
84212 +
84213 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84214 + sizes->cs_usercopycachep = create_kmalloc_cache(
84215 + names->name_usercopy, sizes->cs_size,
84216 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84217 +#endif
84218 +
84219 sizes++;
84220 names++;
84221 }
84222 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84223
84224 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84225 return;
84226 + VM_BUG_ON(!virt_addr_valid(objp));
84227 local_irq_save(flags);
84228 kfree_debugcheck(objp);
84229 c = virt_to_cache(objp);
84230 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84231 }
84232 /* cpu stats */
84233 {
84234 - unsigned long allochit = atomic_read(&cachep->allochit);
84235 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84236 - unsigned long freehit = atomic_read(&cachep->freehit);
84237 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84238 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84239 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84240 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84241 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84242
84243 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84244 allochit, allocmiss, freehit, freemiss);
84245 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84246 static int __init slab_proc_init(void)
84247 {
84248 #ifdef CONFIG_DEBUG_SLAB_LEAK
84249 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84250 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84251 #endif
84252 return 0;
84253 }
84254 module_init(slab_proc_init);
84255 #endif
84256
84257 +bool is_usercopy_object(const void *ptr)
84258 +{
84259 + struct page *page;
84260 + struct kmem_cache *cachep;
84261 +
84262 + if (ZERO_OR_NULL_PTR(ptr))
84263 + return false;
84264 +
84265 + if (!slab_is_available())
84266 + return false;
84267 +
84268 + if (!virt_addr_valid(ptr))
84269 + return false;
84270 +
84271 + page = virt_to_head_page(ptr);
84272 +
84273 + if (!PageSlab(page))
84274 + return false;
84275 +
84276 + cachep = page->slab_cache;
84277 + return cachep->flags & SLAB_USERCOPY;
84278 +}
84279 +
84280 +#ifdef CONFIG_PAX_USERCOPY
84281 +const char *check_heap_object(const void *ptr, unsigned long n)
84282 +{
84283 + struct page *page;
84284 + struct kmem_cache *cachep;
84285 + struct slab *slabp;
84286 + unsigned int objnr;
84287 + unsigned long offset;
84288 +
84289 + if (ZERO_OR_NULL_PTR(ptr))
84290 + return "<null>";
84291 +
84292 + if (!virt_addr_valid(ptr))
84293 + return NULL;
84294 +
84295 + page = virt_to_head_page(ptr);
84296 +
84297 + if (!PageSlab(page))
84298 + return NULL;
84299 +
84300 + cachep = page->slab_cache;
84301 + if (!(cachep->flags & SLAB_USERCOPY))
84302 + return cachep->name;
84303 +
84304 + slabp = page->slab_page;
84305 + objnr = obj_to_index(cachep, slabp, ptr);
84306 + BUG_ON(objnr >= cachep->num);
84307 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84308 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84309 + return NULL;
84310 +
84311 + return cachep->name;
84312 +}
84313 +#endif
84314 +
84315 /**
84316 * ksize - get the actual amount of memory allocated for a given object
84317 * @objp: Pointer to the object
84318 diff --git a/mm/slab.h b/mm/slab.h
84319 index 34a98d6..73633d1 100644
84320 --- a/mm/slab.h
84321 +++ b/mm/slab.h
84322 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84323
84324 /* Legal flag mask for kmem_cache_create(), for various configurations */
84325 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84326 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84327 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84328
84329 #if defined(CONFIG_DEBUG_SLAB)
84330 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84331 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84332 return s;
84333
84334 page = virt_to_head_page(x);
84335 +
84336 + BUG_ON(!PageSlab(page));
84337 +
84338 cachep = page->slab_cache;
84339 if (slab_equal_or_root(cachep, s))
84340 return cachep;
84341 diff --git a/mm/slab_common.c b/mm/slab_common.c
84342 index 3f3cd97..93b0236 100644
84343 --- a/mm/slab_common.c
84344 +++ b/mm/slab_common.c
84345 @@ -22,7 +22,7 @@
84346
84347 #include "slab.h"
84348
84349 -enum slab_state slab_state;
84350 +enum slab_state slab_state __read_only;
84351 LIST_HEAD(slab_caches);
84352 DEFINE_MUTEX(slab_mutex);
84353 struct kmem_cache *kmem_cache;
84354 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84355
84356 err = __kmem_cache_create(s, flags);
84357 if (!err) {
84358 - s->refcount = 1;
84359 + atomic_set(&s->refcount, 1);
84360 list_add(&s->list, &slab_caches);
84361 memcg_cache_list_add(memcg, s);
84362 } else {
84363 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84364
84365 get_online_cpus();
84366 mutex_lock(&slab_mutex);
84367 - s->refcount--;
84368 - if (!s->refcount) {
84369 + if (atomic_dec_and_test(&s->refcount)) {
84370 list_del(&s->list);
84371
84372 if (!__kmem_cache_shutdown(s)) {
84373 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84374 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84375 name, size, err);
84376
84377 - s->refcount = -1; /* Exempt from merging for now */
84378 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84379 }
84380
84381 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84382 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84383
84384 create_boot_cache(s, name, size, flags);
84385 list_add(&s->list, &slab_caches);
84386 - s->refcount = 1;
84387 + atomic_set(&s->refcount, 1);
84388 return s;
84389 }
84390
84391 diff --git a/mm/slob.c b/mm/slob.c
84392 index a99fdf7..6ee34ec 100644
84393 --- a/mm/slob.c
84394 +++ b/mm/slob.c
84395 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84396 /*
84397 * Return the size of a slob block.
84398 */
84399 -static slobidx_t slob_units(slob_t *s)
84400 +static slobidx_t slob_units(const slob_t *s)
84401 {
84402 if (s->units > 0)
84403 return s->units;
84404 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84405 /*
84406 * Return the next free slob block pointer after this one.
84407 */
84408 -static slob_t *slob_next(slob_t *s)
84409 +static slob_t *slob_next(const slob_t *s)
84410 {
84411 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84412 slobidx_t next;
84413 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84414 /*
84415 * Returns true if s is the last free block in its page.
84416 */
84417 -static int slob_last(slob_t *s)
84418 +static int slob_last(const slob_t *s)
84419 {
84420 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84421 }
84422
84423 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84424 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84425 {
84426 - void *page;
84427 + struct page *page;
84428
84429 #ifdef CONFIG_NUMA
84430 if (node != NUMA_NO_NODE)
84431 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84432 if (!page)
84433 return NULL;
84434
84435 - return page_address(page);
84436 + __SetPageSlab(page);
84437 + return page;
84438 }
84439
84440 -static void slob_free_pages(void *b, int order)
84441 +static void slob_free_pages(struct page *sp, int order)
84442 {
84443 if (current->reclaim_state)
84444 current->reclaim_state->reclaimed_slab += 1 << order;
84445 - free_pages((unsigned long)b, order);
84446 + __ClearPageSlab(sp);
84447 + reset_page_mapcount(sp);
84448 + sp->private = 0;
84449 + __free_pages(sp, order);
84450 }
84451
84452 /*
84453 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84454
84455 /* Not enough space: must allocate a new page */
84456 if (!b) {
84457 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84458 - if (!b)
84459 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84460 + if (!sp)
84461 return NULL;
84462 - sp = virt_to_page(b);
84463 - __SetPageSlab(sp);
84464 + b = page_address(sp);
84465
84466 spin_lock_irqsave(&slob_lock, flags);
84467 sp->units = SLOB_UNITS(PAGE_SIZE);
84468 sp->freelist = b;
84469 + sp->private = 0;
84470 INIT_LIST_HEAD(&sp->list);
84471 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84472 set_slob_page_free(sp, slob_list);
84473 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84474 if (slob_page_free(sp))
84475 clear_slob_page_free(sp);
84476 spin_unlock_irqrestore(&slob_lock, flags);
84477 - __ClearPageSlab(sp);
84478 - reset_page_mapcount(sp);
84479 - slob_free_pages(b, 0);
84480 + slob_free_pages(sp, 0);
84481 return;
84482 }
84483
84484 @@ -424,11 +426,10 @@ out:
84485 */
84486
84487 static __always_inline void *
84488 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84489 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84490 {
84491 - unsigned int *m;
84492 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84493 - void *ret;
84494 + slob_t *m;
84495 + void *ret = NULL;
84496
84497 gfp &= gfp_allowed_mask;
84498
84499 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84500
84501 if (!m)
84502 return NULL;
84503 - *m = size;
84504 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84505 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84506 + m[0].units = size;
84507 + m[1].units = align;
84508 ret = (void *)m + align;
84509
84510 trace_kmalloc_node(caller, ret,
84511 size, size + align, gfp, node);
84512 } else {
84513 unsigned int order = get_order(size);
84514 + struct page *page;
84515
84516 if (likely(order))
84517 gfp |= __GFP_COMP;
84518 - ret = slob_new_pages(gfp, order, node);
84519 + page = slob_new_pages(gfp, order, node);
84520 + if (page) {
84521 + ret = page_address(page);
84522 + page->private = size;
84523 + }
84524
84525 trace_kmalloc_node(caller, ret,
84526 size, PAGE_SIZE << order, gfp, node);
84527 }
84528
84529 - kmemleak_alloc(ret, size, 1, gfp);
84530 + return ret;
84531 +}
84532 +
84533 +static __always_inline void *
84534 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84535 +{
84536 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84537 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84538 +
84539 + if (!ZERO_OR_NULL_PTR(ret))
84540 + kmemleak_alloc(ret, size, 1, gfp);
84541 return ret;
84542 }
84543
84544 @@ -493,34 +512,112 @@ void kfree(const void *block)
84545 return;
84546 kmemleak_free(block);
84547
84548 + VM_BUG_ON(!virt_addr_valid(block));
84549 sp = virt_to_page(block);
84550 - if (PageSlab(sp)) {
84551 + VM_BUG_ON(!PageSlab(sp));
84552 + if (!sp->private) {
84553 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84554 - unsigned int *m = (unsigned int *)(block - align);
84555 - slob_free(m, *m + align);
84556 - } else
84557 + slob_t *m = (slob_t *)(block - align);
84558 + slob_free(m, m[0].units + align);
84559 + } else {
84560 + __ClearPageSlab(sp);
84561 + reset_page_mapcount(sp);
84562 + sp->private = 0;
84563 __free_pages(sp, compound_order(sp));
84564 + }
84565 }
84566 EXPORT_SYMBOL(kfree);
84567
84568 +bool is_usercopy_object(const void *ptr)
84569 +{
84570 + if (!slab_is_available())
84571 + return false;
84572 +
84573 + // PAX: TODO
84574 +
84575 + return false;
84576 +}
84577 +
84578 +#ifdef CONFIG_PAX_USERCOPY
84579 +const char *check_heap_object(const void *ptr, unsigned long n)
84580 +{
84581 + struct page *page;
84582 + const slob_t *free;
84583 + const void *base;
84584 + unsigned long flags;
84585 +
84586 + if (ZERO_OR_NULL_PTR(ptr))
84587 + return "<null>";
84588 +
84589 + if (!virt_addr_valid(ptr))
84590 + return NULL;
84591 +
84592 + page = virt_to_head_page(ptr);
84593 + if (!PageSlab(page))
84594 + return NULL;
84595 +
84596 + if (page->private) {
84597 + base = page;
84598 + if (base <= ptr && n <= page->private - (ptr - base))
84599 + return NULL;
84600 + return "<slob>";
84601 + }
84602 +
84603 + /* some tricky double walking to find the chunk */
84604 + spin_lock_irqsave(&slob_lock, flags);
84605 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84606 + free = page->freelist;
84607 +
84608 + while (!slob_last(free) && (void *)free <= ptr) {
84609 + base = free + slob_units(free);
84610 + free = slob_next(free);
84611 + }
84612 +
84613 + while (base < (void *)free) {
84614 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84615 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84616 + int offset;
84617 +
84618 + if (ptr < base + align)
84619 + break;
84620 +
84621 + offset = ptr - base - align;
84622 + if (offset >= m) {
84623 + base += size;
84624 + continue;
84625 + }
84626 +
84627 + if (n > m - offset)
84628 + break;
84629 +
84630 + spin_unlock_irqrestore(&slob_lock, flags);
84631 + return NULL;
84632 + }
84633 +
84634 + spin_unlock_irqrestore(&slob_lock, flags);
84635 + return "<slob>";
84636 +}
84637 +#endif
84638 +
84639 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84640 size_t ksize(const void *block)
84641 {
84642 struct page *sp;
84643 int align;
84644 - unsigned int *m;
84645 + slob_t *m;
84646
84647 BUG_ON(!block);
84648 if (unlikely(block == ZERO_SIZE_PTR))
84649 return 0;
84650
84651 sp = virt_to_page(block);
84652 - if (unlikely(!PageSlab(sp)))
84653 - return PAGE_SIZE << compound_order(sp);
84654 + VM_BUG_ON(!PageSlab(sp));
84655 + if (sp->private)
84656 + return sp->private;
84657
84658 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84659 - m = (unsigned int *)(block - align);
84660 - return SLOB_UNITS(*m) * SLOB_UNIT;
84661 + m = (slob_t *)(block - align);
84662 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84663 }
84664 EXPORT_SYMBOL(ksize);
84665
84666 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84667
84668 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84669 {
84670 - void *b;
84671 + void *b = NULL;
84672
84673 flags &= gfp_allowed_mask;
84674
84675 lockdep_trace_alloc(flags);
84676
84677 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84678 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84679 +#else
84680 if (c->size < PAGE_SIZE) {
84681 b = slob_alloc(c->size, flags, c->align, node);
84682 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84683 SLOB_UNITS(c->size) * SLOB_UNIT,
84684 flags, node);
84685 } else {
84686 - b = slob_new_pages(flags, get_order(c->size), node);
84687 + struct page *sp;
84688 +
84689 + sp = slob_new_pages(flags, get_order(c->size), node);
84690 + if (sp) {
84691 + b = page_address(sp);
84692 + sp->private = c->size;
84693 + }
84694 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84695 PAGE_SIZE << get_order(c->size),
84696 flags, node);
84697 }
84698 +#endif
84699
84700 if (c->ctor)
84701 c->ctor(b);
84702 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84703
84704 static void __kmem_cache_free(void *b, int size)
84705 {
84706 - if (size < PAGE_SIZE)
84707 + struct page *sp;
84708 +
84709 + sp = virt_to_page(b);
84710 + BUG_ON(!PageSlab(sp));
84711 + if (!sp->private)
84712 slob_free(b, size);
84713 else
84714 - slob_free_pages(b, get_order(size));
84715 + slob_free_pages(sp, get_order(size));
84716 }
84717
84718 static void kmem_rcu_free(struct rcu_head *head)
84719 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84720
84721 void kmem_cache_free(struct kmem_cache *c, void *b)
84722 {
84723 + int size = c->size;
84724 +
84725 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84726 + if (size + c->align < PAGE_SIZE) {
84727 + size += c->align;
84728 + b -= c->align;
84729 + }
84730 +#endif
84731 +
84732 kmemleak_free_recursive(b, c->flags);
84733 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84734 struct slob_rcu *slob_rcu;
84735 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84736 - slob_rcu->size = c->size;
84737 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84738 + slob_rcu->size = size;
84739 call_rcu(&slob_rcu->head, kmem_rcu_free);
84740 } else {
84741 - __kmem_cache_free(b, c->size);
84742 + __kmem_cache_free(b, size);
84743 }
84744
84745 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84746 + trace_kfree(_RET_IP_, b);
84747 +#else
84748 trace_kmem_cache_free(_RET_IP_, b);
84749 +#endif
84750 +
84751 }
84752 EXPORT_SYMBOL(kmem_cache_free);
84753
84754 diff --git a/mm/slub.c b/mm/slub.c
84755 index ba2ca53..991c4f7 100644
84756 --- a/mm/slub.c
84757 +++ b/mm/slub.c
84758 @@ -197,7 +197,7 @@ struct track {
84759
84760 enum track_item { TRACK_ALLOC, TRACK_FREE };
84761
84762 -#ifdef CONFIG_SYSFS
84763 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84764 static int sysfs_slab_add(struct kmem_cache *);
84765 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84766 static void sysfs_slab_remove(struct kmem_cache *);
84767 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84768 if (!t->addr)
84769 return;
84770
84771 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84772 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84773 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84774 #ifdef CONFIG_STACKTRACE
84775 {
84776 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84777 * Merge control. If this is set then no merging of slab caches will occur.
84778 * (Could be removed. This was introduced to pacify the merge skeptics.)
84779 */
84780 -static int slub_nomerge;
84781 +static int slub_nomerge = 1;
84782
84783 /*
84784 * Calculate the order of allocation given an slab object size.
84785 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84786 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84787 #endif
84788
84789 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84790 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84791 +#endif
84792 +
84793 static int __init setup_slub_min_order(char *str)
84794 {
84795 get_option(&str, &slub_min_order);
84796 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84797 return kmalloc_dma_caches[index];
84798
84799 #endif
84800 +
84801 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84802 + if (flags & SLAB_USERCOPY)
84803 + return kmalloc_usercopy_caches[index];
84804 +
84805 +#endif
84806 +
84807 return kmalloc_caches[index];
84808 }
84809
84810 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84811 EXPORT_SYMBOL(__kmalloc_node);
84812 #endif
84813
84814 +bool is_usercopy_object(const void *ptr)
84815 +{
84816 + struct page *page;
84817 + struct kmem_cache *s;
84818 +
84819 + if (ZERO_OR_NULL_PTR(ptr))
84820 + return false;
84821 +
84822 + if (!slab_is_available())
84823 + return false;
84824 +
84825 + if (!virt_addr_valid(ptr))
84826 + return false;
84827 +
84828 + page = virt_to_head_page(ptr);
84829 +
84830 + if (!PageSlab(page))
84831 + return false;
84832 +
84833 + s = page->slab_cache;
84834 + return s->flags & SLAB_USERCOPY;
84835 +}
84836 +
84837 +#ifdef CONFIG_PAX_USERCOPY
84838 +const char *check_heap_object(const void *ptr, unsigned long n)
84839 +{
84840 + struct page *page;
84841 + struct kmem_cache *s;
84842 + unsigned long offset;
84843 +
84844 + if (ZERO_OR_NULL_PTR(ptr))
84845 + return "<null>";
84846 +
84847 + if (!virt_addr_valid(ptr))
84848 + return NULL;
84849 +
84850 + page = virt_to_head_page(ptr);
84851 +
84852 + if (!PageSlab(page))
84853 + return NULL;
84854 +
84855 + s = page->slab_cache;
84856 + if (!(s->flags & SLAB_USERCOPY))
84857 + return s->name;
84858 +
84859 + offset = (ptr - page_address(page)) % s->size;
84860 + if (offset <= s->object_size && n <= s->object_size - offset)
84861 + return NULL;
84862 +
84863 + return s->name;
84864 +}
84865 +#endif
84866 +
84867 size_t ksize(const void *object)
84868 {
84869 struct page *page;
84870 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84871 if (unlikely(ZERO_OR_NULL_PTR(x)))
84872 return;
84873
84874 + VM_BUG_ON(!virt_addr_valid(x));
84875 page = virt_to_head_page(x);
84876 if (unlikely(!PageSlab(page))) {
84877 BUG_ON(!PageCompound(page));
84878 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84879
84880 /* Caches that are not of the two-to-the-power-of size */
84881 if (KMALLOC_MIN_SIZE <= 32) {
84882 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84883 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84884 caches++;
84885 }
84886
84887 if (KMALLOC_MIN_SIZE <= 64) {
84888 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84889 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84890 caches++;
84891 }
84892
84893 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84894 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84895 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84896 caches++;
84897 }
84898
84899 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84900 }
84901 }
84902 #endif
84903 +
84904 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84905 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84906 + struct kmem_cache *s = kmalloc_caches[i];
84907 +
84908 + if (s && s->size) {
84909 + char *name = kasprintf(GFP_NOWAIT,
84910 + "usercopy-kmalloc-%d", s->object_size);
84911 +
84912 + BUG_ON(!name);
84913 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84914 + s->object_size, SLAB_USERCOPY);
84915 + }
84916 + }
84917 +#endif
84918 +
84919 printk(KERN_INFO
84920 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84921 " CPUs=%d, Nodes=%d\n",
84922 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84923 /*
84924 * We may have set a slab to be unmergeable during bootstrap.
84925 */
84926 - if (s->refcount < 0)
84927 + if (atomic_read(&s->refcount) < 0)
84928 return 1;
84929
84930 return 0;
84931 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84932
84933 s = find_mergeable(memcg, size, align, flags, name, ctor);
84934 if (s) {
84935 - s->refcount++;
84936 + atomic_inc(&s->refcount);
84937 /*
84938 * Adjust the object sizes so that we clear
84939 * the complete object on kzalloc.
84940 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84941 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84942
84943 if (sysfs_slab_alias(s, name)) {
84944 - s->refcount--;
84945 + atomic_dec(&s->refcount);
84946 s = NULL;
84947 }
84948 }
84949 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84950 return NOTIFY_OK;
84951 }
84952
84953 -static struct notifier_block __cpuinitdata slab_notifier = {
84954 +static struct notifier_block slab_notifier = {
84955 .notifier_call = slab_cpuup_callback
84956 };
84957
84958 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84959 }
84960 #endif
84961
84962 -#ifdef CONFIG_SYSFS
84963 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84964 static int count_inuse(struct page *page)
84965 {
84966 return page->inuse;
84967 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84968 validate_slab_cache(kmalloc_caches[9]);
84969 }
84970 #else
84971 -#ifdef CONFIG_SYSFS
84972 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84973 static void resiliency_test(void) {};
84974 #endif
84975 #endif
84976
84977 -#ifdef CONFIG_SYSFS
84978 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84979 enum slab_stat_type {
84980 SL_ALL, /* All slabs */
84981 SL_PARTIAL, /* Only partially allocated slabs */
84982 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84983
84984 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84985 {
84986 - return sprintf(buf, "%d\n", s->refcount - 1);
84987 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84988 }
84989 SLAB_ATTR_RO(aliases);
84990
84991 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84992 return name;
84993 }
84994
84995 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84996 static int sysfs_slab_add(struct kmem_cache *s)
84997 {
84998 int err;
84999 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85000 kobject_del(&s->kobj);
85001 kobject_put(&s->kobj);
85002 }
85003 +#endif
85004
85005 /*
85006 * Need to buffer aliases during bootup until sysfs becomes
85007 @@ -5336,6 +5419,7 @@ struct saved_alias {
85008
85009 static struct saved_alias *alias_list;
85010
85011 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85012 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85013 {
85014 struct saved_alias *al;
85015 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85016 alias_list = al;
85017 return 0;
85018 }
85019 +#endif
85020
85021 static int __init slab_sysfs_init(void)
85022 {
85023 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85024 index 1b7e22a..3fcd4f3 100644
85025 --- a/mm/sparse-vmemmap.c
85026 +++ b/mm/sparse-vmemmap.c
85027 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85028 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85029 if (!p)
85030 return NULL;
85031 - pud_populate(&init_mm, pud, p);
85032 + pud_populate_kernel(&init_mm, pud, p);
85033 }
85034 return pud;
85035 }
85036 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85037 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85038 if (!p)
85039 return NULL;
85040 - pgd_populate(&init_mm, pgd, p);
85041 + pgd_populate_kernel(&init_mm, pgd, p);
85042 }
85043 return pgd;
85044 }
85045 diff --git a/mm/sparse.c b/mm/sparse.c
85046 index 6b5fb76..db0c190 100644
85047 --- a/mm/sparse.c
85048 +++ b/mm/sparse.c
85049 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85050
85051 for (i = 0; i < PAGES_PER_SECTION; i++) {
85052 if (PageHWPoison(&memmap[i])) {
85053 - atomic_long_sub(1, &mce_bad_pages);
85054 + atomic_long_sub_unchecked(1, &mce_bad_pages);
85055 ClearPageHWPoison(&memmap[i]);
85056 }
85057 }
85058 diff --git a/mm/swap.c b/mm/swap.c
85059 index 6310dc2..3662b3f 100644
85060 --- a/mm/swap.c
85061 +++ b/mm/swap.c
85062 @@ -30,6 +30,7 @@
85063 #include <linux/backing-dev.h>
85064 #include <linux/memcontrol.h>
85065 #include <linux/gfp.h>
85066 +#include <linux/hugetlb.h>
85067
85068 #include "internal.h"
85069
85070 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
85071
85072 __page_cache_release(page);
85073 dtor = get_compound_page_dtor(page);
85074 + if (!PageHuge(page))
85075 + BUG_ON(dtor != free_compound_page);
85076 (*dtor)(page);
85077 }
85078
85079 diff --git a/mm/swapfile.c b/mm/swapfile.c
85080 index e97a0e5..b50e796 100644
85081 --- a/mm/swapfile.c
85082 +++ b/mm/swapfile.c
85083 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
85084
85085 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85086 /* Activity counter to indicate that a swapon or swapoff has occurred */
85087 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85088 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85089
85090 static inline unsigned char swap_count(unsigned char ent)
85091 {
85092 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85093 }
85094 filp_close(swap_file, NULL);
85095 err = 0;
85096 - atomic_inc(&proc_poll_event);
85097 + atomic_inc_unchecked(&proc_poll_event);
85098 wake_up_interruptible(&proc_poll_wait);
85099
85100 out_dput:
85101 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85102
85103 poll_wait(file, &proc_poll_wait, wait);
85104
85105 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85106 - seq->poll_event = atomic_read(&proc_poll_event);
85107 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85108 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85109 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85110 }
85111
85112 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85113 return ret;
85114
85115 seq = file->private_data;
85116 - seq->poll_event = atomic_read(&proc_poll_event);
85117 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85118 return 0;
85119 }
85120
85121 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85122 (frontswap_map) ? "FS" : "");
85123
85124 mutex_unlock(&swapon_mutex);
85125 - atomic_inc(&proc_poll_event);
85126 + atomic_inc_unchecked(&proc_poll_event);
85127 wake_up_interruptible(&proc_poll_wait);
85128
85129 if (S_ISREG(inode->i_mode))
85130 diff --git a/mm/util.c b/mm/util.c
85131 index c55e26b..3f913a9 100644
85132 --- a/mm/util.c
85133 +++ b/mm/util.c
85134 @@ -292,6 +292,12 @@ done:
85135 void arch_pick_mmap_layout(struct mm_struct *mm)
85136 {
85137 mm->mmap_base = TASK_UNMAPPED_BASE;
85138 +
85139 +#ifdef CONFIG_PAX_RANDMMAP
85140 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85141 + mm->mmap_base += mm->delta_mmap;
85142 +#endif
85143 +
85144 mm->get_unmapped_area = arch_get_unmapped_area;
85145 mm->unmap_area = arch_unmap_area;
85146 }
85147 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85148 index 5123a16..f234a48 100644
85149 --- a/mm/vmalloc.c
85150 +++ b/mm/vmalloc.c
85151 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85152
85153 pte = pte_offset_kernel(pmd, addr);
85154 do {
85155 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85156 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85157 +
85158 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85159 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85160 + BUG_ON(!pte_exec(*pte));
85161 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85162 + continue;
85163 + }
85164 +#endif
85165 +
85166 + {
85167 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85168 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85169 + }
85170 } while (pte++, addr += PAGE_SIZE, addr != end);
85171 }
85172
85173 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85174 pte = pte_alloc_kernel(pmd, addr);
85175 if (!pte)
85176 return -ENOMEM;
85177 +
85178 + pax_open_kernel();
85179 do {
85180 struct page *page = pages[*nr];
85181
85182 - if (WARN_ON(!pte_none(*pte)))
85183 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85184 + if (pgprot_val(prot) & _PAGE_NX)
85185 +#endif
85186 +
85187 + if (!pte_none(*pte)) {
85188 + pax_close_kernel();
85189 + WARN_ON(1);
85190 return -EBUSY;
85191 - if (WARN_ON(!page))
85192 + }
85193 + if (!page) {
85194 + pax_close_kernel();
85195 + WARN_ON(1);
85196 return -ENOMEM;
85197 + }
85198 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85199 (*nr)++;
85200 } while (pte++, addr += PAGE_SIZE, addr != end);
85201 + pax_close_kernel();
85202 return 0;
85203 }
85204
85205 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85206 pmd_t *pmd;
85207 unsigned long next;
85208
85209 - pmd = pmd_alloc(&init_mm, pud, addr);
85210 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85211 if (!pmd)
85212 return -ENOMEM;
85213 do {
85214 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85215 pud_t *pud;
85216 unsigned long next;
85217
85218 - pud = pud_alloc(&init_mm, pgd, addr);
85219 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85220 if (!pud)
85221 return -ENOMEM;
85222 do {
85223 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85224 * and fall back on vmalloc() if that fails. Others
85225 * just put it in the vmalloc space.
85226 */
85227 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85228 +#ifdef CONFIG_MODULES
85229 +#ifdef MODULES_VADDR
85230 unsigned long addr = (unsigned long)x;
85231 if (addr >= MODULES_VADDR && addr < MODULES_END)
85232 return 1;
85233 #endif
85234 +
85235 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85236 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85237 + return 1;
85238 +#endif
85239 +
85240 +#endif
85241 +
85242 return is_vmalloc_addr(x);
85243 }
85244
85245 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85246
85247 if (!pgd_none(*pgd)) {
85248 pud_t *pud = pud_offset(pgd, addr);
85249 +#ifdef CONFIG_X86
85250 + if (!pud_large(*pud))
85251 +#endif
85252 if (!pud_none(*pud)) {
85253 pmd_t *pmd = pmd_offset(pud, addr);
85254 +#ifdef CONFIG_X86
85255 + if (!pmd_large(*pmd))
85256 +#endif
85257 if (!pmd_none(*pmd)) {
85258 pte_t *ptep, pte;
85259
85260 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85261 * Allocate a region of KVA of the specified size and alignment, within the
85262 * vstart and vend.
85263 */
85264 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85265 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85266 unsigned long align,
85267 unsigned long vstart, unsigned long vend,
85268 int node, gfp_t gfp_mask)
85269 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85270 struct vm_struct *area;
85271
85272 BUG_ON(in_interrupt());
85273 +
85274 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85275 + if (flags & VM_KERNEXEC) {
85276 + if (start != VMALLOC_START || end != VMALLOC_END)
85277 + return NULL;
85278 + start = (unsigned long)MODULES_EXEC_VADDR;
85279 + end = (unsigned long)MODULES_EXEC_END;
85280 + }
85281 +#endif
85282 +
85283 if (flags & VM_IOREMAP) {
85284 int bit = fls(size);
85285
85286 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85287 if (count > totalram_pages)
85288 return NULL;
85289
85290 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85291 + if (!(pgprot_val(prot) & _PAGE_NX))
85292 + flags |= VM_KERNEXEC;
85293 +#endif
85294 +
85295 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85296 __builtin_return_address(0));
85297 if (!area)
85298 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85299 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85300 goto fail;
85301
85302 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85303 + if (!(pgprot_val(prot) & _PAGE_NX))
85304 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85305 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85306 + else
85307 +#endif
85308 +
85309 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85310 start, end, node, gfp_mask, caller);
85311 if (!area)
85312 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85313 * For tight control over page level allocator and protection flags
85314 * use __vmalloc() instead.
85315 */
85316 -
85317 void *vmalloc_exec(unsigned long size)
85318 {
85319 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85320 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85321 -1, __builtin_return_address(0));
85322 }
85323
85324 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85325 unsigned long uaddr = vma->vm_start;
85326 unsigned long usize = vma->vm_end - vma->vm_start;
85327
85328 + BUG_ON(vma->vm_mirror);
85329 +
85330 if ((PAGE_SIZE-1) & (unsigned long)addr)
85331 return -EINVAL;
85332
85333 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85334 v->addr, v->addr + v->size, v->size);
85335
85336 if (v->caller)
85337 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85338 + seq_printf(m, " %pK", v->caller);
85339 +#else
85340 seq_printf(m, " %pS", v->caller);
85341 +#endif
85342
85343 if (v->nr_pages)
85344 seq_printf(m, " pages=%d", v->nr_pages);
85345 diff --git a/mm/vmstat.c b/mm/vmstat.c
85346 index 9800306..76b4b27 100644
85347 --- a/mm/vmstat.c
85348 +++ b/mm/vmstat.c
85349 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85350 *
85351 * vm_stat contains the global counters
85352 */
85353 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85354 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85355 EXPORT_SYMBOL(vm_stat);
85356
85357 #ifdef CONFIG_SMP
85358 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85359 v = p->vm_stat_diff[i];
85360 p->vm_stat_diff[i] = 0;
85361 local_irq_restore(flags);
85362 - atomic_long_add(v, &zone->vm_stat[i]);
85363 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85364 global_diff[i] += v;
85365 #ifdef CONFIG_NUMA
85366 /* 3 seconds idle till flush */
85367 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85368
85369 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85370 if (global_diff[i])
85371 - atomic_long_add(global_diff[i], &vm_stat[i]);
85372 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85373 }
85374
85375 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85376 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85377 if (pset->vm_stat_diff[i]) {
85378 int v = pset->vm_stat_diff[i];
85379 pset->vm_stat_diff[i] = 0;
85380 - atomic_long_add(v, &zone->vm_stat[i]);
85381 - atomic_long_add(v, &vm_stat[i]);
85382 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85383 + atomic_long_add_unchecked(v, &vm_stat[i]);
85384 }
85385 }
85386 #endif
85387 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85388 return NOTIFY_OK;
85389 }
85390
85391 -static struct notifier_block __cpuinitdata vmstat_notifier =
85392 +static struct notifier_block vmstat_notifier =
85393 { &vmstat_cpuup_callback, NULL, 0 };
85394 #endif
85395
85396 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85397 start_cpu_timer(cpu);
85398 #endif
85399 #ifdef CONFIG_PROC_FS
85400 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85401 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85402 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85403 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85404 + {
85405 + mode_t gr_mode = S_IRUGO;
85406 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85407 + gr_mode = S_IRUSR;
85408 +#endif
85409 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85410 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85411 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85412 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85413 +#else
85414 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85415 +#endif
85416 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85417 + }
85418 #endif
85419 return 0;
85420 }
85421 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85422 index acc74ad..be02639 100644
85423 --- a/net/8021q/vlan.c
85424 +++ b/net/8021q/vlan.c
85425 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85426 if (vlan_id)
85427 vlan_vid_del(real_dev, vlan_id);
85428
85429 + /* Take it out of our own structures, but be sure to interlock with
85430 + * HW accelerating devices or SW vlan input packet processing if
85431 + * VLAN is not 0 (leave it there for 802.1p).
85432 + */
85433 + if (vlan_id)
85434 + vlan_vid_del(real_dev, vlan_id);
85435 +
85436 /* Get rid of the vlan's reference to real_dev */
85437 dev_put(real_dev);
85438 }
85439 @@ -485,7 +492,7 @@ out:
85440 return NOTIFY_DONE;
85441 }
85442
85443 -static struct notifier_block vlan_notifier_block __read_mostly = {
85444 +static struct notifier_block vlan_notifier_block = {
85445 .notifier_call = vlan_device_event,
85446 };
85447
85448 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85449 err = -EPERM;
85450 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85451 break;
85452 - if ((args.u.name_type >= 0) &&
85453 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85454 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85455 struct vlan_net *vn;
85456
85457 vn = net_generic(net, vlan_net_id);
85458 diff --git a/net/9p/mod.c b/net/9p/mod.c
85459 index 6ab36ae..6f1841b 100644
85460 --- a/net/9p/mod.c
85461 +++ b/net/9p/mod.c
85462 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85463 void v9fs_register_trans(struct p9_trans_module *m)
85464 {
85465 spin_lock(&v9fs_trans_lock);
85466 - list_add_tail(&m->list, &v9fs_trans_list);
85467 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85468 spin_unlock(&v9fs_trans_lock);
85469 }
85470 EXPORT_SYMBOL(v9fs_register_trans);
85471 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85472 void v9fs_unregister_trans(struct p9_trans_module *m)
85473 {
85474 spin_lock(&v9fs_trans_lock);
85475 - list_del_init(&m->list);
85476 + pax_list_del_init((struct list_head *)&m->list);
85477 spin_unlock(&v9fs_trans_lock);
85478 }
85479 EXPORT_SYMBOL(v9fs_unregister_trans);
85480 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85481 index 02efb25..41541a9 100644
85482 --- a/net/9p/trans_fd.c
85483 +++ b/net/9p/trans_fd.c
85484 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85485 oldfs = get_fs();
85486 set_fs(get_ds());
85487 /* The cast to a user pointer is valid due to the set_fs() */
85488 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85489 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85490 set_fs(oldfs);
85491
85492 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85493 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85494 index 876fbe8..8bbea9f 100644
85495 --- a/net/atm/atm_misc.c
85496 +++ b/net/atm/atm_misc.c
85497 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85498 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85499 return 1;
85500 atm_return(vcc, truesize);
85501 - atomic_inc(&vcc->stats->rx_drop);
85502 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85503 return 0;
85504 }
85505 EXPORT_SYMBOL(atm_charge);
85506 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85507 }
85508 }
85509 atm_return(vcc, guess);
85510 - atomic_inc(&vcc->stats->rx_drop);
85511 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85512 return NULL;
85513 }
85514 EXPORT_SYMBOL(atm_alloc_charge);
85515 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85516
85517 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85518 {
85519 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85520 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85521 __SONET_ITEMS
85522 #undef __HANDLE_ITEM
85523 }
85524 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85525
85526 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85527 {
85528 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85529 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85530 __SONET_ITEMS
85531 #undef __HANDLE_ITEM
85532 }
85533 diff --git a/net/atm/lec.h b/net/atm/lec.h
85534 index a86aff9..3a0d6f6 100644
85535 --- a/net/atm/lec.h
85536 +++ b/net/atm/lec.h
85537 @@ -48,7 +48,7 @@ struct lane2_ops {
85538 const u8 *tlvs, u32 sizeoftlvs);
85539 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85540 const u8 *tlvs, u32 sizeoftlvs);
85541 -};
85542 +} __no_const;
85543
85544 /*
85545 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85546 diff --git a/net/atm/proc.c b/net/atm/proc.c
85547 index 0d020de..011c7bb 100644
85548 --- a/net/atm/proc.c
85549 +++ b/net/atm/proc.c
85550 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85551 const struct k_atm_aal_stats *stats)
85552 {
85553 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85554 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85555 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85556 - atomic_read(&stats->rx_drop));
85557 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85558 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85559 + atomic_read_unchecked(&stats->rx_drop));
85560 }
85561
85562 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85563 diff --git a/net/atm/resources.c b/net/atm/resources.c
85564 index 0447d5d..3cf4728 100644
85565 --- a/net/atm/resources.c
85566 +++ b/net/atm/resources.c
85567 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85568 static void copy_aal_stats(struct k_atm_aal_stats *from,
85569 struct atm_aal_stats *to)
85570 {
85571 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85572 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85573 __AAL_STAT_ITEMS
85574 #undef __HANDLE_ITEM
85575 }
85576 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85577 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85578 struct atm_aal_stats *to)
85579 {
85580 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85581 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85582 __AAL_STAT_ITEMS
85583 #undef __HANDLE_ITEM
85584 }
85585 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85586 index d5744b7..506bae3 100644
85587 --- a/net/ax25/sysctl_net_ax25.c
85588 +++ b/net/ax25/sysctl_net_ax25.c
85589 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85590 {
85591 char path[sizeof("net/ax25/") + IFNAMSIZ];
85592 int k;
85593 - struct ctl_table *table;
85594 + ctl_table_no_const *table;
85595
85596 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85597 if (!table)
85598 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85599 index 1ee94d0..14beea2 100644
85600 --- a/net/batman-adv/bat_iv_ogm.c
85601 +++ b/net/batman-adv/bat_iv_ogm.c
85602 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85603
85604 /* randomize initial seqno to avoid collision */
85605 get_random_bytes(&random_seqno, sizeof(random_seqno));
85606 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85607 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85608
85609 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85610 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85611 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85612 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85613
85614 /* change sequence number to network order */
85615 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85616 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85617 batadv_ogm_packet->seqno = htonl(seqno);
85618 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85619 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85620
85621 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85622 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85623 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85624 return;
85625
85626 /* could be changed by schedule_own_packet() */
85627 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85628 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85629
85630 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85631 has_directlink_flag = 1;
85632 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85633 index f1d37cd..4190879 100644
85634 --- a/net/batman-adv/hard-interface.c
85635 +++ b/net/batman-adv/hard-interface.c
85636 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85637 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85638 dev_add_pack(&hard_iface->batman_adv_ptype);
85639
85640 - atomic_set(&hard_iface->frag_seqno, 1);
85641 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85642 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85643 hard_iface->net_dev->name);
85644
85645 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85646 /* This can't be called via a bat_priv callback because
85647 * we have no bat_priv yet.
85648 */
85649 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85650 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85651 hard_iface->bat_iv.ogm_buff = NULL;
85652
85653 return hard_iface;
85654 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85655 index 6b548fd..fc32c8d 100644
85656 --- a/net/batman-adv/soft-interface.c
85657 +++ b/net/batman-adv/soft-interface.c
85658 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85659 primary_if->net_dev->dev_addr, ETH_ALEN);
85660
85661 /* set broadcast sequence number */
85662 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85663 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85664 bcast_packet->seqno = htonl(seqno);
85665
85666 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85667 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85668 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85669
85670 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85671 - atomic_set(&bat_priv->bcast_seqno, 1);
85672 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85673 atomic_set(&bat_priv->tt.vn, 0);
85674 atomic_set(&bat_priv->tt.local_changes, 0);
85675 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85676 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85677 index ae9ac9a..11e0fe7 100644
85678 --- a/net/batman-adv/types.h
85679 +++ b/net/batman-adv/types.h
85680 @@ -48,7 +48,7 @@
85681 struct batadv_hard_iface_bat_iv {
85682 unsigned char *ogm_buff;
85683 int ogm_buff_len;
85684 - atomic_t ogm_seqno;
85685 + atomic_unchecked_t ogm_seqno;
85686 };
85687
85688 struct batadv_hard_iface {
85689 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85690 int16_t if_num;
85691 char if_status;
85692 struct net_device *net_dev;
85693 - atomic_t frag_seqno;
85694 + atomic_unchecked_t frag_seqno;
85695 struct kobject *hardif_obj;
85696 atomic_t refcount;
85697 struct packet_type batman_adv_ptype;
85698 @@ -284,7 +284,7 @@ struct batadv_priv {
85699 atomic_t orig_interval; /* uint */
85700 atomic_t hop_penalty; /* uint */
85701 atomic_t log_level; /* uint */
85702 - atomic_t bcast_seqno;
85703 + atomic_unchecked_t bcast_seqno;
85704 atomic_t bcast_queue_left;
85705 atomic_t batman_queue_left;
85706 char num_ifaces;
85707 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85708 index 10aff49..ea8e021 100644
85709 --- a/net/batman-adv/unicast.c
85710 +++ b/net/batman-adv/unicast.c
85711 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85712 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85713 frag2->flags = large_tail;
85714
85715 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85716 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85717 frag1->seqno = htons(seqno - 1);
85718 frag2->seqno = htons(seqno);
85719
85720 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85721 index 07f0739..3c42e34 100644
85722 --- a/net/bluetooth/hci_sock.c
85723 +++ b/net/bluetooth/hci_sock.c
85724 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85725 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85726 }
85727
85728 - len = min_t(unsigned int, len, sizeof(uf));
85729 + len = min((size_t)len, sizeof(uf));
85730 if (copy_from_user(&uf, optval, len)) {
85731 err = -EFAULT;
85732 break;
85733 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85734 index 22e6583..426e2f3 100644
85735 --- a/net/bluetooth/l2cap_core.c
85736 +++ b/net/bluetooth/l2cap_core.c
85737 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85738 break;
85739
85740 case L2CAP_CONF_RFC:
85741 - if (olen == sizeof(rfc))
85742 - memcpy(&rfc, (void *)val, olen);
85743 + if (olen != sizeof(rfc))
85744 + break;
85745 +
85746 + memcpy(&rfc, (void *)val, olen);
85747
85748 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85749 rfc.mode != chan->mode)
85750 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85751 index 1bcfb84..dad9f98 100644
85752 --- a/net/bluetooth/l2cap_sock.c
85753 +++ b/net/bluetooth/l2cap_sock.c
85754 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85755 struct sock *sk = sock->sk;
85756 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85757 struct l2cap_options opts;
85758 - int len, err = 0;
85759 + int err = 0;
85760 + size_t len = optlen;
85761 u32 opt;
85762
85763 BT_DBG("sk %p", sk);
85764 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85765 opts.max_tx = chan->max_tx;
85766 opts.txwin_size = chan->tx_win;
85767
85768 - len = min_t(unsigned int, sizeof(opts), optlen);
85769 + len = min(sizeof(opts), len);
85770 if (copy_from_user((char *) &opts, optval, len)) {
85771 err = -EFAULT;
85772 break;
85773 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85774 struct bt_security sec;
85775 struct bt_power pwr;
85776 struct l2cap_conn *conn;
85777 - int len, err = 0;
85778 + int err = 0;
85779 + size_t len = optlen;
85780 u32 opt;
85781
85782 BT_DBG("sk %p", sk);
85783 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85784
85785 sec.level = BT_SECURITY_LOW;
85786
85787 - len = min_t(unsigned int, sizeof(sec), optlen);
85788 + len = min(sizeof(sec), len);
85789 if (copy_from_user((char *) &sec, optval, len)) {
85790 err = -EFAULT;
85791 break;
85792 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85793
85794 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85795
85796 - len = min_t(unsigned int, sizeof(pwr), optlen);
85797 + len = min(sizeof(pwr), len);
85798 if (copy_from_user((char *) &pwr, optval, len)) {
85799 err = -EFAULT;
85800 break;
85801 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85802 index 970fc13..cf0161d 100644
85803 --- a/net/bluetooth/rfcomm/sock.c
85804 +++ b/net/bluetooth/rfcomm/sock.c
85805 @@ -668,7 +668,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85806 struct sock *sk = sock->sk;
85807 struct bt_security sec;
85808 int err = 0;
85809 - size_t len;
85810 + size_t len = optlen;
85811 u32 opt;
85812
85813 BT_DBG("sk %p", sk);
85814 @@ -690,7 +690,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85815
85816 sec.level = BT_SECURITY_LOW;
85817
85818 - len = min_t(unsigned int, sizeof(sec), optlen);
85819 + len = min(sizeof(sec), len);
85820 if (copy_from_user((char *) &sec, optval, len)) {
85821 err = -EFAULT;
85822 break;
85823 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85824 index bd6fd0f..6492cba 100644
85825 --- a/net/bluetooth/rfcomm/tty.c
85826 +++ b/net/bluetooth/rfcomm/tty.c
85827 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85828 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85829
85830 spin_lock_irqsave(&dev->port.lock, flags);
85831 - if (dev->port.count > 0) {
85832 + if (atomic_read(&dev->port.count) > 0) {
85833 spin_unlock_irqrestore(&dev->port.lock, flags);
85834 return;
85835 }
85836 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85837 return -ENODEV;
85838
85839 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85840 - dev->channel, dev->port.count);
85841 + dev->channel, atomic_read(&dev->port.count));
85842
85843 spin_lock_irqsave(&dev->port.lock, flags);
85844 - if (++dev->port.count > 1) {
85845 + if (atomic_inc_return(&dev->port.count) > 1) {
85846 spin_unlock_irqrestore(&dev->port.lock, flags);
85847 return 0;
85848 }
85849 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85850 return;
85851
85852 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85853 - dev->port.count);
85854 + atomic_read(&dev->port.count));
85855
85856 spin_lock_irqsave(&dev->port.lock, flags);
85857 - if (!--dev->port.count) {
85858 + if (!atomic_dec_return(&dev->port.count)) {
85859 spin_unlock_irqrestore(&dev->port.lock, flags);
85860 if (dev->tty_dev->parent)
85861 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85862 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85863 index d9576e6..85f4f4e 100644
85864 --- a/net/bridge/br_fdb.c
85865 +++ b/net/bridge/br_fdb.c
85866 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85867 return 0;
85868 br_warn(br, "adding interface %s with same address "
85869 "as a received packet\n",
85870 - source->dev->name);
85871 + source ? source->dev->name : br->dev->name);
85872 fdb_delete(br, fdb);
85873 }
85874
85875 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85876 index 5fe2ff3..121d696 100644
85877 --- a/net/bridge/netfilter/ebtables.c
85878 +++ b/net/bridge/netfilter/ebtables.c
85879 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85880 tmp.valid_hooks = t->table->valid_hooks;
85881 }
85882 mutex_unlock(&ebt_mutex);
85883 - if (copy_to_user(user, &tmp, *len) != 0){
85884 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85885 BUGPRINT("c2u Didn't work\n");
85886 ret = -EFAULT;
85887 break;
85888 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85889 goto out;
85890 tmp.valid_hooks = t->valid_hooks;
85891
85892 - if (copy_to_user(user, &tmp, *len) != 0) {
85893 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85894 ret = -EFAULT;
85895 break;
85896 }
85897 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85898 tmp.entries_size = t->table->entries_size;
85899 tmp.valid_hooks = t->table->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 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85907 index a376ec1..1fbd6be 100644
85908 --- a/net/caif/cfctrl.c
85909 +++ b/net/caif/cfctrl.c
85910 @@ -10,6 +10,7 @@
85911 #include <linux/spinlock.h>
85912 #include <linux/slab.h>
85913 #include <linux/pkt_sched.h>
85914 +#include <linux/sched.h>
85915 #include <net/caif/caif_layer.h>
85916 #include <net/caif/cfpkt.h>
85917 #include <net/caif/cfctrl.h>
85918 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85919 memset(&dev_info, 0, sizeof(dev_info));
85920 dev_info.id = 0xff;
85921 cfsrvl_init(&this->serv, 0, &dev_info, false);
85922 - atomic_set(&this->req_seq_no, 1);
85923 - atomic_set(&this->rsp_seq_no, 1);
85924 + atomic_set_unchecked(&this->req_seq_no, 1);
85925 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85926 this->serv.layer.receive = cfctrl_recv;
85927 sprintf(this->serv.layer.name, "ctrl");
85928 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85929 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85930 struct cfctrl_request_info *req)
85931 {
85932 spin_lock_bh(&ctrl->info_list_lock);
85933 - atomic_inc(&ctrl->req_seq_no);
85934 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85935 + atomic_inc_unchecked(&ctrl->req_seq_no);
85936 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85937 list_add_tail(&req->list, &ctrl->list);
85938 spin_unlock_bh(&ctrl->info_list_lock);
85939 }
85940 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85941 if (p != first)
85942 pr_warn("Requests are not received in order\n");
85943
85944 - atomic_set(&ctrl->rsp_seq_no,
85945 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85946 p->sequence_no);
85947 list_del(&p->list);
85948 goto out;
85949 diff --git a/net/can/af_can.c b/net/can/af_can.c
85950 index ddac1ee..3ee0a78 100644
85951 --- a/net/can/af_can.c
85952 +++ b/net/can/af_can.c
85953 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85954 };
85955
85956 /* notifier block for netdevice event */
85957 -static struct notifier_block can_netdev_notifier __read_mostly = {
85958 +static struct notifier_block can_netdev_notifier = {
85959 .notifier_call = can_notifier,
85960 };
85961
85962 diff --git a/net/can/gw.c b/net/can/gw.c
85963 index 28e7bdc..d42c4cd 100644
85964 --- a/net/can/gw.c
85965 +++ b/net/can/gw.c
85966 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85967 MODULE_ALIAS("can-gw");
85968
85969 static HLIST_HEAD(cgw_list);
85970 -static struct notifier_block notifier;
85971
85972 static struct kmem_cache *cgw_cache __read_mostly;
85973
85974 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85975 return err;
85976 }
85977
85978 +static struct notifier_block notifier = {
85979 + .notifier_call = cgw_notifier
85980 +};
85981 +
85982 static __init int cgw_module_init(void)
85983 {
85984 printk(banner);
85985 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85986 return -ENOMEM;
85987
85988 /* set notifier */
85989 - notifier.notifier_call = cgw_notifier;
85990 register_netdevice_notifier(&notifier);
85991
85992 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85993 diff --git a/net/compat.c b/net/compat.c
85994 index 79ae884..17c5c09 100644
85995 --- a/net/compat.c
85996 +++ b/net/compat.c
85997 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85998 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85999 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86000 return -EFAULT;
86001 - kmsg->msg_name = compat_ptr(tmp1);
86002 - kmsg->msg_iov = compat_ptr(tmp2);
86003 - kmsg->msg_control = compat_ptr(tmp3);
86004 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86005 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86006 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86007 return 0;
86008 }
86009
86010 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86011
86012 if (kern_msg->msg_namelen) {
86013 if (mode == VERIFY_READ) {
86014 - int err = move_addr_to_kernel(kern_msg->msg_name,
86015 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86016 kern_msg->msg_namelen,
86017 kern_address);
86018 if (err < 0)
86019 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86020 kern_msg->msg_name = NULL;
86021
86022 tot_len = iov_from_user_compat_to_kern(kern_iov,
86023 - (struct compat_iovec __user *)kern_msg->msg_iov,
86024 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86025 kern_msg->msg_iovlen);
86026 if (tot_len >= 0)
86027 kern_msg->msg_iov = kern_iov;
86028 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86029
86030 #define CMSG_COMPAT_FIRSTHDR(msg) \
86031 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86032 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86033 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86034 (struct compat_cmsghdr __user *)NULL)
86035
86036 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86037 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86038 (ucmlen) <= (unsigned long) \
86039 ((mhdr)->msg_controllen - \
86040 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86041 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86042
86043 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86044 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86045 {
86046 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86047 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86048 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86049 msg->msg_controllen)
86050 return NULL;
86051 return (struct compat_cmsghdr __user *)ptr;
86052 @@ -219,7 +219,7 @@ Efault:
86053
86054 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86055 {
86056 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86057 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86058 struct compat_cmsghdr cmhdr;
86059 struct compat_timeval ctv;
86060 struct compat_timespec cts[3];
86061 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86062
86063 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86064 {
86065 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86066 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86067 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86068 int fdnum = scm->fp->count;
86069 struct file **fp = scm->fp->fp;
86070 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86071 return -EFAULT;
86072 old_fs = get_fs();
86073 set_fs(KERNEL_DS);
86074 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86075 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86076 set_fs(old_fs);
86077
86078 return err;
86079 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86080 len = sizeof(ktime);
86081 old_fs = get_fs();
86082 set_fs(KERNEL_DS);
86083 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86084 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86085 set_fs(old_fs);
86086
86087 if (!err) {
86088 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86089 case MCAST_JOIN_GROUP:
86090 case MCAST_LEAVE_GROUP:
86091 {
86092 - struct compat_group_req __user *gr32 = (void *)optval;
86093 + struct compat_group_req __user *gr32 = (void __user *)optval;
86094 struct group_req __user *kgr =
86095 compat_alloc_user_space(sizeof(struct group_req));
86096 u32 interface;
86097 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86098 case MCAST_BLOCK_SOURCE:
86099 case MCAST_UNBLOCK_SOURCE:
86100 {
86101 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86102 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86103 struct group_source_req __user *kgsr = compat_alloc_user_space(
86104 sizeof(struct group_source_req));
86105 u32 interface;
86106 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86107 }
86108 case MCAST_MSFILTER:
86109 {
86110 - struct compat_group_filter __user *gf32 = (void *)optval;
86111 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86112 struct group_filter __user *kgf;
86113 u32 interface, fmode, numsrc;
86114
86115 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86116 char __user *optval, int __user *optlen,
86117 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86118 {
86119 - struct compat_group_filter __user *gf32 = (void *)optval;
86120 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86121 struct group_filter __user *kgf;
86122 int __user *koptlen;
86123 u32 interface, fmode, numsrc;
86124 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86125
86126 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86127 return -EINVAL;
86128 - if (copy_from_user(a, args, nas[call]))
86129 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86130 return -EFAULT;
86131 a0 = a[0];
86132 a1 = a[1];
86133 diff --git a/net/core/datagram.c b/net/core/datagram.c
86134 index 368f9c3..f82d4a3 100644
86135 --- a/net/core/datagram.c
86136 +++ b/net/core/datagram.c
86137 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86138 }
86139
86140 kfree_skb(skb);
86141 - atomic_inc(&sk->sk_drops);
86142 + atomic_inc_unchecked(&sk->sk_drops);
86143 sk_mem_reclaim_partial(sk);
86144
86145 return err;
86146 diff --git a/net/core/dev.c b/net/core/dev.c
86147 index d592214..2764363 100644
86148 --- a/net/core/dev.c
86149 +++ b/net/core/dev.c
86150 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86151 if (no_module && capable(CAP_NET_ADMIN))
86152 no_module = request_module("netdev-%s", name);
86153 if (no_module && capable(CAP_SYS_MODULE)) {
86154 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86155 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86156 +#else
86157 if (!request_module("%s", name))
86158 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86159 name);
86160 +#endif
86161 }
86162 }
86163 EXPORT_SYMBOL(dev_load);
86164 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86165 {
86166 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86167 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86168 - atomic_long_inc(&dev->rx_dropped);
86169 + atomic_long_inc_unchecked(&dev->rx_dropped);
86170 kfree_skb(skb);
86171 return NET_RX_DROP;
86172 }
86173 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86174 nf_reset(skb);
86175
86176 if (unlikely(!is_skb_forwardable(dev, skb))) {
86177 - atomic_long_inc(&dev->rx_dropped);
86178 + atomic_long_inc_unchecked(&dev->rx_dropped);
86179 kfree_skb(skb);
86180 return NET_RX_DROP;
86181 }
86182 @@ -2183,7 +2187,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86183
86184 struct dev_gso_cb {
86185 void (*destructor)(struct sk_buff *skb);
86186 -};
86187 +} __no_const;
86188
86189 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86190
86191 @@ -3056,7 +3060,7 @@ enqueue:
86192
86193 local_irq_restore(flags);
86194
86195 - atomic_long_inc(&skb->dev->rx_dropped);
86196 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86197 kfree_skb(skb);
86198 return NET_RX_DROP;
86199 }
86200 @@ -3128,7 +3132,7 @@ int netif_rx_ni(struct sk_buff *skb)
86201 }
86202 EXPORT_SYMBOL(netif_rx_ni);
86203
86204 -static void net_tx_action(struct softirq_action *h)
86205 +static void net_tx_action(void)
86206 {
86207 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86208
86209 @@ -3466,7 +3470,7 @@ ncls:
86210 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86211 } else {
86212 drop:
86213 - atomic_long_inc(&skb->dev->rx_dropped);
86214 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86215 kfree_skb(skb);
86216 /* Jamal, now you will not able to escape explaining
86217 * me how you were going to use this. :-)
86218 @@ -4049,7 +4053,7 @@ void netif_napi_del(struct napi_struct *napi)
86219 }
86220 EXPORT_SYMBOL(netif_napi_del);
86221
86222 -static void net_rx_action(struct softirq_action *h)
86223 +static void net_rx_action(void)
86224 {
86225 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86226 unsigned long time_limit = jiffies + 2;
86227 @@ -4533,8 +4537,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86228 else
86229 seq_printf(seq, "%04x", ntohs(pt->type));
86230
86231 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86232 + seq_printf(seq, " %-8s %p\n",
86233 + pt->dev ? pt->dev->name : "", NULL);
86234 +#else
86235 seq_printf(seq, " %-8s %pF\n",
86236 pt->dev ? pt->dev->name : "", pt->func);
86237 +#endif
86238 }
86239
86240 return 0;
86241 @@ -6106,7 +6115,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86242 } else {
86243 netdev_stats_to_stats64(storage, &dev->stats);
86244 }
86245 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86246 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86247 return storage;
86248 }
86249 EXPORT_SYMBOL(dev_get_stats);
86250 diff --git a/net/core/flow.c b/net/core/flow.c
86251 index 3bad824..2071a55 100644
86252 --- a/net/core/flow.c
86253 +++ b/net/core/flow.c
86254 @@ -61,7 +61,7 @@ struct flow_cache {
86255 struct timer_list rnd_timer;
86256 };
86257
86258 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86259 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86260 EXPORT_SYMBOL(flow_cache_genid);
86261 static struct flow_cache flow_cache_global;
86262 static struct kmem_cache *flow_cachep __read_mostly;
86263 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86264
86265 static int flow_entry_valid(struct flow_cache_entry *fle)
86266 {
86267 - if (atomic_read(&flow_cache_genid) != fle->genid)
86268 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86269 return 0;
86270 if (fle->object && !fle->object->ops->check(fle->object))
86271 return 0;
86272 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86273 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86274 fcp->hash_count++;
86275 }
86276 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86277 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86278 flo = fle->object;
86279 if (!flo)
86280 goto ret_object;
86281 @@ -280,7 +280,7 @@ nocache:
86282 }
86283 flo = resolver(net, key, family, dir, flo, ctx);
86284 if (fle) {
86285 - fle->genid = atomic_read(&flow_cache_genid);
86286 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86287 if (!IS_ERR(flo))
86288 fle->object = flo;
86289 else
86290 diff --git a/net/core/iovec.c b/net/core/iovec.c
86291 index 7e7aeb0..2a998cb 100644
86292 --- a/net/core/iovec.c
86293 +++ b/net/core/iovec.c
86294 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86295 if (m->msg_namelen) {
86296 if (mode == VERIFY_READ) {
86297 void __user *namep;
86298 - namep = (void __user __force *) m->msg_name;
86299 + namep = (void __force_user *) m->msg_name;
86300 err = move_addr_to_kernel(namep, m->msg_namelen,
86301 address);
86302 if (err < 0)
86303 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86304 }
86305
86306 size = m->msg_iovlen * sizeof(struct iovec);
86307 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86308 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86309 return -EFAULT;
86310
86311 m->msg_iov = iov;
86312 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86313 index c815f28..e6403f2 100644
86314 --- a/net/core/neighbour.c
86315 +++ b/net/core/neighbour.c
86316 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86317 size_t *lenp, loff_t *ppos)
86318 {
86319 int size, ret;
86320 - ctl_table tmp = *ctl;
86321 + ctl_table_no_const tmp = *ctl;
86322
86323 tmp.extra1 = &zero;
86324 tmp.extra2 = &unres_qlen_max;
86325 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86326 index 28c5f5a..7edf2e2 100644
86327 --- a/net/core/net-sysfs.c
86328 +++ b/net/core/net-sysfs.c
86329 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86330 }
86331 EXPORT_SYMBOL(netdev_class_remove_file);
86332
86333 -int netdev_kobject_init(void)
86334 +int __init netdev_kobject_init(void)
86335 {
86336 kobj_ns_type_register(&net_ns_type_operations);
86337 return class_register(&net_class);
86338 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86339 index 8acce01..2e306bb 100644
86340 --- a/net/core/net_namespace.c
86341 +++ b/net/core/net_namespace.c
86342 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86343 int error;
86344 LIST_HEAD(net_exit_list);
86345
86346 - list_add_tail(&ops->list, list);
86347 + pax_list_add_tail((struct list_head *)&ops->list, list);
86348 if (ops->init || (ops->id && ops->size)) {
86349 for_each_net(net) {
86350 error = ops_init(ops, net);
86351 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86352
86353 out_undo:
86354 /* If I have an error cleanup all namespaces I initialized */
86355 - list_del(&ops->list);
86356 + pax_list_del((struct list_head *)&ops->list);
86357 ops_exit_list(ops, &net_exit_list);
86358 ops_free_list(ops, &net_exit_list);
86359 return error;
86360 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86361 struct net *net;
86362 LIST_HEAD(net_exit_list);
86363
86364 - list_del(&ops->list);
86365 + pax_list_del((struct list_head *)&ops->list);
86366 for_each_net(net)
86367 list_add_tail(&net->exit_list, &net_exit_list);
86368 ops_exit_list(ops, &net_exit_list);
86369 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86370 mutex_lock(&net_mutex);
86371 error = register_pernet_operations(&pernet_list, ops);
86372 if (!error && (first_device == &pernet_list))
86373 - first_device = &ops->list;
86374 + first_device = (struct list_head *)&ops->list;
86375 mutex_unlock(&net_mutex);
86376 return error;
86377 }
86378 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86379 index 055fb13..5ee16b2 100644
86380 --- a/net/core/rtnetlink.c
86381 +++ b/net/core/rtnetlink.c
86382 @@ -58,7 +58,7 @@ struct rtnl_link {
86383 rtnl_doit_func doit;
86384 rtnl_dumpit_func dumpit;
86385 rtnl_calcit_func calcit;
86386 -};
86387 +} __no_const;
86388
86389 static DEFINE_MUTEX(rtnl_mutex);
86390
86391 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86392 if (rtnl_link_ops_get(ops->kind))
86393 return -EEXIST;
86394
86395 - if (!ops->dellink)
86396 - ops->dellink = unregister_netdevice_queue;
86397 + if (!ops->dellink) {
86398 + pax_open_kernel();
86399 + *(void **)&ops->dellink = unregister_netdevice_queue;
86400 + pax_close_kernel();
86401 + }
86402
86403 - list_add_tail(&ops->list, &link_ops);
86404 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86405 return 0;
86406 }
86407 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86408 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86409 for_each_net(net) {
86410 __rtnl_kill_links(net, ops);
86411 }
86412 - list_del(&ops->list);
86413 + pax_list_del((struct list_head *)&ops->list);
86414 }
86415 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86416
86417 diff --git a/net/core/scm.c b/net/core/scm.c
86418 index 2dc6cda..2159524 100644
86419 --- a/net/core/scm.c
86420 +++ b/net/core/scm.c
86421 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86422 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86423 {
86424 struct cmsghdr __user *cm
86425 - = (__force struct cmsghdr __user *)msg->msg_control;
86426 + = (struct cmsghdr __force_user *)msg->msg_control;
86427 struct cmsghdr cmhdr;
86428 int cmlen = CMSG_LEN(len);
86429 int err;
86430 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86431 err = -EFAULT;
86432 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86433 goto out;
86434 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86435 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86436 goto out;
86437 cmlen = CMSG_SPACE(len);
86438 if (msg->msg_controllen < cmlen)
86439 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86440 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86441 {
86442 struct cmsghdr __user *cm
86443 - = (__force struct cmsghdr __user*)msg->msg_control;
86444 + = (struct cmsghdr __force_user *)msg->msg_control;
86445
86446 int fdmax = 0;
86447 int fdnum = scm->fp->count;
86448 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86449 if (fdnum < fdmax)
86450 fdmax = fdnum;
86451
86452 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86453 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86454 i++, cmfptr++)
86455 {
86456 struct socket *sock;
86457 diff --git a/net/core/secure_seq.c b/net/core/secure_seq.c
86458 index e61a8bb..6a2f13c 100644
86459 --- a/net/core/secure_seq.c
86460 +++ b/net/core/secure_seq.c
86461 @@ -12,12 +12,10 @@
86462
86463 static u32 net_secret[MD5_MESSAGE_BYTES / 4] ____cacheline_aligned;
86464
86465 -static int __init net_secret_init(void)
86466 +void net_secret_init(void)
86467 {
86468 get_random_bytes(net_secret, sizeof(net_secret));
86469 - return 0;
86470 }
86471 -late_initcall(net_secret_init);
86472
86473 #ifdef CONFIG_INET
86474 static u32 seq_scale(u32 seq)
86475 diff --git a/net/core/sock.c b/net/core/sock.c
86476 index bc131d4..029e378 100644
86477 --- a/net/core/sock.c
86478 +++ b/net/core/sock.c
86479 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86480 struct sk_buff_head *list = &sk->sk_receive_queue;
86481
86482 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86483 - atomic_inc(&sk->sk_drops);
86484 + atomic_inc_unchecked(&sk->sk_drops);
86485 trace_sock_rcvqueue_full(sk, skb);
86486 return -ENOMEM;
86487 }
86488 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86489 return err;
86490
86491 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86492 - atomic_inc(&sk->sk_drops);
86493 + atomic_inc_unchecked(&sk->sk_drops);
86494 return -ENOBUFS;
86495 }
86496
86497 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86498 skb_dst_force(skb);
86499
86500 spin_lock_irqsave(&list->lock, flags);
86501 - skb->dropcount = atomic_read(&sk->sk_drops);
86502 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86503 __skb_queue_tail(list, skb);
86504 spin_unlock_irqrestore(&list->lock, flags);
86505
86506 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86507 skb->dev = NULL;
86508
86509 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86510 - atomic_inc(&sk->sk_drops);
86511 + atomic_inc_unchecked(&sk->sk_drops);
86512 goto discard_and_relse;
86513 }
86514 if (nested)
86515 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86516 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86517 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86518 bh_unlock_sock(sk);
86519 - atomic_inc(&sk->sk_drops);
86520 + atomic_inc_unchecked(&sk->sk_drops);
86521 goto discard_and_relse;
86522 }
86523
86524 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86525 struct timeval tm;
86526 } v;
86527
86528 - int lv = sizeof(int);
86529 - int len;
86530 + unsigned int lv = sizeof(int);
86531 + unsigned int len;
86532
86533 if (get_user(len, optlen))
86534 return -EFAULT;
86535 - if (len < 0)
86536 + if (len > INT_MAX)
86537 return -EINVAL;
86538
86539 memset(&v, 0, sizeof(v));
86540 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86541
86542 case SO_PEERNAME:
86543 {
86544 - char address[128];
86545 + char address[_K_SS_MAXSIZE];
86546
86547 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86548 return -ENOTCONN;
86549 - if (lv < len)
86550 + if (lv < len || sizeof address < len)
86551 return -EINVAL;
86552 if (copy_to_user(optval, address, len))
86553 return -EFAULT;
86554 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86555
86556 if (len > lv)
86557 len = lv;
86558 - if (copy_to_user(optval, &v, len))
86559 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86560 return -EFAULT;
86561 lenout:
86562 if (put_user(len, optlen))
86563 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86564 */
86565 smp_wmb();
86566 atomic_set(&sk->sk_refcnt, 1);
86567 - atomic_set(&sk->sk_drops, 0);
86568 + atomic_set_unchecked(&sk->sk_drops, 0);
86569 }
86570 EXPORT_SYMBOL(sock_init_data);
86571
86572 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86573 index 750f44f..922399c 100644
86574 --- a/net/core/sock_diag.c
86575 +++ b/net/core/sock_diag.c
86576 @@ -9,26 +9,33 @@
86577 #include <linux/inet_diag.h>
86578 #include <linux/sock_diag.h>
86579
86580 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86581 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86582 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86583 static DEFINE_MUTEX(sock_diag_table_mutex);
86584
86585 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86586 {
86587 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86588 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86589 cookie[1] != INET_DIAG_NOCOOKIE) &&
86590 ((u32)(unsigned long)sk != cookie[0] ||
86591 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86592 return -ESTALE;
86593 else
86594 +#endif
86595 return 0;
86596 }
86597 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86598
86599 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86600 {
86601 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86602 + cookie[0] = 0;
86603 + cookie[1] = 0;
86604 +#else
86605 cookie[0] = (u32)(unsigned long)sk;
86606 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86607 +#endif
86608 }
86609 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86610
86611 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86612 mutex_lock(&sock_diag_table_mutex);
86613 if (sock_diag_handlers[hndl->family])
86614 err = -EBUSY;
86615 - else
86616 + else {
86617 + pax_open_kernel();
86618 sock_diag_handlers[hndl->family] = hndl;
86619 + pax_close_kernel();
86620 + }
86621 mutex_unlock(&sock_diag_table_mutex);
86622
86623 return err;
86624 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86625
86626 mutex_lock(&sock_diag_table_mutex);
86627 BUG_ON(sock_diag_handlers[family] != hnld);
86628 + pax_open_kernel();
86629 sock_diag_handlers[family] = NULL;
86630 + pax_close_kernel();
86631 mutex_unlock(&sock_diag_table_mutex);
86632 }
86633 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86634
86635 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86636 -{
86637 - if (sock_diag_handlers[family] == NULL)
86638 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86639 - NETLINK_SOCK_DIAG, family);
86640 -
86641 - mutex_lock(&sock_diag_table_mutex);
86642 - return sock_diag_handlers[family];
86643 -}
86644 -
86645 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86646 -{
86647 - mutex_unlock(&sock_diag_table_mutex);
86648 -}
86649 -
86650 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86651 {
86652 int err;
86653 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86654 if (req->sdiag_family >= AF_MAX)
86655 return -EINVAL;
86656
86657 - hndl = sock_diag_lock_handler(req->sdiag_family);
86658 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86659 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86660 + NETLINK_SOCK_DIAG, req->sdiag_family);
86661 +
86662 + mutex_lock(&sock_diag_table_mutex);
86663 + hndl = sock_diag_handlers[req->sdiag_family];
86664 if (hndl == NULL)
86665 err = -ENOENT;
86666 else
86667 err = hndl->dump(skb, nlh);
86668 - sock_diag_unlock_handler(hndl);
86669 + mutex_unlock(&sock_diag_table_mutex);
86670
86671 return err;
86672 }
86673 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86674 index d1b0804..98cf5f7 100644
86675 --- a/net/core/sysctl_net_core.c
86676 +++ b/net/core/sysctl_net_core.c
86677 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86678 {
86679 unsigned int orig_size, size;
86680 int ret, i;
86681 - ctl_table tmp = {
86682 + ctl_table_no_const tmp = {
86683 .data = &size,
86684 .maxlen = sizeof(size),
86685 .mode = table->mode
86686 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86687
86688 static __net_init int sysctl_core_net_init(struct net *net)
86689 {
86690 - struct ctl_table *tbl;
86691 + ctl_table_no_const *tbl = NULL;
86692
86693 net->core.sysctl_somaxconn = SOMAXCONN;
86694
86695 - tbl = netns_core_table;
86696 if (!net_eq(net, &init_net)) {
86697 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86698 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86699 if (tbl == NULL)
86700 goto err_dup;
86701
86702 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86703 if (net->user_ns != &init_user_ns) {
86704 tbl[0].procname = NULL;
86705 }
86706 - }
86707 -
86708 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86709 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86710 + } else
86711 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86712 if (net->core.sysctl_hdr == NULL)
86713 goto err_reg;
86714
86715 return 0;
86716
86717 err_reg:
86718 - if (tbl != netns_core_table)
86719 - kfree(tbl);
86720 + kfree(tbl);
86721 err_dup:
86722 return -ENOMEM;
86723 }
86724 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86725 kfree(tbl);
86726 }
86727
86728 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86729 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86730 .init = sysctl_core_net_init,
86731 .exit = sysctl_core_net_exit,
86732 };
86733 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86734 index 307c322..78a4c6f 100644
86735 --- a/net/decnet/af_decnet.c
86736 +++ b/net/decnet/af_decnet.c
86737 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86738 .sysctl_rmem = sysctl_decnet_rmem,
86739 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86740 .obj_size = sizeof(struct dn_sock),
86741 + .slab_flags = SLAB_USERCOPY,
86742 };
86743
86744 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86745 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86746 index a55eecc..dd8428c 100644
86747 --- a/net/decnet/sysctl_net_decnet.c
86748 +++ b/net/decnet/sysctl_net_decnet.c
86749 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86750
86751 if (len > *lenp) len = *lenp;
86752
86753 - if (copy_to_user(buffer, addr, len))
86754 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86755 return -EFAULT;
86756
86757 *lenp = len;
86758 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86759
86760 if (len > *lenp) len = *lenp;
86761
86762 - if (copy_to_user(buffer, devname, len))
86763 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86764 return -EFAULT;
86765
86766 *lenp = len;
86767 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86768 index fcf104e..6b748ea 100644
86769 --- a/net/ipv4/af_inet.c
86770 +++ b/net/ipv4/af_inet.c
86771 @@ -115,6 +115,7 @@
86772 #include <net/inet_common.h>
86773 #include <net/xfrm.h>
86774 #include <net/net_namespace.h>
86775 +#include <net/secure_seq.h>
86776 #ifdef CONFIG_IP_MROUTE
86777 #include <linux/mroute.h>
86778 #endif
86779 @@ -263,8 +264,10 @@ void build_ehash_secret(void)
86780 get_random_bytes(&rnd, sizeof(rnd));
86781 } while (rnd == 0);
86782
86783 - if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0)
86784 + if (cmpxchg(&inet_ehash_secret, 0, rnd) == 0) {
86785 get_random_bytes(&ipv6_hash_secret, sizeof(ipv6_hash_secret));
86786 + net_secret_init();
86787 + }
86788 }
86789 EXPORT_SYMBOL(build_ehash_secret);
86790
86791 @@ -1717,13 +1720,9 @@ static int __init inet_init(void)
86792
86793 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86794
86795 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86796 - if (!sysctl_local_reserved_ports)
86797 - goto out;
86798 -
86799 rc = proto_register(&tcp_prot, 1);
86800 if (rc)
86801 - goto out_free_reserved_ports;
86802 + goto out;
86803
86804 rc = proto_register(&udp_prot, 1);
86805 if (rc)
86806 @@ -1832,8 +1831,6 @@ out_unregister_udp_proto:
86807 proto_unregister(&udp_prot);
86808 out_unregister_tcp_proto:
86809 proto_unregister(&tcp_prot);
86810 -out_free_reserved_ports:
86811 - kfree(sysctl_local_reserved_ports);
86812 goto out;
86813 }
86814
86815 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86816 index a69b4e4..dbccba5 100644
86817 --- a/net/ipv4/ah4.c
86818 +++ b/net/ipv4/ah4.c
86819 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86820 return;
86821
86822 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86823 - atomic_inc(&flow_cache_genid);
86824 + atomic_inc_unchecked(&flow_cache_genid);
86825 rt_genid_bump(net);
86826
86827 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86828 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86829 index a8e4f26..25e5f40 100644
86830 --- a/net/ipv4/devinet.c
86831 +++ b/net/ipv4/devinet.c
86832 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86833 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86834 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86835
86836 -static struct devinet_sysctl_table {
86837 +static const struct devinet_sysctl_table {
86838 struct ctl_table_header *sysctl_header;
86839 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86840 } devinet_sysctl = {
86841 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86842 int err;
86843 struct ipv4_devconf *all, *dflt;
86844 #ifdef CONFIG_SYSCTL
86845 - struct ctl_table *tbl = ctl_forward_entry;
86846 + ctl_table_no_const *tbl = NULL;
86847 struct ctl_table_header *forw_hdr;
86848 #endif
86849
86850 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86851 goto err_alloc_dflt;
86852
86853 #ifdef CONFIG_SYSCTL
86854 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86855 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86856 if (tbl == NULL)
86857 goto err_alloc_ctl;
86858
86859 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86860 goto err_reg_dflt;
86861
86862 err = -ENOMEM;
86863 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86864 + if (!net_eq(net, &init_net))
86865 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86866 + else
86867 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86868 if (forw_hdr == NULL)
86869 goto err_reg_ctl;
86870 net->ipv4.forw_hdr = forw_hdr;
86871 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86872 err_reg_dflt:
86873 __devinet_sysctl_unregister(all);
86874 err_reg_all:
86875 - if (tbl != ctl_forward_entry)
86876 - kfree(tbl);
86877 + kfree(tbl);
86878 err_alloc_ctl:
86879 #endif
86880 if (dflt != &ipv4_devconf_dflt)
86881 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86882 index 4cfe34d..a6ba66e 100644
86883 --- a/net/ipv4/esp4.c
86884 +++ b/net/ipv4/esp4.c
86885 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86886 return;
86887
86888 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86889 - atomic_inc(&flow_cache_genid);
86890 + atomic_inc_unchecked(&flow_cache_genid);
86891 rt_genid_bump(net);
86892
86893 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86894 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86895 index 5cd75e2..f57ef39 100644
86896 --- a/net/ipv4/fib_frontend.c
86897 +++ b/net/ipv4/fib_frontend.c
86898 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86899 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86900 fib_sync_up(dev);
86901 #endif
86902 - atomic_inc(&net->ipv4.dev_addr_genid);
86903 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86904 rt_cache_flush(dev_net(dev));
86905 break;
86906 case NETDEV_DOWN:
86907 fib_del_ifaddr(ifa, NULL);
86908 - atomic_inc(&net->ipv4.dev_addr_genid);
86909 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86910 if (ifa->ifa_dev->ifa_list == NULL) {
86911 /* Last address was deleted from this interface.
86912 * Disable IP.
86913 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86914 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86915 fib_sync_up(dev);
86916 #endif
86917 - atomic_inc(&net->ipv4.dev_addr_genid);
86918 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86919 rt_cache_flush(net);
86920 break;
86921 case NETDEV_DOWN:
86922 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86923 index 4797a80..2bd54e9 100644
86924 --- a/net/ipv4/fib_semantics.c
86925 +++ b/net/ipv4/fib_semantics.c
86926 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86927 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86928 nh->nh_gw,
86929 nh->nh_parent->fib_scope);
86930 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86931 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86932
86933 return nh->nh_saddr;
86934 }
86935 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86936 index d0670f0..744ac80 100644
86937 --- a/net/ipv4/inet_connection_sock.c
86938 +++ b/net/ipv4/inet_connection_sock.c
86939 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86940 .range = { 32768, 61000 },
86941 };
86942
86943 -unsigned long *sysctl_local_reserved_ports;
86944 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86945 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86946
86947 void inet_get_local_port_range(int *low, int *high)
86948 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86949 index fa3ae81..0dbe6b8 100644
86950 --- a/net/ipv4/inet_hashtables.c
86951 +++ b/net/ipv4/inet_hashtables.c
86952 @@ -18,12 +18,15 @@
86953 #include <linux/sched.h>
86954 #include <linux/slab.h>
86955 #include <linux/wait.h>
86956 +#include <linux/security.h>
86957
86958 #include <net/inet_connection_sock.h>
86959 #include <net/inet_hashtables.h>
86960 #include <net/secure_seq.h>
86961 #include <net/ip.h>
86962
86963 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86964 +
86965 /*
86966 * Allocate and initialize a new local port bind bucket.
86967 * The bindhash mutex for snum's hash chain must be held here.
86968 @@ -540,6 +543,8 @@ ok:
86969 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86970 spin_unlock(&head->lock);
86971
86972 + gr_update_task_in_ip_table(current, inet_sk(sk));
86973 +
86974 if (tw) {
86975 inet_twsk_deschedule(tw, death_row);
86976 while (twrefcnt) {
86977 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86978 index 000e3d2..5472da3 100644
86979 --- a/net/ipv4/inetpeer.c
86980 +++ b/net/ipv4/inetpeer.c
86981 @@ -503,8 +503,8 @@ relookup:
86982 if (p) {
86983 p->daddr = *daddr;
86984 atomic_set(&p->refcnt, 1);
86985 - atomic_set(&p->rid, 0);
86986 - atomic_set(&p->ip_id_count,
86987 + atomic_set_unchecked(&p->rid, 0);
86988 + atomic_set_unchecked(&p->ip_id_count,
86989 (daddr->family == AF_INET) ?
86990 secure_ip_id(daddr->addr.a4) :
86991 secure_ipv6_id(daddr->addr.a6));
86992 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86993 index 0fcfee3..66e86c9 100644
86994 --- a/net/ipv4/ip_fragment.c
86995 +++ b/net/ipv4/ip_fragment.c
86996 @@ -318,7 +318,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86997 return 0;
86998
86999 start = qp->rid;
87000 - end = atomic_inc_return(&peer->rid);
87001 + end = atomic_inc_return_unchecked(&peer->rid);
87002 qp->rid = end;
87003
87004 rc = qp->q.fragments && (end - start) > max;
87005 @@ -793,12 +793,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87006
87007 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87008 {
87009 - struct ctl_table *table;
87010 + ctl_table_no_const *table = NULL;
87011 struct ctl_table_header *hdr;
87012
87013 - table = ip4_frags_ns_ctl_table;
87014 if (!net_eq(net, &init_net)) {
87015 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87016 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87017 if (table == NULL)
87018 goto err_alloc;
87019
87020 @@ -809,9 +808,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87021 /* Don't export sysctls to unprivileged users */
87022 if (net->user_ns != &init_user_ns)
87023 table[0].procname = NULL;
87024 - }
87025 + hdr = register_net_sysctl(net, "net/ipv4", table);
87026 + } else
87027 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87028
87029 - hdr = register_net_sysctl(net, "net/ipv4", table);
87030 if (hdr == NULL)
87031 goto err_reg;
87032
87033 @@ -819,8 +819,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87034 return 0;
87035
87036 err_reg:
87037 - if (!net_eq(net, &init_net))
87038 - kfree(table);
87039 + kfree(table);
87040 err_alloc:
87041 return -ENOMEM;
87042 }
87043 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87044 index a85062b..2958a9b 100644
87045 --- a/net/ipv4/ip_gre.c
87046 +++ b/net/ipv4/ip_gre.c
87047 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
87048 module_param(log_ecn_error, bool, 0644);
87049 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87050
87051 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87052 +static struct rtnl_link_ops ipgre_link_ops;
87053 static int ipgre_tunnel_init(struct net_device *dev);
87054 static void ipgre_tunnel_setup(struct net_device *dev);
87055 static int ipgre_tunnel_bind_dev(struct net_device *dev);
87056 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87057 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87058 };
87059
87060 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87061 +static struct rtnl_link_ops ipgre_link_ops = {
87062 .kind = "gre",
87063 .maxtype = IFLA_GRE_MAX,
87064 .policy = ipgre_policy,
87065 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87066 .fill_info = ipgre_fill_info,
87067 };
87068
87069 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87070 +static struct rtnl_link_ops ipgre_tap_ops = {
87071 .kind = "gretap",
87072 .maxtype = IFLA_GRE_MAX,
87073 .policy = ipgre_policy,
87074 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87075 index d9c4f11..02b82dbc 100644
87076 --- a/net/ipv4/ip_sockglue.c
87077 +++ b/net/ipv4/ip_sockglue.c
87078 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87079 len = min_t(unsigned int, len, opt->optlen);
87080 if (put_user(len, optlen))
87081 return -EFAULT;
87082 - if (copy_to_user(optval, opt->__data, len))
87083 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87084 + copy_to_user(optval, opt->__data, len))
87085 return -EFAULT;
87086 return 0;
87087 }
87088 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87089 if (sk->sk_type != SOCK_STREAM)
87090 return -ENOPROTOOPT;
87091
87092 - msg.msg_control = optval;
87093 + msg.msg_control = (void __force_kernel *)optval;
87094 msg.msg_controllen = len;
87095 msg.msg_flags = flags;
87096
87097 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87098 index c3a4233..1412161 100644
87099 --- a/net/ipv4/ip_vti.c
87100 +++ b/net/ipv4/ip_vti.c
87101 @@ -47,7 +47,7 @@
87102 #define HASH_SIZE 16
87103 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87104
87105 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87106 +static struct rtnl_link_ops vti_link_ops;
87107
87108 static int vti_net_id __read_mostly;
87109 struct vti_net {
87110 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87111 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87112 };
87113
87114 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87115 +static struct rtnl_link_ops vti_link_ops = {
87116 .kind = "vti",
87117 .maxtype = IFLA_VTI_MAX,
87118 .policy = vti_policy,
87119 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87120 index 9a46dae..5f793a0 100644
87121 --- a/net/ipv4/ipcomp.c
87122 +++ b/net/ipv4/ipcomp.c
87123 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87124 return;
87125
87126 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87127 - atomic_inc(&flow_cache_genid);
87128 + atomic_inc_unchecked(&flow_cache_genid);
87129 rt_genid_bump(net);
87130
87131 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87132 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87133 index a2e50ae..e152b7c 100644
87134 --- a/net/ipv4/ipconfig.c
87135 +++ b/net/ipv4/ipconfig.c
87136 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87137
87138 mm_segment_t oldfs = get_fs();
87139 set_fs(get_ds());
87140 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87141 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87142 set_fs(oldfs);
87143 return res;
87144 }
87145 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87146
87147 mm_segment_t oldfs = get_fs();
87148 set_fs(get_ds());
87149 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87150 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87151 set_fs(oldfs);
87152 return res;
87153 }
87154 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87155
87156 mm_segment_t oldfs = get_fs();
87157 set_fs(get_ds());
87158 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87159 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87160 set_fs(oldfs);
87161 return res;
87162 }
87163 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87164 index 191fc24..1b3b804 100644
87165 --- a/net/ipv4/ipip.c
87166 +++ b/net/ipv4/ipip.c
87167 @@ -138,7 +138,7 @@ struct ipip_net {
87168 static int ipip_tunnel_init(struct net_device *dev);
87169 static void ipip_tunnel_setup(struct net_device *dev);
87170 static void ipip_dev_free(struct net_device *dev);
87171 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87172 +static struct rtnl_link_ops ipip_link_ops;
87173
87174 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87175 struct rtnl_link_stats64 *tot)
87176 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87177 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87178 };
87179
87180 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87181 +static struct rtnl_link_ops ipip_link_ops = {
87182 .kind = "ipip",
87183 .maxtype = IFLA_IPTUN_MAX,
87184 .policy = ipip_policy,
87185 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87186 index 3ea4127..849297b 100644
87187 --- a/net/ipv4/netfilter/arp_tables.c
87188 +++ b/net/ipv4/netfilter/arp_tables.c
87189 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87190 #endif
87191
87192 static int get_info(struct net *net, void __user *user,
87193 - const int *len, int compat)
87194 + int len, int compat)
87195 {
87196 char name[XT_TABLE_MAXNAMELEN];
87197 struct xt_table *t;
87198 int ret;
87199
87200 - if (*len != sizeof(struct arpt_getinfo)) {
87201 - duprintf("length %u != %Zu\n", *len,
87202 + if (len != sizeof(struct arpt_getinfo)) {
87203 + duprintf("length %u != %Zu\n", len,
87204 sizeof(struct arpt_getinfo));
87205 return -EINVAL;
87206 }
87207 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87208 info.size = private->size;
87209 strcpy(info.name, name);
87210
87211 - if (copy_to_user(user, &info, *len) != 0)
87212 + if (copy_to_user(user, &info, len) != 0)
87213 ret = -EFAULT;
87214 else
87215 ret = 0;
87216 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87217
87218 switch (cmd) {
87219 case ARPT_SO_GET_INFO:
87220 - ret = get_info(sock_net(sk), user, len, 1);
87221 + ret = get_info(sock_net(sk), user, *len, 1);
87222 break;
87223 case ARPT_SO_GET_ENTRIES:
87224 ret = compat_get_entries(sock_net(sk), user, len);
87225 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87226
87227 switch (cmd) {
87228 case ARPT_SO_GET_INFO:
87229 - ret = get_info(sock_net(sk), user, len, 0);
87230 + ret = get_info(sock_net(sk), user, *len, 0);
87231 break;
87232
87233 case ARPT_SO_GET_ENTRIES:
87234 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87235 index 17c5e06..1b91206 100644
87236 --- a/net/ipv4/netfilter/ip_tables.c
87237 +++ b/net/ipv4/netfilter/ip_tables.c
87238 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87239 #endif
87240
87241 static int get_info(struct net *net, void __user *user,
87242 - const int *len, int compat)
87243 + int len, int compat)
87244 {
87245 char name[XT_TABLE_MAXNAMELEN];
87246 struct xt_table *t;
87247 int ret;
87248
87249 - if (*len != sizeof(struct ipt_getinfo)) {
87250 - duprintf("length %u != %zu\n", *len,
87251 + if (len != sizeof(struct ipt_getinfo)) {
87252 + duprintf("length %u != %zu\n", len,
87253 sizeof(struct ipt_getinfo));
87254 return -EINVAL;
87255 }
87256 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87257 info.size = private->size;
87258 strcpy(info.name, name);
87259
87260 - if (copy_to_user(user, &info, *len) != 0)
87261 + if (copy_to_user(user, &info, len) != 0)
87262 ret = -EFAULT;
87263 else
87264 ret = 0;
87265 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87266
87267 switch (cmd) {
87268 case IPT_SO_GET_INFO:
87269 - ret = get_info(sock_net(sk), user, len, 1);
87270 + ret = get_info(sock_net(sk), user, *len, 1);
87271 break;
87272 case IPT_SO_GET_ENTRIES:
87273 ret = compat_get_entries(sock_net(sk), user, len);
87274 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87275
87276 switch (cmd) {
87277 case IPT_SO_GET_INFO:
87278 - ret = get_info(sock_net(sk), user, len, 0);
87279 + ret = get_info(sock_net(sk), user, *len, 0);
87280 break;
87281
87282 case IPT_SO_GET_ENTRIES:
87283 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87284 index dc454cc..5bb917f 100644
87285 --- a/net/ipv4/ping.c
87286 +++ b/net/ipv4/ping.c
87287 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87288 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87289 0, sock_i_ino(sp),
87290 atomic_read(&sp->sk_refcnt), sp,
87291 - atomic_read(&sp->sk_drops), len);
87292 + atomic_read_unchecked(&sp->sk_drops), len);
87293 }
87294
87295 static int ping_seq_show(struct seq_file *seq, void *v)
87296 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87297 index 6f08991..55867ad 100644
87298 --- a/net/ipv4/raw.c
87299 +++ b/net/ipv4/raw.c
87300 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87301 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87302 {
87303 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87304 - atomic_inc(&sk->sk_drops);
87305 + atomic_inc_unchecked(&sk->sk_drops);
87306 kfree_skb(skb);
87307 return NET_RX_DROP;
87308 }
87309 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87310
87311 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87312 {
87313 + struct icmp_filter filter;
87314 +
87315 if (optlen > sizeof(struct icmp_filter))
87316 optlen = sizeof(struct icmp_filter);
87317 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87318 + if (copy_from_user(&filter, optval, optlen))
87319 return -EFAULT;
87320 + raw_sk(sk)->filter = filter;
87321 return 0;
87322 }
87323
87324 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87325 {
87326 int len, ret = -EFAULT;
87327 + struct icmp_filter filter;
87328
87329 if (get_user(len, optlen))
87330 goto out;
87331 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87332 if (len > sizeof(struct icmp_filter))
87333 len = sizeof(struct icmp_filter);
87334 ret = -EFAULT;
87335 - if (put_user(len, optlen) ||
87336 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87337 + filter = raw_sk(sk)->filter;
87338 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87339 goto out;
87340 ret = 0;
87341 out: return ret;
87342 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87343 0, 0L, 0,
87344 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87345 0, sock_i_ino(sp),
87346 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87347 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87348 }
87349
87350 static int raw_seq_show(struct seq_file *seq, void *v)
87351 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87352 index a0fcc47..32e2c89 100644
87353 --- a/net/ipv4/route.c
87354 +++ b/net/ipv4/route.c
87355 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87356 .maxlen = sizeof(int),
87357 .mode = 0200,
87358 .proc_handler = ipv4_sysctl_rtcache_flush,
87359 + .extra1 = &init_net,
87360 },
87361 { },
87362 };
87363
87364 static __net_init int sysctl_route_net_init(struct net *net)
87365 {
87366 - struct ctl_table *tbl;
87367 + ctl_table_no_const *tbl = NULL;
87368
87369 - tbl = ipv4_route_flush_table;
87370 if (!net_eq(net, &init_net)) {
87371 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87372 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87373 if (tbl == NULL)
87374 goto err_dup;
87375
87376 /* Don't export sysctls to unprivileged users */
87377 if (net->user_ns != &init_user_ns)
87378 tbl[0].procname = NULL;
87379 - }
87380 - tbl[0].extra1 = net;
87381 + tbl[0].extra1 = net;
87382 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87383 + } else
87384 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87385
87386 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87387 if (net->ipv4.route_hdr == NULL)
87388 goto err_reg;
87389 return 0;
87390
87391 err_reg:
87392 - if (tbl != ipv4_route_flush_table)
87393 - kfree(tbl);
87394 + kfree(tbl);
87395 err_dup:
87396 return -ENOMEM;
87397 }
87398 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87399
87400 static __net_init int rt_genid_init(struct net *net)
87401 {
87402 - atomic_set(&net->rt_genid, 0);
87403 + atomic_set_unchecked(&net->rt_genid, 0);
87404 get_random_bytes(&net->ipv4.dev_addr_genid,
87405 sizeof(net->ipv4.dev_addr_genid));
87406 return 0;
87407 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87408 index d84400b..62e066e 100644
87409 --- a/net/ipv4/sysctl_net_ipv4.c
87410 +++ b/net/ipv4/sysctl_net_ipv4.c
87411 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87412 {
87413 int ret;
87414 int range[2];
87415 - ctl_table tmp = {
87416 + ctl_table_no_const tmp = {
87417 .data = &range,
87418 .maxlen = sizeof(range),
87419 .mode = table->mode,
87420 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87421 int ret;
87422 gid_t urange[2];
87423 kgid_t low, high;
87424 - ctl_table tmp = {
87425 + ctl_table_no_const tmp = {
87426 .data = &urange,
87427 .maxlen = sizeof(urange),
87428 .mode = table->mode,
87429 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87430 void __user *buffer, size_t *lenp, loff_t *ppos)
87431 {
87432 char val[TCP_CA_NAME_MAX];
87433 - ctl_table tbl = {
87434 + ctl_table_no_const tbl = {
87435 .data = val,
87436 .maxlen = TCP_CA_NAME_MAX,
87437 };
87438 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87439 void __user *buffer, size_t *lenp,
87440 loff_t *ppos)
87441 {
87442 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87443 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87444 int ret;
87445
87446 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87447 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87448 void __user *buffer, size_t *lenp,
87449 loff_t *ppos)
87450 {
87451 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87452 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87453 int ret;
87454
87455 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87456 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87457 struct mem_cgroup *memcg;
87458 #endif
87459
87460 - ctl_table tmp = {
87461 + ctl_table_no_const tmp = {
87462 .data = &vec,
87463 .maxlen = sizeof(vec),
87464 .mode = ctl->mode,
87465 };
87466
87467 if (!write) {
87468 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87469 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87470 + ctl_table_no_const tcp_mem = *ctl;
87471 +
87472 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87473 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87474 }
87475
87476 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87477 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87478 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87479 size_t *lenp, loff_t *ppos)
87480 {
87481 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87482 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87483 struct tcp_fastopen_context *ctxt;
87484 int ret;
87485 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87486 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87487 },
87488 {
87489 .procname = "ip_local_reserved_ports",
87490 - .data = NULL, /* initialized in sysctl_ipv4_init */
87491 + .data = sysctl_local_reserved_ports,
87492 .maxlen = 65536,
87493 .mode = 0644,
87494 .proc_handler = proc_do_large_bitmap,
87495 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87496
87497 static __net_init int ipv4_sysctl_init_net(struct net *net)
87498 {
87499 - struct ctl_table *table;
87500 + ctl_table_no_const *table = NULL;
87501
87502 - table = ipv4_net_table;
87503 if (!net_eq(net, &init_net)) {
87504 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87505 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87506 if (table == NULL)
87507 goto err_alloc;
87508
87509 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87510
87511 tcp_init_mem(net);
87512
87513 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87514 + if (!net_eq(net, &init_net))
87515 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87516 + else
87517 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87518 if (net->ipv4.ipv4_hdr == NULL)
87519 goto err_reg;
87520
87521 return 0;
87522
87523 err_reg:
87524 - if (!net_eq(net, &init_net))
87525 - kfree(table);
87526 + kfree(table);
87527 err_alloc:
87528 return -ENOMEM;
87529 }
87530 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87531 static __init int sysctl_ipv4_init(void)
87532 {
87533 struct ctl_table_header *hdr;
87534 - struct ctl_table *i;
87535 -
87536 - for (i = ipv4_table; i->procname; i++) {
87537 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87538 - i->data = sysctl_local_reserved_ports;
87539 - break;
87540 - }
87541 - }
87542 - if (!i->procname)
87543 - return -EINVAL;
87544
87545 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87546 if (hdr == NULL)
87547 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87548 index b4e8b79..617d6aa 100644
87549 --- a/net/ipv4/tcp_input.c
87550 +++ b/net/ipv4/tcp_input.c
87551 @@ -4737,7 +4737,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87552 * simplifies code)
87553 */
87554 static void
87555 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87556 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87557 struct sk_buff *head, struct sk_buff *tail,
87558 u32 start, u32 end)
87559 {
87560 @@ -5849,6 +5849,7 @@ discard:
87561 tcp_paws_reject(&tp->rx_opt, 0))
87562 goto discard_and_undo;
87563
87564 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87565 if (th->syn) {
87566 /* We see SYN without ACK. It is attempt of
87567 * simultaneous connect with crossed SYNs.
87568 @@ -5899,6 +5900,7 @@ discard:
87569 goto discard;
87570 #endif
87571 }
87572 +#endif
87573 /* "fifth, if neither of the SYN or RST bits is set then
87574 * drop the segment and return."
87575 */
87576 @@ -5943,7 +5945,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87577 goto discard;
87578
87579 if (th->syn) {
87580 - if (th->fin)
87581 + if (th->fin || th->urg || th->psh)
87582 goto discard;
87583 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87584 return 1;
87585 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87586 index d9130a9..00328ff 100644
87587 --- a/net/ipv4/tcp_ipv4.c
87588 +++ b/net/ipv4/tcp_ipv4.c
87589 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87590 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87591
87592
87593 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87594 +extern int grsec_enable_blackhole;
87595 +#endif
87596 +
87597 #ifdef CONFIG_TCP_MD5SIG
87598 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87599 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87600 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87601 return 0;
87602
87603 reset:
87604 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87605 + if (!grsec_enable_blackhole)
87606 +#endif
87607 tcp_v4_send_reset(rsk, skb);
87608 discard:
87609 kfree_skb(skb);
87610 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87611 TCP_SKB_CB(skb)->sacked = 0;
87612
87613 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87614 - if (!sk)
87615 + if (!sk) {
87616 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87617 + ret = 1;
87618 +#endif
87619 goto no_tcp_socket;
87620 -
87621 + }
87622 process:
87623 - if (sk->sk_state == TCP_TIME_WAIT)
87624 + if (sk->sk_state == TCP_TIME_WAIT) {
87625 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87626 + ret = 2;
87627 +#endif
87628 goto do_time_wait;
87629 + }
87630
87631 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87632 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87633 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87634 bad_packet:
87635 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87636 } else {
87637 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87638 + if (!grsec_enable_blackhole || (ret == 1 &&
87639 + (skb->dev->flags & IFF_LOOPBACK)))
87640 +#endif
87641 tcp_v4_send_reset(NULL, skb);
87642 }
87643
87644 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87645 index f35f2df..ccb5ca6 100644
87646 --- a/net/ipv4/tcp_minisocks.c
87647 +++ b/net/ipv4/tcp_minisocks.c
87648 @@ -27,6 +27,10 @@
87649 #include <net/inet_common.h>
87650 #include <net/xfrm.h>
87651
87652 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87653 +extern int grsec_enable_blackhole;
87654 +#endif
87655 +
87656 int sysctl_tcp_syncookies __read_mostly = 1;
87657 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87658
87659 @@ -742,7 +746,10 @@ embryonic_reset:
87660 * avoid becoming vulnerable to outside attack aiming at
87661 * resetting legit local connections.
87662 */
87663 - req->rsk_ops->send_reset(sk, skb);
87664 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87665 + if (!grsec_enable_blackhole)
87666 +#endif
87667 + req->rsk_ops->send_reset(sk, skb);
87668 } else if (fastopen) { /* received a valid RST pkt */
87669 reqsk_fastopen_remove(sk, req, true);
87670 tcp_reset(sk);
87671 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87672 index 4526fe6..1a34e43 100644
87673 --- a/net/ipv4/tcp_probe.c
87674 +++ b/net/ipv4/tcp_probe.c
87675 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87676 if (cnt + width >= len)
87677 break;
87678
87679 - if (copy_to_user(buf + cnt, tbuf, width))
87680 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87681 return -EFAULT;
87682 cnt += width;
87683 }
87684 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87685 index b78aac3..e18230b 100644
87686 --- a/net/ipv4/tcp_timer.c
87687 +++ b/net/ipv4/tcp_timer.c
87688 @@ -22,6 +22,10 @@
87689 #include <linux/gfp.h>
87690 #include <net/tcp.h>
87691
87692 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87693 +extern int grsec_lastack_retries;
87694 +#endif
87695 +
87696 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87697 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87698 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87699 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87700 }
87701 }
87702
87703 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87704 + if ((sk->sk_state == TCP_LAST_ACK) &&
87705 + (grsec_lastack_retries > 0) &&
87706 + (grsec_lastack_retries < retry_until))
87707 + retry_until = grsec_lastack_retries;
87708 +#endif
87709 +
87710 if (retransmits_timed_out(sk, retry_until,
87711 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87712 /* Has it gone just too far? */
87713 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87714 index 1f4d405..3524677 100644
87715 --- a/net/ipv4/udp.c
87716 +++ b/net/ipv4/udp.c
87717 @@ -87,6 +87,7 @@
87718 #include <linux/types.h>
87719 #include <linux/fcntl.h>
87720 #include <linux/module.h>
87721 +#include <linux/security.h>
87722 #include <linux/socket.h>
87723 #include <linux/sockios.h>
87724 #include <linux/igmp.h>
87725 @@ -111,6 +112,10 @@
87726 #include <trace/events/skb.h>
87727 #include "udp_impl.h"
87728
87729 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87730 +extern int grsec_enable_blackhole;
87731 +#endif
87732 +
87733 struct udp_table udp_table __read_mostly;
87734 EXPORT_SYMBOL(udp_table);
87735
87736 @@ -569,6 +574,9 @@ found:
87737 return s;
87738 }
87739
87740 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87741 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87742 +
87743 /*
87744 * This routine is called by the ICMP module when it gets some
87745 * sort of error condition. If err < 0 then the socket should
87746 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87747 dport = usin->sin_port;
87748 if (dport == 0)
87749 return -EINVAL;
87750 +
87751 + err = gr_search_udp_sendmsg(sk, usin);
87752 + if (err)
87753 + return err;
87754 } else {
87755 if (sk->sk_state != TCP_ESTABLISHED)
87756 return -EDESTADDRREQ;
87757 +
87758 + err = gr_search_udp_sendmsg(sk, NULL);
87759 + if (err)
87760 + return err;
87761 +
87762 daddr = inet->inet_daddr;
87763 dport = inet->inet_dport;
87764 /* Open fast path for connected socket.
87765 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87766 udp_lib_checksum_complete(skb)) {
87767 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87768 IS_UDPLITE(sk));
87769 - atomic_inc(&sk->sk_drops);
87770 + atomic_inc_unchecked(&sk->sk_drops);
87771 __skb_unlink(skb, rcvq);
87772 __skb_queue_tail(&list_kill, skb);
87773 }
87774 @@ -1194,6 +1211,10 @@ try_again:
87775 if (!skb)
87776 goto out;
87777
87778 + err = gr_search_udp_recvmsg(sk, skb);
87779 + if (err)
87780 + goto out_free;
87781 +
87782 ulen = skb->len - sizeof(struct udphdr);
87783 copied = len;
87784 if (copied > ulen)
87785 @@ -1227,7 +1248,7 @@ try_again:
87786 if (unlikely(err)) {
87787 trace_kfree_skb(skb, udp_recvmsg);
87788 if (!peeked) {
87789 - atomic_inc(&sk->sk_drops);
87790 + atomic_inc_unchecked(&sk->sk_drops);
87791 UDP_INC_STATS_USER(sock_net(sk),
87792 UDP_MIB_INERRORS, is_udplite);
87793 }
87794 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87795
87796 drop:
87797 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87798 - atomic_inc(&sk->sk_drops);
87799 + atomic_inc_unchecked(&sk->sk_drops);
87800 kfree_skb(skb);
87801 return -1;
87802 }
87803 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87804 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87805
87806 if (!skb1) {
87807 - atomic_inc(&sk->sk_drops);
87808 + atomic_inc_unchecked(&sk->sk_drops);
87809 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87810 IS_UDPLITE(sk));
87811 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87812 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87813 goto csum_error;
87814
87815 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87816 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87817 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87818 +#endif
87819 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87820
87821 /*
87822 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87823 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87824 0, sock_i_ino(sp),
87825 atomic_read(&sp->sk_refcnt), sp,
87826 - atomic_read(&sp->sk_drops), len);
87827 + atomic_read_unchecked(&sp->sk_drops), len);
87828 }
87829
87830 int udp4_seq_show(struct seq_file *seq, void *v)
87831 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87832 index e8676c2..0a164f6 100644
87833 --- a/net/ipv6/addrconf.c
87834 +++ b/net/ipv6/addrconf.c
87835 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87836 p.iph.ihl = 5;
87837 p.iph.protocol = IPPROTO_IPV6;
87838 p.iph.ttl = 64;
87839 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87840 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87841
87842 if (ops->ndo_do_ioctl) {
87843 mm_segment_t oldfs = get_fs();
87844 @@ -4415,7 +4415,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87845 int *valp = ctl->data;
87846 int val = *valp;
87847 loff_t pos = *ppos;
87848 - ctl_table lctl;
87849 + ctl_table_no_const lctl;
87850 int ret;
87851
87852 /*
87853 @@ -4497,7 +4497,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87854 int *valp = ctl->data;
87855 int val = *valp;
87856 loff_t pos = *ppos;
87857 - ctl_table lctl;
87858 + ctl_table_no_const lctl;
87859 int ret;
87860
87861 /*
87862 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87863 index fff5bdd..15194fb 100644
87864 --- a/net/ipv6/icmp.c
87865 +++ b/net/ipv6/icmp.c
87866 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87867
87868 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87869 {
87870 - struct ctl_table *table;
87871 + ctl_table_no_const *table;
87872
87873 table = kmemdup(ipv6_icmp_table_template,
87874 sizeof(ipv6_icmp_table_template),
87875 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87876 index 131dd09..f7ed64f 100644
87877 --- a/net/ipv6/ip6_gre.c
87878 +++ b/net/ipv6/ip6_gre.c
87879 @@ -73,7 +73,7 @@ struct ip6gre_net {
87880 struct net_device *fb_tunnel_dev;
87881 };
87882
87883 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87884 +static struct rtnl_link_ops ip6gre_link_ops;
87885 static int ip6gre_tunnel_init(struct net_device *dev);
87886 static void ip6gre_tunnel_setup(struct net_device *dev);
87887 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87888 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87889 }
87890
87891
87892 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87893 +static struct inet6_protocol ip6gre_protocol = {
87894 .handler = ip6gre_rcv,
87895 .err_handler = ip6gre_err,
87896 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87897 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87898 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87899 };
87900
87901 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87902 +static struct rtnl_link_ops ip6gre_link_ops = {
87903 .kind = "ip6gre",
87904 .maxtype = IFLA_GRE_MAX,
87905 .policy = ip6gre_policy,
87906 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87907 .fill_info = ip6gre_fill_info,
87908 };
87909
87910 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87911 +static struct rtnl_link_ops ip6gre_tap_ops = {
87912 .kind = "ip6gretap",
87913 .maxtype = IFLA_GRE_MAX,
87914 .policy = ip6gre_policy,
87915 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87916 index a14f28b..b4b8956 100644
87917 --- a/net/ipv6/ip6_tunnel.c
87918 +++ b/net/ipv6/ip6_tunnel.c
87919 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87920
87921 static int ip6_tnl_dev_init(struct net_device *dev);
87922 static void ip6_tnl_dev_setup(struct net_device *dev);
87923 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87924 +static struct rtnl_link_ops ip6_link_ops;
87925
87926 static int ip6_tnl_net_id __read_mostly;
87927 struct ip6_tnl_net {
87928 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87929 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87930 };
87931
87932 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87933 +static struct rtnl_link_ops ip6_link_ops = {
87934 .kind = "ip6tnl",
87935 .maxtype = IFLA_IPTUN_MAX,
87936 .policy = ip6_tnl_policy,
87937 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87938 index d1e2e8e..51c19ae 100644
87939 --- a/net/ipv6/ipv6_sockglue.c
87940 +++ b/net/ipv6/ipv6_sockglue.c
87941 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87942 if (sk->sk_type != SOCK_STREAM)
87943 return -ENOPROTOOPT;
87944
87945 - msg.msg_control = optval;
87946 + msg.msg_control = (void __force_kernel *)optval;
87947 msg.msg_controllen = len;
87948 msg.msg_flags = flags;
87949
87950 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87951 index 125a90d..2a11f36 100644
87952 --- a/net/ipv6/netfilter/ip6_tables.c
87953 +++ b/net/ipv6/netfilter/ip6_tables.c
87954 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87955 #endif
87956
87957 static int get_info(struct net *net, void __user *user,
87958 - const int *len, int compat)
87959 + int len, int compat)
87960 {
87961 char name[XT_TABLE_MAXNAMELEN];
87962 struct xt_table *t;
87963 int ret;
87964
87965 - if (*len != sizeof(struct ip6t_getinfo)) {
87966 - duprintf("length %u != %zu\n", *len,
87967 + if (len != sizeof(struct ip6t_getinfo)) {
87968 + duprintf("length %u != %zu\n", len,
87969 sizeof(struct ip6t_getinfo));
87970 return -EINVAL;
87971 }
87972 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87973 info.size = private->size;
87974 strcpy(info.name, name);
87975
87976 - if (copy_to_user(user, &info, *len) != 0)
87977 + if (copy_to_user(user, &info, len) != 0)
87978 ret = -EFAULT;
87979 else
87980 ret = 0;
87981 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87982
87983 switch (cmd) {
87984 case IP6T_SO_GET_INFO:
87985 - ret = get_info(sock_net(sk), user, len, 1);
87986 + ret = get_info(sock_net(sk), user, *len, 1);
87987 break;
87988 case IP6T_SO_GET_ENTRIES:
87989 ret = compat_get_entries(sock_net(sk), user, len);
87990 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87991
87992 switch (cmd) {
87993 case IP6T_SO_GET_INFO:
87994 - ret = get_info(sock_net(sk), user, len, 0);
87995 + ret = get_info(sock_net(sk), user, *len, 0);
87996 break;
87997
87998 case IP6T_SO_GET_ENTRIES:
87999 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
88000 index 83acc14..0ea43c7 100644
88001 --- a/net/ipv6/netfilter/ip6t_NPT.c
88002 +++ b/net/ipv6/netfilter/ip6t_NPT.c
88003 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
88004 if (pfx_len - i >= 32)
88005 mask = 0;
88006 else
88007 - mask = htonl(~((1 << (pfx_len - i)) - 1));
88008 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
88009
88010 idx = i / 32;
88011 addr->s6_addr32[idx] &= mask;
88012 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88013 index 2f3a018..8bca195 100644
88014 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88015 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88016 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88017
88018 static int nf_ct_frag6_sysctl_register(struct net *net)
88019 {
88020 - struct ctl_table *table;
88021 + ctl_table_no_const *table = NULL;
88022 struct ctl_table_header *hdr;
88023
88024 - table = nf_ct_frag6_sysctl_table;
88025 if (!net_eq(net, &init_net)) {
88026 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88027 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88028 GFP_KERNEL);
88029 if (table == NULL)
88030 goto err_alloc;
88031 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88032 table[0].data = &net->ipv6.frags.high_thresh;
88033 table[1].data = &net->ipv6.frags.low_thresh;
88034 table[2].data = &net->ipv6.frags.timeout;
88035 - }
88036 -
88037 - hdr = register_net_sysctl(net, "net/netfilter", table);
88038 + hdr = register_net_sysctl(net, "net/netfilter", table);
88039 + } else
88040 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88041 if (hdr == NULL)
88042 goto err_reg;
88043
88044 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88045 return 0;
88046
88047 err_reg:
88048 - if (!net_eq(net, &init_net))
88049 - kfree(table);
88050 + kfree(table);
88051 err_alloc:
88052 return -ENOMEM;
88053 }
88054 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88055 index 70fa814..d70c28c 100644
88056 --- a/net/ipv6/raw.c
88057 +++ b/net/ipv6/raw.c
88058 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88059 {
88060 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88061 skb_checksum_complete(skb)) {
88062 - atomic_inc(&sk->sk_drops);
88063 + atomic_inc_unchecked(&sk->sk_drops);
88064 kfree_skb(skb);
88065 return NET_RX_DROP;
88066 }
88067 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88068 struct raw6_sock *rp = raw6_sk(sk);
88069
88070 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88071 - atomic_inc(&sk->sk_drops);
88072 + atomic_inc_unchecked(&sk->sk_drops);
88073 kfree_skb(skb);
88074 return NET_RX_DROP;
88075 }
88076 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88077
88078 if (inet->hdrincl) {
88079 if (skb_checksum_complete(skb)) {
88080 - atomic_inc(&sk->sk_drops);
88081 + atomic_inc_unchecked(&sk->sk_drops);
88082 kfree_skb(skb);
88083 return NET_RX_DROP;
88084 }
88085 @@ -604,7 +604,7 @@ out:
88086 return err;
88087 }
88088
88089 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88090 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88091 struct flowi6 *fl6, struct dst_entry **dstp,
88092 unsigned int flags)
88093 {
88094 @@ -916,12 +916,15 @@ do_confirm:
88095 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88096 char __user *optval, int optlen)
88097 {
88098 + struct icmp6_filter filter;
88099 +
88100 switch (optname) {
88101 case ICMPV6_FILTER:
88102 if (optlen > sizeof(struct icmp6_filter))
88103 optlen = sizeof(struct icmp6_filter);
88104 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88105 + if (copy_from_user(&filter, optval, optlen))
88106 return -EFAULT;
88107 + raw6_sk(sk)->filter = filter;
88108 return 0;
88109 default:
88110 return -ENOPROTOOPT;
88111 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88112 char __user *optval, int __user *optlen)
88113 {
88114 int len;
88115 + struct icmp6_filter filter;
88116
88117 switch (optname) {
88118 case ICMPV6_FILTER:
88119 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88120 len = sizeof(struct icmp6_filter);
88121 if (put_user(len, optlen))
88122 return -EFAULT;
88123 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88124 + filter = raw6_sk(sk)->filter;
88125 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88126 return -EFAULT;
88127 return 0;
88128 default:
88129 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88130 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88131 0,
88132 sock_i_ino(sp),
88133 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88134 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88135 }
88136
88137 static int raw6_seq_show(struct seq_file *seq, void *v)
88138 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88139 index 7a610a6..202dff9 100644
88140 --- a/net/ipv6/reassembly.c
88141 +++ b/net/ipv6/reassembly.c
88142 @@ -617,12 +617,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88143
88144 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88145 {
88146 - struct ctl_table *table;
88147 + ctl_table_no_const *table = NULL;
88148 struct ctl_table_header *hdr;
88149
88150 - table = ip6_frags_ns_ctl_table;
88151 if (!net_eq(net, &init_net)) {
88152 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88153 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88154 if (table == NULL)
88155 goto err_alloc;
88156
88157 @@ -633,9 +632,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88158 /* Don't export sysctls to unprivileged users */
88159 if (net->user_ns != &init_user_ns)
88160 table[0].procname = NULL;
88161 - }
88162 + hdr = register_net_sysctl(net, "net/ipv6", table);
88163 + } else
88164 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88165
88166 - hdr = register_net_sysctl(net, "net/ipv6", table);
88167 if (hdr == NULL)
88168 goto err_reg;
88169
88170 @@ -643,8 +643,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88171 return 0;
88172
88173 err_reg:
88174 - if (!net_eq(net, &init_net))
88175 - kfree(table);
88176 + kfree(table);
88177 err_alloc:
88178 return -ENOMEM;
88179 }
88180 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88181 index 5845613..3af8fc7 100644
88182 --- a/net/ipv6/route.c
88183 +++ b/net/ipv6/route.c
88184 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88185
88186 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88187 {
88188 - struct ctl_table *table;
88189 + ctl_table_no_const *table;
88190
88191 table = kmemdup(ipv6_route_table_template,
88192 sizeof(ipv6_route_table_template),
88193 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88194 index cfba99b..20ca511 100644
88195 --- a/net/ipv6/sit.c
88196 +++ b/net/ipv6/sit.c
88197 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88198 static int ipip6_tunnel_init(struct net_device *dev);
88199 static void ipip6_tunnel_setup(struct net_device *dev);
88200 static void ipip6_dev_free(struct net_device *dev);
88201 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88202 +static struct rtnl_link_ops sit_link_ops;
88203
88204 static int sit_net_id __read_mostly;
88205 struct sit_net {
88206 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88207 #endif
88208 };
88209
88210 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88211 +static struct rtnl_link_ops sit_link_ops = {
88212 .kind = "sit",
88213 .maxtype = IFLA_IPTUN_MAX,
88214 .policy = ipip6_policy,
88215 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88216 index e85c48b..b8268d3 100644
88217 --- a/net/ipv6/sysctl_net_ipv6.c
88218 +++ b/net/ipv6/sysctl_net_ipv6.c
88219 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88220
88221 static int __net_init ipv6_sysctl_net_init(struct net *net)
88222 {
88223 - struct ctl_table *ipv6_table;
88224 + ctl_table_no_const *ipv6_table;
88225 struct ctl_table *ipv6_route_table;
88226 struct ctl_table *ipv6_icmp_table;
88227 int err;
88228 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88229 index 89dfedd..f122ba5 100644
88230 --- a/net/ipv6/tcp_ipv6.c
88231 +++ b/net/ipv6/tcp_ipv6.c
88232 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88233 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88234 }
88235
88236 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88237 +extern int grsec_enable_blackhole;
88238 +#endif
88239 +
88240 static void tcp_v6_hash(struct sock *sk)
88241 {
88242 if (sk->sk_state != TCP_CLOSE) {
88243 @@ -1441,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88244 return 0;
88245
88246 reset:
88247 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88248 + if (!grsec_enable_blackhole)
88249 +#endif
88250 tcp_v6_send_reset(sk, skb);
88251 discard:
88252 if (opt_skb)
88253 @@ -1522,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88254 TCP_SKB_CB(skb)->sacked = 0;
88255
88256 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88257 - if (!sk)
88258 + if (!sk) {
88259 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88260 + ret = 1;
88261 +#endif
88262 goto no_tcp_socket;
88263 + }
88264
88265 process:
88266 - if (sk->sk_state == TCP_TIME_WAIT)
88267 + if (sk->sk_state == TCP_TIME_WAIT) {
88268 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88269 + ret = 2;
88270 +#endif
88271 goto do_time_wait;
88272 + }
88273
88274 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88275 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88276 @@ -1576,6 +1591,10 @@ no_tcp_socket:
88277 bad_packet:
88278 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88279 } else {
88280 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88281 + if (!grsec_enable_blackhole || (ret == 1 &&
88282 + (skb->dev->flags & IFF_LOOPBACK)))
88283 +#endif
88284 tcp_v6_send_reset(NULL, skb);
88285 }
88286
88287 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88288 index fb08329..2d6919e 100644
88289 --- a/net/ipv6/udp.c
88290 +++ b/net/ipv6/udp.c
88291 @@ -51,6 +51,10 @@
88292 #include <trace/events/skb.h>
88293 #include "udp_impl.h"
88294
88295 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88296 +extern int grsec_enable_blackhole;
88297 +#endif
88298 +
88299 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88300 {
88301 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88302 @@ -395,7 +399,7 @@ try_again:
88303 if (unlikely(err)) {
88304 trace_kfree_skb(skb, udpv6_recvmsg);
88305 if (!peeked) {
88306 - atomic_inc(&sk->sk_drops);
88307 + atomic_inc_unchecked(&sk->sk_drops);
88308 if (is_udp4)
88309 UDP_INC_STATS_USER(sock_net(sk),
88310 UDP_MIB_INERRORS,
88311 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88312 return rc;
88313 drop:
88314 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88315 - atomic_inc(&sk->sk_drops);
88316 + atomic_inc_unchecked(&sk->sk_drops);
88317 kfree_skb(skb);
88318 return -1;
88319 }
88320 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88321 if (likely(skb1 == NULL))
88322 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88323 if (!skb1) {
88324 - atomic_inc(&sk->sk_drops);
88325 + atomic_inc_unchecked(&sk->sk_drops);
88326 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88327 IS_UDPLITE(sk));
88328 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88329 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88330 goto discard;
88331
88332 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88333 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88334 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88335 +#endif
88336 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88337
88338 kfree_skb(skb);
88339 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88340 0,
88341 sock_i_ino(sp),
88342 atomic_read(&sp->sk_refcnt), sp,
88343 - atomic_read(&sp->sk_drops));
88344 + atomic_read_unchecked(&sp->sk_drops));
88345 }
88346
88347 int udp6_seq_show(struct seq_file *seq, void *v)
88348 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88349 index a68c88c..d55b0c5 100644
88350 --- a/net/irda/ircomm/ircomm_tty.c
88351 +++ b/net/irda/ircomm/ircomm_tty.c
88352 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88353 add_wait_queue(&port->open_wait, &wait);
88354
88355 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88356 - __FILE__, __LINE__, tty->driver->name, port->count);
88357 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88358
88359 spin_lock_irqsave(&port->lock, flags);
88360 if (!tty_hung_up_p(filp)) {
88361 extra_count = 1;
88362 - port->count--;
88363 + atomic_dec(&port->count);
88364 }
88365 spin_unlock_irqrestore(&port->lock, flags);
88366 port->blocked_open++;
88367 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88368 }
88369
88370 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88371 - __FILE__, __LINE__, tty->driver->name, port->count);
88372 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88373
88374 schedule();
88375 }
88376 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88377 if (extra_count) {
88378 /* ++ is not atomic, so this should be protected - Jean II */
88379 spin_lock_irqsave(&port->lock, flags);
88380 - port->count++;
88381 + atomic_inc(&port->count);
88382 spin_unlock_irqrestore(&port->lock, flags);
88383 }
88384 port->blocked_open--;
88385
88386 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88387 - __FILE__, __LINE__, tty->driver->name, port->count);
88388 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88389
88390 if (!retval)
88391 port->flags |= ASYNC_NORMAL_ACTIVE;
88392 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88393
88394 /* ++ is not atomic, so this should be protected - Jean II */
88395 spin_lock_irqsave(&self->port.lock, flags);
88396 - self->port.count++;
88397 + atomic_inc(&self->port.count);
88398 spin_unlock_irqrestore(&self->port.lock, flags);
88399 tty_port_tty_set(&self->port, tty);
88400
88401 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88402 - self->line, self->port.count);
88403 + self->line, atomic_read(&self->port.count));
88404
88405 /* Not really used by us, but lets do it anyway */
88406 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88407 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88408 tty_kref_put(port->tty);
88409 }
88410 port->tty = NULL;
88411 - port->count = 0;
88412 + atomic_set(&port->count, 0);
88413 spin_unlock_irqrestore(&port->lock, flags);
88414
88415 wake_up_interruptible(&port->open_wait);
88416 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88417 seq_putc(m, '\n');
88418
88419 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88420 - seq_printf(m, "Open count: %d\n", self->port.count);
88421 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88422 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88423 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88424
88425 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88426 index e71e85b..29340a9 100644
88427 --- a/net/irda/iriap.c
88428 +++ b/net/irda/iriap.c
88429 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88430 /* case CS_ISO_8859_9: */
88431 /* case CS_UNICODE: */
88432 default:
88433 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88434 - __func__, ias_charset_types[charset]);
88435 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88436 + __func__, charset,
88437 + charset < ARRAY_SIZE(ias_charset_types) ?
88438 + ias_charset_types[charset] :
88439 + "(unknown)");
88440
88441 /* Aborting, close connection! */
88442 iriap_disconnect_request(self);
88443 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88444 index 625bc50..ac6eef9 100644
88445 --- a/net/iucv/af_iucv.c
88446 +++ b/net/iucv/af_iucv.c
88447 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88448
88449 write_lock_bh(&iucv_sk_list.lock);
88450
88451 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88452 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88453 while (__iucv_get_sock_by_name(name)) {
88454 sprintf(name, "%08x",
88455 - atomic_inc_return(&iucv_sk_list.autobind_name));
88456 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88457 }
88458
88459 write_unlock_bh(&iucv_sk_list.lock);
88460 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88461 index df08250..02021fe 100644
88462 --- a/net/iucv/iucv.c
88463 +++ b/net/iucv/iucv.c
88464 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88465 return NOTIFY_OK;
88466 }
88467
88468 -static struct notifier_block __refdata iucv_cpu_notifier = {
88469 +static struct notifier_block iucv_cpu_notifier = {
88470 .notifier_call = iucv_cpu_notify,
88471 };
88472
88473 diff --git a/net/key/af_key.c b/net/key/af_key.c
88474 index 5b426a6..970032b 100644
88475 --- a/net/key/af_key.c
88476 +++ b/net/key/af_key.c
88477 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88478 static u32 get_acqseq(void)
88479 {
88480 u32 res;
88481 - static atomic_t acqseq;
88482 + static atomic_unchecked_t acqseq;
88483
88484 do {
88485 - res = atomic_inc_return(&acqseq);
88486 + res = atomic_inc_return_unchecked(&acqseq);
88487 } while (!res);
88488 return res;
88489 }
88490 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88491 index 49c48c6..9e72ff4 100644
88492 --- a/net/mac80211/cfg.c
88493 +++ b/net/mac80211/cfg.c
88494 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88495 ret = ieee80211_vif_use_channel(sdata, chandef,
88496 IEEE80211_CHANCTX_EXCLUSIVE);
88497 }
88498 - } else if (local->open_count == local->monitors) {
88499 + } else if (local_read(&local->open_count) == local->monitors) {
88500 local->_oper_channel = chandef->chan;
88501 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88502 ieee80211_hw_config(local, 0);
88503 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88504 else
88505 local->probe_req_reg--;
88506
88507 - if (!local->open_count)
88508 + if (!local_read(&local->open_count))
88509 break;
88510
88511 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88512 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88513 index 55d8f89..bec0c2b 100644
88514 --- a/net/mac80211/ieee80211_i.h
88515 +++ b/net/mac80211/ieee80211_i.h
88516 @@ -28,6 +28,7 @@
88517 #include <net/ieee80211_radiotap.h>
88518 #include <net/cfg80211.h>
88519 #include <net/mac80211.h>
88520 +#include <asm/local.h>
88521 #include "key.h"
88522 #include "sta_info.h"
88523 #include "debug.h"
88524 @@ -910,7 +911,7 @@ struct ieee80211_local {
88525 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88526 spinlock_t queue_stop_reason_lock;
88527
88528 - int open_count;
88529 + local_t open_count;
88530 int monitors, cooked_mntrs;
88531 /* number of interfaces with corresponding FIF_ flags */
88532 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88533 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88534 index 8be854e..ad72a69 100644
88535 --- a/net/mac80211/iface.c
88536 +++ b/net/mac80211/iface.c
88537 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88538 break;
88539 }
88540
88541 - if (local->open_count == 0) {
88542 + if (local_read(&local->open_count) == 0) {
88543 res = drv_start(local);
88544 if (res)
88545 goto err_del_bss;
88546 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88547 break;
88548 }
88549
88550 - if (local->monitors == 0 && local->open_count == 0) {
88551 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88552 res = ieee80211_add_virtual_monitor(local);
88553 if (res)
88554 goto err_stop;
88555 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88556 mutex_unlock(&local->mtx);
88557
88558 if (coming_up)
88559 - local->open_count++;
88560 + local_inc(&local->open_count);
88561
88562 if (hw_reconf_flags)
88563 ieee80211_hw_config(local, hw_reconf_flags);
88564 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88565 err_del_interface:
88566 drv_remove_interface(local, sdata);
88567 err_stop:
88568 - if (!local->open_count)
88569 + if (!local_read(&local->open_count))
88570 drv_stop(local);
88571 err_del_bss:
88572 sdata->bss = NULL;
88573 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88574 }
88575
88576 if (going_down)
88577 - local->open_count--;
88578 + local_dec(&local->open_count);
88579
88580 switch (sdata->vif.type) {
88581 case NL80211_IFTYPE_AP_VLAN:
88582 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88583
88584 ieee80211_recalc_ps(local, -1);
88585
88586 - if (local->open_count == 0) {
88587 + if (local_read(&local->open_count) == 0) {
88588 if (local->ops->napi_poll)
88589 napi_disable(&local->napi);
88590 ieee80211_clear_tx_pending(local);
88591 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88592 }
88593 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88594
88595 - if (local->monitors == local->open_count && local->monitors > 0)
88596 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88597 ieee80211_add_virtual_monitor(local);
88598 }
88599
88600 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88601 index 1b087ff..bf600e9 100644
88602 --- a/net/mac80211/main.c
88603 +++ b/net/mac80211/main.c
88604 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88605 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88606 IEEE80211_CONF_CHANGE_POWER);
88607
88608 - if (changed && local->open_count) {
88609 + if (changed && local_read(&local->open_count)) {
88610 ret = drv_config(local, changed);
88611 /*
88612 * Goal:
88613 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88614 index 64619f4..c497f0f 100644
88615 --- a/net/mac80211/pm.c
88616 +++ b/net/mac80211/pm.c
88617 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88618 struct sta_info *sta;
88619 struct ieee80211_chanctx *ctx;
88620
88621 - if (!local->open_count)
88622 + if (!local_read(&local->open_count))
88623 goto suspend;
88624
88625 ieee80211_scan_cancel(local);
88626 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88627 cancel_work_sync(&local->dynamic_ps_enable_work);
88628 del_timer_sync(&local->dynamic_ps_timer);
88629
88630 - local->wowlan = wowlan && local->open_count;
88631 + local->wowlan = wowlan && local_read(&local->open_count);
88632 if (local->wowlan) {
88633 int err = drv_suspend(local, wowlan);
88634 if (err < 0) {
88635 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88636 mutex_unlock(&local->chanctx_mtx);
88637
88638 /* stop hardware - this must stop RX */
88639 - if (local->open_count)
88640 + if (local_read(&local->open_count))
88641 ieee80211_stop_device(local);
88642
88643 suspend:
88644 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88645 index dd88381..eef4dd6 100644
88646 --- a/net/mac80211/rate.c
88647 +++ b/net/mac80211/rate.c
88648 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88649
88650 ASSERT_RTNL();
88651
88652 - if (local->open_count)
88653 + if (local_read(&local->open_count))
88654 return -EBUSY;
88655
88656 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88657 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88658 index c97a065..ff61928 100644
88659 --- a/net/mac80211/rc80211_pid_debugfs.c
88660 +++ b/net/mac80211/rc80211_pid_debugfs.c
88661 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88662
88663 spin_unlock_irqrestore(&events->lock, status);
88664
88665 - if (copy_to_user(buf, pb, p))
88666 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88667 return -EFAULT;
88668
88669 return p;
88670 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88671 index f11e8c5..08d0013 100644
88672 --- a/net/mac80211/util.c
88673 +++ b/net/mac80211/util.c
88674 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88675 }
88676 #endif
88677 /* everything else happens only if HW was up & running */
88678 - if (!local->open_count)
88679 + if (!local_read(&local->open_count))
88680 goto wake_up;
88681
88682 /*
88683 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88684 index 49e96df..63a51c3 100644
88685 --- a/net/netfilter/Kconfig
88686 +++ b/net/netfilter/Kconfig
88687 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88688
88689 To compile it as a module, choose M here. If unsure, say N.
88690
88691 +config NETFILTER_XT_MATCH_GRADM
88692 + tristate '"gradm" match support'
88693 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88694 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88695 + ---help---
88696 + The gradm match allows to match on grsecurity RBAC being enabled.
88697 + It is useful when iptables rules are applied early on bootup to
88698 + prevent connections to the machine (except from a trusted host)
88699 + while the RBAC system is disabled.
88700 +
88701 config NETFILTER_XT_MATCH_HASHLIMIT
88702 tristate '"hashlimit" match support'
88703 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88704 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88705 index 3259697..54d5393 100644
88706 --- a/net/netfilter/Makefile
88707 +++ b/net/netfilter/Makefile
88708 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88709 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88710 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88711 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88712 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88713 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88714 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88715 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88716 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88717 index 6d6d8f2..a676749 100644
88718 --- a/net/netfilter/ipset/ip_set_core.c
88719 +++ b/net/netfilter/ipset/ip_set_core.c
88720 @@ -1800,7 +1800,7 @@ done:
88721 return ret;
88722 }
88723
88724 -static struct nf_sockopt_ops so_set __read_mostly = {
88725 +static struct nf_sockopt_ops so_set = {
88726 .pf = PF_INET,
88727 .get_optmin = SO_IP_SET,
88728 .get_optmax = SO_IP_SET + 1,
88729 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88730 index 30e764a..c3b6a9d 100644
88731 --- a/net/netfilter/ipvs/ip_vs_conn.c
88732 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88733 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88734 /* Increase the refcnt counter of the dest */
88735 atomic_inc(&dest->refcnt);
88736
88737 - conn_flags = atomic_read(&dest->conn_flags);
88738 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88739 if (cp->protocol != IPPROTO_UDP)
88740 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88741 flags = cp->flags;
88742 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88743 atomic_set(&cp->refcnt, 1);
88744
88745 atomic_set(&cp->n_control, 0);
88746 - atomic_set(&cp->in_pkts, 0);
88747 + atomic_set_unchecked(&cp->in_pkts, 0);
88748
88749 atomic_inc(&ipvs->conn_count);
88750 if (flags & IP_VS_CONN_F_NO_CPORT)
88751 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88752
88753 /* Don't drop the entry if its number of incoming packets is not
88754 located in [0, 8] */
88755 - i = atomic_read(&cp->in_pkts);
88756 + i = atomic_read_unchecked(&cp->in_pkts);
88757 if (i > 8 || i < 0) return 0;
88758
88759 if (!todrop_rate[i]) return 0;
88760 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88761 index 47edf5a..235b07d 100644
88762 --- a/net/netfilter/ipvs/ip_vs_core.c
88763 +++ b/net/netfilter/ipvs/ip_vs_core.c
88764 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88765 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88766 /* do not touch skb anymore */
88767
88768 - atomic_inc(&cp->in_pkts);
88769 + atomic_inc_unchecked(&cp->in_pkts);
88770 ip_vs_conn_put(cp);
88771 return ret;
88772 }
88773 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88774 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88775 pkts = sysctl_sync_threshold(ipvs);
88776 else
88777 - pkts = atomic_add_return(1, &cp->in_pkts);
88778 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88779
88780 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88781 ip_vs_sync_conn(net, cp, pkts);
88782 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88783 index ec664cb..7f34a77 100644
88784 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88785 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88786 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88787 ip_vs_rs_hash(ipvs, dest);
88788 write_unlock_bh(&ipvs->rs_lock);
88789 }
88790 - atomic_set(&dest->conn_flags, conn_flags);
88791 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88792
88793 /* bind the service */
88794 if (!dest->svc) {
88795 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88796 * align with netns init in ip_vs_control_net_init()
88797 */
88798
88799 -static struct ctl_table vs_vars[] = {
88800 +static ctl_table_no_const vs_vars[] __read_only = {
88801 {
88802 .procname = "amemthresh",
88803 .maxlen = sizeof(int),
88804 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88805 " %-7s %-6d %-10d %-10d\n",
88806 &dest->addr.in6,
88807 ntohs(dest->port),
88808 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88809 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88810 atomic_read(&dest->weight),
88811 atomic_read(&dest->activeconns),
88812 atomic_read(&dest->inactconns));
88813 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88814 "%-7s %-6d %-10d %-10d\n",
88815 ntohl(dest->addr.ip),
88816 ntohs(dest->port),
88817 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88818 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88819 atomic_read(&dest->weight),
88820 atomic_read(&dest->activeconns),
88821 atomic_read(&dest->inactconns));
88822 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88823
88824 entry.addr = dest->addr.ip;
88825 entry.port = dest->port;
88826 - entry.conn_flags = atomic_read(&dest->conn_flags);
88827 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88828 entry.weight = atomic_read(&dest->weight);
88829 entry.u_threshold = dest->u_threshold;
88830 entry.l_threshold = dest->l_threshold;
88831 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88832 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88833 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88834 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88835 - (atomic_read(&dest->conn_flags) &
88836 + (atomic_read_unchecked(&dest->conn_flags) &
88837 IP_VS_CONN_F_FWD_MASK)) ||
88838 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88839 atomic_read(&dest->weight)) ||
88840 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88841 {
88842 int idx;
88843 struct netns_ipvs *ipvs = net_ipvs(net);
88844 - struct ctl_table *tbl;
88845 + ctl_table_no_const *tbl;
88846
88847 atomic_set(&ipvs->dropentry, 0);
88848 spin_lock_init(&ipvs->dropentry_lock);
88849 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88850 index fdd89b9..bd96aa9 100644
88851 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88852 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88853 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88854 * IPVS LBLC sysctl table
88855 */
88856 #ifdef CONFIG_SYSCTL
88857 -static ctl_table vs_vars_table[] = {
88858 +static ctl_table_no_const vs_vars_table[] __read_only = {
88859 {
88860 .procname = "lblc_expiration",
88861 .data = NULL,
88862 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88863 index c03b6a3..8ce3681 100644
88864 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88865 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88866 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88867 * IPVS LBLCR sysctl table
88868 */
88869
88870 -static ctl_table vs_vars_table[] = {
88871 +static ctl_table_no_const vs_vars_table[] __read_only = {
88872 {
88873 .procname = "lblcr_expiration",
88874 .data = NULL,
88875 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88876 index 44fd10c..2a163b3 100644
88877 --- a/net/netfilter/ipvs/ip_vs_sync.c
88878 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88879 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88880 cp = cp->control;
88881 if (cp) {
88882 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88883 - pkts = atomic_add_return(1, &cp->in_pkts);
88884 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88885 else
88886 pkts = sysctl_sync_threshold(ipvs);
88887 ip_vs_sync_conn(net, cp->control, pkts);
88888 @@ -758,7 +758,7 @@ control:
88889 if (!cp)
88890 return;
88891 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88892 - pkts = atomic_add_return(1, &cp->in_pkts);
88893 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88894 else
88895 pkts = sysctl_sync_threshold(ipvs);
88896 goto sloop;
88897 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88898
88899 if (opt)
88900 memcpy(&cp->in_seq, opt, sizeof(*opt));
88901 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88902 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88903 cp->state = state;
88904 cp->old_state = cp->state;
88905 /*
88906 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88907 index ee6b7a9..f9a89f6 100644
88908 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88909 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88910 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88911 else
88912 rc = NF_ACCEPT;
88913 /* do not touch skb anymore */
88914 - atomic_inc(&cp->in_pkts);
88915 + atomic_inc_unchecked(&cp->in_pkts);
88916 goto out;
88917 }
88918
88919 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88920 else
88921 rc = NF_ACCEPT;
88922 /* do not touch skb anymore */
88923 - atomic_inc(&cp->in_pkts);
88924 + atomic_inc_unchecked(&cp->in_pkts);
88925 goto out;
88926 }
88927
88928 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88929 index 7df424e..a527b02 100644
88930 --- a/net/netfilter/nf_conntrack_acct.c
88931 +++ b/net/netfilter/nf_conntrack_acct.c
88932 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88933 #ifdef CONFIG_SYSCTL
88934 static int nf_conntrack_acct_init_sysctl(struct net *net)
88935 {
88936 - struct ctl_table *table;
88937 + ctl_table_no_const *table;
88938
88939 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88940 GFP_KERNEL);
88941 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88942 index e4a0c4f..c263f28 100644
88943 --- a/net/netfilter/nf_conntrack_core.c
88944 +++ b/net/netfilter/nf_conntrack_core.c
88945 @@ -1529,6 +1529,10 @@ err_extend:
88946 #define DYING_NULLS_VAL ((1<<30)+1)
88947 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88948
88949 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88950 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88951 +#endif
88952 +
88953 static int nf_conntrack_init_net(struct net *net)
88954 {
88955 int ret;
88956 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88957 goto err_stat;
88958 }
88959
88960 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88961 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88962 +#else
88963 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88964 +#endif
88965 if (!net->ct.slabname) {
88966 ret = -ENOMEM;
88967 goto err_slabname;
88968 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88969 index faa978f..1afb18f 100644
88970 --- a/net/netfilter/nf_conntrack_ecache.c
88971 +++ b/net/netfilter/nf_conntrack_ecache.c
88972 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88973 #ifdef CONFIG_SYSCTL
88974 static int nf_conntrack_event_init_sysctl(struct net *net)
88975 {
88976 - struct ctl_table *table;
88977 + ctl_table_no_const *table;
88978
88979 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88980 GFP_KERNEL);
88981 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88982 index 884f2b3..d53b33a 100644
88983 --- a/net/netfilter/nf_conntrack_helper.c
88984 +++ b/net/netfilter/nf_conntrack_helper.c
88985 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88986
88987 static int nf_conntrack_helper_init_sysctl(struct net *net)
88988 {
88989 - struct ctl_table *table;
88990 + ctl_table_no_const *table;
88991
88992 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88993 GFP_KERNEL);
88994 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88995 index 51e928d..72a413a 100644
88996 --- a/net/netfilter/nf_conntrack_proto.c
88997 +++ b/net/netfilter/nf_conntrack_proto.c
88998 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88999
89000 static void
89001 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89002 - struct ctl_table **table,
89003 + ctl_table_no_const **table,
89004 unsigned int users)
89005 {
89006 if (users > 0)
89007 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89008 index e7185c6..4ad6c9c 100644
89009 --- a/net/netfilter/nf_conntrack_standalone.c
89010 +++ b/net/netfilter/nf_conntrack_standalone.c
89011 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89012
89013 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89014 {
89015 - struct ctl_table *table;
89016 + ctl_table_no_const *table;
89017
89018 if (net_eq(net, &init_net)) {
89019 nf_ct_netfilter_header =
89020 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89021 index 7ea8026..bc9512d 100644
89022 --- a/net/netfilter/nf_conntrack_timestamp.c
89023 +++ b/net/netfilter/nf_conntrack_timestamp.c
89024 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89025 #ifdef CONFIG_SYSCTL
89026 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89027 {
89028 - struct ctl_table *table;
89029 + ctl_table_no_const *table;
89030
89031 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89032 GFP_KERNEL);
89033 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89034 index 9e31269..bc4c1b7 100644
89035 --- a/net/netfilter/nf_log.c
89036 +++ b/net/netfilter/nf_log.c
89037 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
89038
89039 #ifdef CONFIG_SYSCTL
89040 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89041 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89042 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89043 static struct ctl_table_header *nf_log_dir_header;
89044
89045 static int nf_log_proc_dostring(ctl_table *table, int write,
89046 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89047 rcu_assign_pointer(nf_loggers[tindex], logger);
89048 mutex_unlock(&nf_log_mutex);
89049 } else {
89050 + ctl_table_no_const nf_log_table = *table;
89051 +
89052 mutex_lock(&nf_log_mutex);
89053 logger = rcu_dereference_protected(nf_loggers[tindex],
89054 lockdep_is_held(&nf_log_mutex));
89055 if (!logger)
89056 - table->data = "NONE";
89057 + nf_log_table.data = "NONE";
89058 else
89059 - table->data = logger->name;
89060 - r = proc_dostring(table, write, buffer, lenp, ppos);
89061 + nf_log_table.data = logger->name;
89062 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89063 mutex_unlock(&nf_log_mutex);
89064 }
89065
89066 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89067 index f042ae5..30ea486 100644
89068 --- a/net/netfilter/nf_sockopt.c
89069 +++ b/net/netfilter/nf_sockopt.c
89070 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89071 }
89072 }
89073
89074 - list_add(&reg->list, &nf_sockopts);
89075 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89076 out:
89077 mutex_unlock(&nf_sockopt_mutex);
89078 return ret;
89079 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89080 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89081 {
89082 mutex_lock(&nf_sockopt_mutex);
89083 - list_del(&reg->list);
89084 + pax_list_del((struct list_head *)&reg->list);
89085 mutex_unlock(&nf_sockopt_mutex);
89086 }
89087 EXPORT_SYMBOL(nf_unregister_sockopt);
89088 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
89089 index 589d686..dc3fd5d 100644
89090 --- a/net/netfilter/nfnetlink_acct.c
89091 +++ b/net/netfilter/nfnetlink_acct.c
89092 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
89093 return -EINVAL;
89094
89095 acct_name = nla_data(tb[NFACCT_NAME]);
89096 + if (strlen(acct_name) == 0)
89097 + return -EINVAL;
89098
89099 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
89100 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
89101 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89102 index 92fd8ec..3f6ea4b 100644
89103 --- a/net/netfilter/nfnetlink_log.c
89104 +++ b/net/netfilter/nfnetlink_log.c
89105 @@ -72,7 +72,7 @@ struct nfulnl_instance {
89106 };
89107
89108 static DEFINE_SPINLOCK(instances_lock);
89109 -static atomic_t global_seq;
89110 +static atomic_unchecked_t global_seq;
89111
89112 #define INSTANCE_BUCKETS 16
89113 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89114 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89115 /* global sequence number */
89116 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89117 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89118 - htonl(atomic_inc_return(&global_seq))))
89119 + htonl(atomic_inc_return_unchecked(&global_seq))))
89120 goto nla_put_failure;
89121
89122 if (data_len) {
89123 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89124 index 3158d87..39006c9 100644
89125 --- a/net/netfilter/nfnetlink_queue_core.c
89126 +++ b/net/netfilter/nfnetlink_queue_core.c
89127 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89128
89129 #ifdef CONFIG_PROC_FS
89130 if (!proc_create("nfnetlink_queue", 0440,
89131 - proc_net_netfilter, &nfqnl_file_ops))
89132 + proc_net_netfilter, &nfqnl_file_ops)) {
89133 + status = -ENOMEM;
89134 goto cleanup_subsys;
89135 + }
89136 #endif
89137
89138 register_netdevice_notifier(&nfqnl_dev_notifier);
89139 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89140 new file mode 100644
89141 index 0000000..c566332
89142 --- /dev/null
89143 +++ b/net/netfilter/xt_gradm.c
89144 @@ -0,0 +1,51 @@
89145 +/*
89146 + * gradm match for netfilter
89147 + * Copyright © Zbigniew Krzystolik, 2010
89148 + *
89149 + * This program is free software; you can redistribute it and/or modify
89150 + * it under the terms of the GNU General Public License; either version
89151 + * 2 or 3 as published by the Free Software Foundation.
89152 + */
89153 +#include <linux/module.h>
89154 +#include <linux/moduleparam.h>
89155 +#include <linux/skbuff.h>
89156 +#include <linux/netfilter/x_tables.h>
89157 +#include <linux/grsecurity.h>
89158 +#include <linux/netfilter/xt_gradm.h>
89159 +
89160 +static bool
89161 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89162 +{
89163 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89164 + bool retval = false;
89165 + if (gr_acl_is_enabled())
89166 + retval = true;
89167 + return retval ^ info->invflags;
89168 +}
89169 +
89170 +static struct xt_match gradm_mt_reg __read_mostly = {
89171 + .name = "gradm",
89172 + .revision = 0,
89173 + .family = NFPROTO_UNSPEC,
89174 + .match = gradm_mt,
89175 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89176 + .me = THIS_MODULE,
89177 +};
89178 +
89179 +static int __init gradm_mt_init(void)
89180 +{
89181 + return xt_register_match(&gradm_mt_reg);
89182 +}
89183 +
89184 +static void __exit gradm_mt_exit(void)
89185 +{
89186 + xt_unregister_match(&gradm_mt_reg);
89187 +}
89188 +
89189 +module_init(gradm_mt_init);
89190 +module_exit(gradm_mt_exit);
89191 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89192 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89193 +MODULE_LICENSE("GPL");
89194 +MODULE_ALIAS("ipt_gradm");
89195 +MODULE_ALIAS("ip6t_gradm");
89196 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89197 index 4fe4fb4..87a89e5 100644
89198 --- a/net/netfilter/xt_statistic.c
89199 +++ b/net/netfilter/xt_statistic.c
89200 @@ -19,7 +19,7 @@
89201 #include <linux/module.h>
89202
89203 struct xt_statistic_priv {
89204 - atomic_t count;
89205 + atomic_unchecked_t count;
89206 } ____cacheline_aligned_in_smp;
89207
89208 MODULE_LICENSE("GPL");
89209 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89210 break;
89211 case XT_STATISTIC_MODE_NTH:
89212 do {
89213 - oval = atomic_read(&info->master->count);
89214 + oval = atomic_read_unchecked(&info->master->count);
89215 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89216 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89217 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89218 if (nval == 0)
89219 ret = !ret;
89220 break;
89221 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89222 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89223 if (info->master == NULL)
89224 return -ENOMEM;
89225 - atomic_set(&info->master->count, info->u.nth.count);
89226 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89227
89228 return 0;
89229 }
89230 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89231 index c0353d5..fcb0270 100644
89232 --- a/net/netlink/af_netlink.c
89233 +++ b/net/netlink/af_netlink.c
89234 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89235 sk->sk_error_report(sk);
89236 }
89237 }
89238 - atomic_inc(&sk->sk_drops);
89239 + atomic_inc_unchecked(&sk->sk_drops);
89240 }
89241
89242 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89243 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89244 sk_wmem_alloc_get(s),
89245 nlk->cb,
89246 atomic_read(&s->sk_refcnt),
89247 - atomic_read(&s->sk_drops),
89248 + atomic_read_unchecked(&s->sk_drops),
89249 sock_i_ino(s)
89250 );
89251
89252 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89253 index 5a55be3..7630745 100644
89254 --- a/net/netlink/genetlink.c
89255 +++ b/net/netlink/genetlink.c
89256 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89257 goto errout;
89258 }
89259
89260 + pax_open_kernel();
89261 if (ops->dumpit)
89262 - ops->flags |= GENL_CMD_CAP_DUMP;
89263 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89264 if (ops->doit)
89265 - ops->flags |= GENL_CMD_CAP_DO;
89266 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89267 if (ops->policy)
89268 - ops->flags |= GENL_CMD_CAP_HASPOL;
89269 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89270 + pax_close_kernel();
89271
89272 genl_lock();
89273 - list_add_tail(&ops->ops_list, &family->ops_list);
89274 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89275 genl_unlock();
89276
89277 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89278 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89279 err = 0;
89280 errout:
89281 return err;
89282 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89283 genl_lock();
89284 list_for_each_entry(rc, &family->ops_list, ops_list) {
89285 if (rc == ops) {
89286 - list_del(&ops->ops_list);
89287 + pax_list_del((struct list_head *)&ops->ops_list);
89288 genl_unlock();
89289 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89290 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89291 return 0;
89292 }
89293 }
89294 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89295 index 14c106b..2d58b38 100644
89296 --- a/net/netrom/af_netrom.c
89297 +++ b/net/netrom/af_netrom.c
89298 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89299 struct sock *sk = sock->sk;
89300 struct nr_sock *nr = nr_sk(sk);
89301
89302 + memset(sax, 0, sizeof(*sax));
89303 lock_sock(sk);
89304 if (peer != 0) {
89305 if (sk->sk_state != TCP_ESTABLISHED) {
89306 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89307 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89308 } else {
89309 sax->fsa_ax25.sax25_family = AF_NETROM;
89310 - sax->fsa_ax25.sax25_ndigis = 0;
89311 sax->fsa_ax25.sax25_call = nr->source_addr;
89312 *uaddr_len = sizeof(struct sockaddr_ax25);
89313 }
89314 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89315 index c111bd0..7788ff7 100644
89316 --- a/net/packet/af_packet.c
89317 +++ b/net/packet/af_packet.c
89318 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89319
89320 spin_lock(&sk->sk_receive_queue.lock);
89321 po->stats.tp_packets++;
89322 - skb->dropcount = atomic_read(&sk->sk_drops);
89323 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89324 __skb_queue_tail(&sk->sk_receive_queue, skb);
89325 spin_unlock(&sk->sk_receive_queue.lock);
89326 sk->sk_data_ready(sk, skb->len);
89327 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89328 drop_n_acct:
89329 spin_lock(&sk->sk_receive_queue.lock);
89330 po->stats.tp_drops++;
89331 - atomic_inc(&sk->sk_drops);
89332 + atomic_inc_unchecked(&sk->sk_drops);
89333 spin_unlock(&sk->sk_receive_queue.lock);
89334
89335 drop_n_restore:
89336 @@ -2565,6 +2565,7 @@ out:
89337
89338 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89339 {
89340 + struct sock_extended_err ee;
89341 struct sock_exterr_skb *serr;
89342 struct sk_buff *skb, *skb2;
89343 int copied, err;
89344 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89345 sock_recv_timestamp(msg, sk, skb);
89346
89347 serr = SKB_EXT_ERR(skb);
89348 + ee = serr->ee;
89349 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89350 - sizeof(serr->ee), &serr->ee);
89351 + sizeof ee, &ee);
89352
89353 msg->msg_flags |= MSG_ERRQUEUE;
89354 err = copied;
89355 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89356 case PACKET_HDRLEN:
89357 if (len > sizeof(int))
89358 len = sizeof(int);
89359 - if (copy_from_user(&val, optval, len))
89360 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89361 return -EFAULT;
89362 switch (val) {
89363 case TPACKET_V1:
89364 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89365 len = lv;
89366 if (put_user(len, optlen))
89367 return -EFAULT;
89368 - if (copy_to_user(optval, data, len))
89369 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89370 return -EFAULT;
89371 return 0;
89372 }
89373 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89374 index 5a940db..d6a502d 100644
89375 --- a/net/phonet/af_phonet.c
89376 +++ b/net/phonet/af_phonet.c
89377 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89378 {
89379 int err = 0;
89380
89381 - if (protocol >= PHONET_NPROTO)
89382 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89383 return -EINVAL;
89384
89385 err = proto_register(pp->prot, 1);
89386 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89387 index 576f22c..bc7a71b 100644
89388 --- a/net/phonet/pep.c
89389 +++ b/net/phonet/pep.c
89390 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89391
89392 case PNS_PEP_CTRL_REQ:
89393 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89394 - atomic_inc(&sk->sk_drops);
89395 + atomic_inc_unchecked(&sk->sk_drops);
89396 break;
89397 }
89398 __skb_pull(skb, 4);
89399 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89400 }
89401
89402 if (pn->rx_credits == 0) {
89403 - atomic_inc(&sk->sk_drops);
89404 + atomic_inc_unchecked(&sk->sk_drops);
89405 err = -ENOBUFS;
89406 break;
89407 }
89408 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89409 }
89410
89411 if (pn->rx_credits == 0) {
89412 - atomic_inc(&sk->sk_drops);
89413 + atomic_inc_unchecked(&sk->sk_drops);
89414 err = NET_RX_DROP;
89415 break;
89416 }
89417 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89418 index b7e9827..c264c85 100644
89419 --- a/net/phonet/socket.c
89420 +++ b/net/phonet/socket.c
89421 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89422 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89423 sock_i_ino(sk),
89424 atomic_read(&sk->sk_refcnt), sk,
89425 - atomic_read(&sk->sk_drops), &len);
89426 + atomic_read_unchecked(&sk->sk_drops), &len);
89427 }
89428 seq_printf(seq, "%*s\n", 127 - len, "");
89429 return 0;
89430 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89431 index d6bbbbd..61561e4 100644
89432 --- a/net/phonet/sysctl.c
89433 +++ b/net/phonet/sysctl.c
89434 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89435 {
89436 int ret;
89437 int range[2] = {local_port_range[0], local_port_range[1]};
89438 - ctl_table tmp = {
89439 + ctl_table_no_const tmp = {
89440 .data = &range,
89441 .maxlen = sizeof(range),
89442 .mode = table->mode,
89443 diff --git a/net/rds/cong.c b/net/rds/cong.c
89444 index e5b65ac..f3b6fb7 100644
89445 --- a/net/rds/cong.c
89446 +++ b/net/rds/cong.c
89447 @@ -78,7 +78,7 @@
89448 * finds that the saved generation number is smaller than the global generation
89449 * number, it wakes up the process.
89450 */
89451 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89452 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89453
89454 /*
89455 * Congestion monitoring
89456 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89457 rdsdebug("waking map %p for %pI4\n",
89458 map, &map->m_addr);
89459 rds_stats_inc(s_cong_update_received);
89460 - atomic_inc(&rds_cong_generation);
89461 + atomic_inc_unchecked(&rds_cong_generation);
89462 if (waitqueue_active(&map->m_waitq))
89463 wake_up(&map->m_waitq);
89464 if (waitqueue_active(&rds_poll_waitq))
89465 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89466
89467 int rds_cong_updated_since(unsigned long *recent)
89468 {
89469 - unsigned long gen = atomic_read(&rds_cong_generation);
89470 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89471
89472 if (likely(*recent == gen))
89473 return 0;
89474 diff --git a/net/rds/ib.h b/net/rds/ib.h
89475 index 7280ab8..e04f4ea 100644
89476 --- a/net/rds/ib.h
89477 +++ b/net/rds/ib.h
89478 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89479 /* sending acks */
89480 unsigned long i_ack_flags;
89481 #ifdef KERNEL_HAS_ATOMIC64
89482 - atomic64_t i_ack_next; /* next ACK to send */
89483 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89484 #else
89485 spinlock_t i_ack_lock; /* protect i_ack_next */
89486 u64 i_ack_next; /* next ACK to send */
89487 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89488 index 31b74f5..dc1fbfa 100644
89489 --- a/net/rds/ib_cm.c
89490 +++ b/net/rds/ib_cm.c
89491 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89492 /* Clear the ACK state */
89493 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89494 #ifdef KERNEL_HAS_ATOMIC64
89495 - atomic64_set(&ic->i_ack_next, 0);
89496 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89497 #else
89498 ic->i_ack_next = 0;
89499 #endif
89500 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89501 index 8eb9501..0c386ff 100644
89502 --- a/net/rds/ib_recv.c
89503 +++ b/net/rds/ib_recv.c
89504 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89505 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89506 int ack_required)
89507 {
89508 - atomic64_set(&ic->i_ack_next, seq);
89509 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89510 if (ack_required) {
89511 smp_mb__before_clear_bit();
89512 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89513 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89514 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89515 smp_mb__after_clear_bit();
89516
89517 - return atomic64_read(&ic->i_ack_next);
89518 + return atomic64_read_unchecked(&ic->i_ack_next);
89519 }
89520 #endif
89521
89522 diff --git a/net/rds/iw.h b/net/rds/iw.h
89523 index 04ce3b1..48119a6 100644
89524 --- a/net/rds/iw.h
89525 +++ b/net/rds/iw.h
89526 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89527 /* sending acks */
89528 unsigned long i_ack_flags;
89529 #ifdef KERNEL_HAS_ATOMIC64
89530 - atomic64_t i_ack_next; /* next ACK to send */
89531 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89532 #else
89533 spinlock_t i_ack_lock; /* protect i_ack_next */
89534 u64 i_ack_next; /* next ACK to send */
89535 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89536 index a91e1db..cf3053f 100644
89537 --- a/net/rds/iw_cm.c
89538 +++ b/net/rds/iw_cm.c
89539 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89540 /* Clear the ACK state */
89541 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89542 #ifdef KERNEL_HAS_ATOMIC64
89543 - atomic64_set(&ic->i_ack_next, 0);
89544 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89545 #else
89546 ic->i_ack_next = 0;
89547 #endif
89548 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89549 index 4503335..db566b4 100644
89550 --- a/net/rds/iw_recv.c
89551 +++ b/net/rds/iw_recv.c
89552 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89553 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89554 int ack_required)
89555 {
89556 - atomic64_set(&ic->i_ack_next, seq);
89557 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89558 if (ack_required) {
89559 smp_mb__before_clear_bit();
89560 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89561 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89562 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89563 smp_mb__after_clear_bit();
89564
89565 - return atomic64_read(&ic->i_ack_next);
89566 + return atomic64_read_unchecked(&ic->i_ack_next);
89567 }
89568 #endif
89569
89570 diff --git a/net/rds/rds.h b/net/rds/rds.h
89571 index ec1d731..90a3a8d 100644
89572 --- a/net/rds/rds.h
89573 +++ b/net/rds/rds.h
89574 @@ -449,7 +449,7 @@ struct rds_transport {
89575 void (*sync_mr)(void *trans_private, int direction);
89576 void (*free_mr)(void *trans_private, int invalidate);
89577 void (*flush_mrs)(void);
89578 -};
89579 +} __do_const;
89580
89581 struct rds_sock {
89582 struct sock rs_sk;
89583 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89584 index edac9ef..16bcb98 100644
89585 --- a/net/rds/tcp.c
89586 +++ b/net/rds/tcp.c
89587 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89588 int val = 1;
89589
89590 set_fs(KERNEL_DS);
89591 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89592 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89593 sizeof(val));
89594 set_fs(oldfs);
89595 }
89596 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89597 index 81cf5a4..b5826ff 100644
89598 --- a/net/rds/tcp_send.c
89599 +++ b/net/rds/tcp_send.c
89600 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89601
89602 oldfs = get_fs();
89603 set_fs(KERNEL_DS);
89604 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89605 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89606 sizeof(val));
89607 set_fs(oldfs);
89608 }
89609 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89610 index 05996d0..5a1dfe0 100644
89611 --- a/net/rxrpc/af_rxrpc.c
89612 +++ b/net/rxrpc/af_rxrpc.c
89613 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89614 __be32 rxrpc_epoch;
89615
89616 /* current debugging ID */
89617 -atomic_t rxrpc_debug_id;
89618 +atomic_unchecked_t rxrpc_debug_id;
89619
89620 /* count of skbs currently in use */
89621 atomic_t rxrpc_n_skbs;
89622 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89623 index e4d9cbc..b229649 100644
89624 --- a/net/rxrpc/ar-ack.c
89625 +++ b/net/rxrpc/ar-ack.c
89626 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89627
89628 _enter("{%d,%d,%d,%d},",
89629 call->acks_hard, call->acks_unacked,
89630 - atomic_read(&call->sequence),
89631 + atomic_read_unchecked(&call->sequence),
89632 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89633
89634 stop = 0;
89635 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89636
89637 /* each Tx packet has a new serial number */
89638 sp->hdr.serial =
89639 - htonl(atomic_inc_return(&call->conn->serial));
89640 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89641
89642 hdr = (struct rxrpc_header *) txb->head;
89643 hdr->serial = sp->hdr.serial;
89644 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89645 */
89646 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89647 {
89648 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89649 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89650 }
89651
89652 /*
89653 @@ -629,7 +629,7 @@ process_further:
89654
89655 latest = ntohl(sp->hdr.serial);
89656 hard = ntohl(ack.firstPacket);
89657 - tx = atomic_read(&call->sequence);
89658 + tx = atomic_read_unchecked(&call->sequence);
89659
89660 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89661 latest,
89662 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89663 goto maybe_reschedule;
89664
89665 send_ACK_with_skew:
89666 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89667 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89668 ntohl(ack.serial));
89669 send_ACK:
89670 mtu = call->conn->trans->peer->if_mtu;
89671 @@ -1173,7 +1173,7 @@ send_ACK:
89672 ackinfo.rxMTU = htonl(5692);
89673 ackinfo.jumbo_max = htonl(4);
89674
89675 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89676 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89677 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89678 ntohl(hdr.serial),
89679 ntohs(ack.maxSkew),
89680 @@ -1191,7 +1191,7 @@ send_ACK:
89681 send_message:
89682 _debug("send message");
89683
89684 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89685 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89686 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89687 send_message_2:
89688
89689 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89690 index a3bbb36..3341fb9 100644
89691 --- a/net/rxrpc/ar-call.c
89692 +++ b/net/rxrpc/ar-call.c
89693 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89694 spin_lock_init(&call->lock);
89695 rwlock_init(&call->state_lock);
89696 atomic_set(&call->usage, 1);
89697 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89698 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89699 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89700
89701 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89702 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89703 index 4106ca9..a338d7a 100644
89704 --- a/net/rxrpc/ar-connection.c
89705 +++ b/net/rxrpc/ar-connection.c
89706 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89707 rwlock_init(&conn->lock);
89708 spin_lock_init(&conn->state_lock);
89709 atomic_set(&conn->usage, 1);
89710 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89711 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89712 conn->avail_calls = RXRPC_MAXCALLS;
89713 conn->size_align = 4;
89714 conn->header_size = sizeof(struct rxrpc_header);
89715 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89716 index e7ed43a..6afa140 100644
89717 --- a/net/rxrpc/ar-connevent.c
89718 +++ b/net/rxrpc/ar-connevent.c
89719 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89720
89721 len = iov[0].iov_len + iov[1].iov_len;
89722
89723 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89724 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89725 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89726
89727 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89728 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89729 index 529572f..c758ca7 100644
89730 --- a/net/rxrpc/ar-input.c
89731 +++ b/net/rxrpc/ar-input.c
89732 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89733 /* track the latest serial number on this connection for ACK packet
89734 * information */
89735 serial = ntohl(sp->hdr.serial);
89736 - hi_serial = atomic_read(&call->conn->hi_serial);
89737 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89738 while (serial > hi_serial)
89739 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89740 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89741 serial);
89742
89743 /* request ACK generation for any ACK or DATA packet that requests
89744 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89745 index a693aca..81e7293 100644
89746 --- a/net/rxrpc/ar-internal.h
89747 +++ b/net/rxrpc/ar-internal.h
89748 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89749 int error; /* error code for local abort */
89750 int debug_id; /* debug ID for printks */
89751 unsigned int call_counter; /* call ID counter */
89752 - atomic_t serial; /* packet serial number counter */
89753 - atomic_t hi_serial; /* highest serial number received */
89754 + atomic_unchecked_t serial; /* packet serial number counter */
89755 + atomic_unchecked_t hi_serial; /* highest serial number received */
89756 u8 avail_calls; /* number of calls available */
89757 u8 size_align; /* data size alignment (for security) */
89758 u8 header_size; /* rxrpc + security header size */
89759 @@ -346,7 +346,7 @@ struct rxrpc_call {
89760 spinlock_t lock;
89761 rwlock_t state_lock; /* lock for state transition */
89762 atomic_t usage;
89763 - atomic_t sequence; /* Tx data packet sequence counter */
89764 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89765 u32 abort_code; /* local/remote abort code */
89766 enum { /* current state of call */
89767 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89768 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89769 */
89770 extern atomic_t rxrpc_n_skbs;
89771 extern __be32 rxrpc_epoch;
89772 -extern atomic_t rxrpc_debug_id;
89773 +extern atomic_unchecked_t rxrpc_debug_id;
89774 extern struct workqueue_struct *rxrpc_workqueue;
89775
89776 /*
89777 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89778 index 87f7135..74d3703 100644
89779 --- a/net/rxrpc/ar-local.c
89780 +++ b/net/rxrpc/ar-local.c
89781 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89782 spin_lock_init(&local->lock);
89783 rwlock_init(&local->services_lock);
89784 atomic_set(&local->usage, 1);
89785 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89786 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89787 memcpy(&local->srx, srx, sizeof(*srx));
89788 }
89789
89790 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89791 index e1ac183..b43e10e 100644
89792 --- a/net/rxrpc/ar-output.c
89793 +++ b/net/rxrpc/ar-output.c
89794 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89795 sp->hdr.cid = call->cid;
89796 sp->hdr.callNumber = call->call_id;
89797 sp->hdr.seq =
89798 - htonl(atomic_inc_return(&call->sequence));
89799 + htonl(atomic_inc_return_unchecked(&call->sequence));
89800 sp->hdr.serial =
89801 - htonl(atomic_inc_return(&conn->serial));
89802 + htonl(atomic_inc_return_unchecked(&conn->serial));
89803 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89804 sp->hdr.userStatus = 0;
89805 sp->hdr.securityIndex = conn->security_ix;
89806 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89807 index bebaa43..2644591 100644
89808 --- a/net/rxrpc/ar-peer.c
89809 +++ b/net/rxrpc/ar-peer.c
89810 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89811 INIT_LIST_HEAD(&peer->error_targets);
89812 spin_lock_init(&peer->lock);
89813 atomic_set(&peer->usage, 1);
89814 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89815 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89816 memcpy(&peer->srx, srx, sizeof(*srx));
89817
89818 rxrpc_assess_MTU_size(peer);
89819 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89820 index 38047f7..9f48511 100644
89821 --- a/net/rxrpc/ar-proc.c
89822 +++ b/net/rxrpc/ar-proc.c
89823 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89824 atomic_read(&conn->usage),
89825 rxrpc_conn_states[conn->state],
89826 key_serial(conn->key),
89827 - atomic_read(&conn->serial),
89828 - atomic_read(&conn->hi_serial));
89829 + atomic_read_unchecked(&conn->serial),
89830 + atomic_read_unchecked(&conn->hi_serial));
89831
89832 return 0;
89833 }
89834 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89835 index 92df566..87ec1bf 100644
89836 --- a/net/rxrpc/ar-transport.c
89837 +++ b/net/rxrpc/ar-transport.c
89838 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89839 spin_lock_init(&trans->client_lock);
89840 rwlock_init(&trans->conn_lock);
89841 atomic_set(&trans->usage, 1);
89842 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89843 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89844
89845 if (peer->srx.transport.family == AF_INET) {
89846 switch (peer->srx.transport_type) {
89847 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89848 index f226709..0e735a8 100644
89849 --- a/net/rxrpc/rxkad.c
89850 +++ b/net/rxrpc/rxkad.c
89851 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89852
89853 len = iov[0].iov_len + iov[1].iov_len;
89854
89855 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89856 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89857 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89858
89859 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89860 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89861
89862 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89863
89864 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89865 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89866 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89867
89868 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89869 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89870 index 391a245..296b3d7 100644
89871 --- a/net/sctp/ipv6.c
89872 +++ b/net/sctp/ipv6.c
89873 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89874 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89875 };
89876
89877 -static struct sctp_af sctp_af_inet6 = {
89878 +static struct sctp_af sctp_af_inet6 __read_only = {
89879 .sa_family = AF_INET6,
89880 .sctp_xmit = sctp_v6_xmit,
89881 .setsockopt = ipv6_setsockopt,
89882 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89883 #endif
89884 };
89885
89886 -static struct sctp_pf sctp_pf_inet6 = {
89887 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89888 .event_msgname = sctp_inet6_event_msgname,
89889 .skb_msgname = sctp_inet6_skb_msgname,
89890 .af_supported = sctp_inet6_af_supported,
89891 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89892
89893 void sctp_v6_pf_exit(void)
89894 {
89895 - list_del(&sctp_af_inet6.list);
89896 + pax_list_del(&sctp_af_inet6.list);
89897 }
89898
89899 /* Initialize IPv6 support and register with socket layer. */
89900 diff --git a/net/sctp/probe.c b/net/sctp/probe.c
89901 index 5f7518d..9b91f6c 100644
89902 --- a/net/sctp/probe.c
89903 +++ b/net/sctp/probe.c
89904 @@ -63,7 +63,7 @@ static struct {
89905 struct timespec tstart;
89906 } sctpw;
89907
89908 -static void printl(const char *fmt, ...)
89909 +static __printf(1, 2) void printl(const char *fmt, ...)
89910 {
89911 va_list args;
89912 int len;
89913 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89914 index 8c19e97..16264b8 100644
89915 --- a/net/sctp/proc.c
89916 +++ b/net/sctp/proc.c
89917 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89918 seq_printf(seq,
89919 "%8pK %8pK %-3d %-3d %-2d %-4d "
89920 "%4d %8d %8d %7d %5lu %-5d %5d ",
89921 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89922 + assoc, sk,
89923 + sctp_sk(sk)->type, sk->sk_state,
89924 assoc->state, hash,
89925 assoc->assoc_id,
89926 assoc->sndbuf_used,
89927 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89928 index f898b1c..a2d0fe8 100644
89929 --- a/net/sctp/protocol.c
89930 +++ b/net/sctp/protocol.c
89931 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89932 return 0;
89933 }
89934
89935 + pax_open_kernel();
89936 INIT_LIST_HEAD(&af->list);
89937 - list_add_tail(&af->list, &sctp_address_families);
89938 + pax_close_kernel();
89939 + pax_list_add_tail(&af->list, &sctp_address_families);
89940 return 1;
89941 }
89942
89943 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89944
89945 static struct sctp_af sctp_af_inet;
89946
89947 -static struct sctp_pf sctp_pf_inet = {
89948 +static struct sctp_pf sctp_pf_inet __read_only = {
89949 .event_msgname = sctp_inet_event_msgname,
89950 .skb_msgname = sctp_inet_skb_msgname,
89951 .af_supported = sctp_inet_af_supported,
89952 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89953 };
89954
89955 /* IPv4 address related functions. */
89956 -static struct sctp_af sctp_af_inet = {
89957 +static struct sctp_af sctp_af_inet __read_only = {
89958 .sa_family = AF_INET,
89959 .sctp_xmit = sctp_v4_xmit,
89960 .setsockopt = ip_setsockopt,
89961 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89962
89963 static void sctp_v4_pf_exit(void)
89964 {
89965 - list_del(&sctp_af_inet.list);
89966 + pax_list_del(&sctp_af_inet.list);
89967 }
89968
89969 static int sctp_v4_protosw_init(void)
89970 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89971 index c957775..6d4593a 100644
89972 --- a/net/sctp/sm_sideeffect.c
89973 +++ b/net/sctp/sm_sideeffect.c
89974 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89975 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89976 }
89977
89978 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89979 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89980 NULL,
89981 sctp_generate_t1_cookie_event,
89982 sctp_generate_t1_init_event,
89983 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89984 index 9ef5c73..1e9a9a9 100644
89985 --- a/net/sctp/socket.c
89986 +++ b/net/sctp/socket.c
89987 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89988 {
89989 struct sctp_association *asoc;
89990 struct sctp_ulpevent *event;
89991 + struct sctp_event_subscribe subscribe;
89992
89993 if (optlen > sizeof(struct sctp_event_subscribe))
89994 return -EINVAL;
89995 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89996 + if (copy_from_user(&subscribe, optval, optlen))
89997 return -EFAULT;
89998 + sctp_sk(sk)->subscribe = subscribe;
89999
90000 /*
90001 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90002 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90003 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90004 int __user *optlen)
90005 {
90006 + struct sctp_event_subscribe subscribe;
90007 +
90008 if (len <= 0)
90009 return -EINVAL;
90010 if (len > sizeof(struct sctp_event_subscribe))
90011 len = sizeof(struct sctp_event_subscribe);
90012 if (put_user(len, optlen))
90013 return -EFAULT;
90014 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90015 + subscribe = sctp_sk(sk)->subscribe;
90016 + if (copy_to_user(optval, &subscribe, len))
90017 return -EFAULT;
90018 return 0;
90019 }
90020 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90021 */
90022 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90023 {
90024 + __u32 autoclose;
90025 +
90026 /* Applicable to UDP-style socket only */
90027 if (sctp_style(sk, TCP))
90028 return -EOPNOTSUPP;
90029 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90030 len = sizeof(int);
90031 if (put_user(len, optlen))
90032 return -EFAULT;
90033 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90034 + autoclose = sctp_sk(sk)->autoclose;
90035 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90036 return -EFAULT;
90037 return 0;
90038 }
90039 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90040 */
90041 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90042 {
90043 + struct sctp_initmsg initmsg;
90044 +
90045 if (len < sizeof(struct sctp_initmsg))
90046 return -EINVAL;
90047 len = sizeof(struct sctp_initmsg);
90048 if (put_user(len, optlen))
90049 return -EFAULT;
90050 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90051 + initmsg = sctp_sk(sk)->initmsg;
90052 + if (copy_to_user(optval, &initmsg, len))
90053 return -EFAULT;
90054 return 0;
90055 }
90056 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90057 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90058 if (space_left < addrlen)
90059 return -ENOMEM;
90060 + if (addrlen > sizeof(temp) || addrlen < 0)
90061 + return -EFAULT;
90062 if (copy_to_user(to, &temp, addrlen))
90063 return -EFAULT;
90064 to += addrlen;
90065 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
90066 index 442ad4e..825ea94 100644
90067 --- a/net/sctp/ssnmap.c
90068 +++ b/net/sctp/ssnmap.c
90069 @@ -41,8 +41,6 @@
90070 #include <net/sctp/sctp.h>
90071 #include <net/sctp/sm.h>
90072
90073 -#define MAX_KMALLOC_SIZE 131072
90074 -
90075 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
90076 __u16 out);
90077
90078 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90079 int size;
90080
90081 size = sctp_ssnmap_size(in, out);
90082 - if (size <= MAX_KMALLOC_SIZE)
90083 + if (size <= KMALLOC_MAX_SIZE)
90084 retval = kmalloc(size, gfp);
90085 else
90086 retval = (struct sctp_ssnmap *)
90087 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
90088 return retval;
90089
90090 fail_map:
90091 - if (size <= MAX_KMALLOC_SIZE)
90092 + if (size <= KMALLOC_MAX_SIZE)
90093 kfree(retval);
90094 else
90095 free_pages((unsigned long)retval, get_order(size));
90096 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
90097 int size;
90098
90099 size = sctp_ssnmap_size(map->in.len, map->out.len);
90100 - if (size <= MAX_KMALLOC_SIZE)
90101 + if (size <= KMALLOC_MAX_SIZE)
90102 kfree(map);
90103 else
90104 free_pages((unsigned long)map, get_order(size));
90105 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90106 index bf3c6e8..376d8d0 100644
90107 --- a/net/sctp/sysctl.c
90108 +++ b/net/sctp/sysctl.c
90109 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90110 {
90111 struct net *net = current->nsproxy->net_ns;
90112 char tmp[8];
90113 - ctl_table tbl;
90114 + ctl_table_no_const tbl;
90115 int ret;
90116 int changed = 0;
90117 char *none = "none";
90118 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90119
90120 int sctp_sysctl_net_register(struct net *net)
90121 {
90122 - struct ctl_table *table;
90123 + ctl_table_no_const *table;
90124 int i;
90125
90126 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90127 diff --git a/net/socket.c b/net/socket.c
90128 index 2ca51c7..ee5feb5 100644
90129 --- a/net/socket.c
90130 +++ b/net/socket.c
90131 @@ -89,6 +89,7 @@
90132 #include <linux/magic.h>
90133 #include <linux/slab.h>
90134 #include <linux/xattr.h>
90135 +#include <linux/in.h>
90136
90137 #include <asm/uaccess.h>
90138 #include <asm/unistd.h>
90139 @@ -106,6 +107,8 @@
90140 #include <linux/sockios.h>
90141 #include <linux/atalk.h>
90142
90143 +#include <linux/grsock.h>
90144 +
90145 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90146 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90147 unsigned long nr_segs, loff_t pos);
90148 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90149 &sockfs_dentry_operations, SOCKFS_MAGIC);
90150 }
90151
90152 -static struct vfsmount *sock_mnt __read_mostly;
90153 +struct vfsmount *sock_mnt __read_mostly;
90154
90155 static struct file_system_type sock_fs_type = {
90156 .name = "sockfs",
90157 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90158 return -EAFNOSUPPORT;
90159 if (type < 0 || type >= SOCK_MAX)
90160 return -EINVAL;
90161 + if (protocol < 0)
90162 + return -EINVAL;
90163
90164 /* Compatibility.
90165
90166 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90167 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90168 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90169
90170 + if(!gr_search_socket(family, type, protocol)) {
90171 + retval = -EACCES;
90172 + goto out;
90173 + }
90174 +
90175 + if (gr_handle_sock_all(family, type, protocol)) {
90176 + retval = -EACCES;
90177 + goto out;
90178 + }
90179 +
90180 retval = sock_create(family, type, protocol, &sock);
90181 if (retval < 0)
90182 goto out;
90183 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90184 if (sock) {
90185 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90186 if (err >= 0) {
90187 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90188 + err = -EACCES;
90189 + goto error;
90190 + }
90191 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90192 + if (err)
90193 + goto error;
90194 +
90195 err = security_socket_bind(sock,
90196 (struct sockaddr *)&address,
90197 addrlen);
90198 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90199 (struct sockaddr *)
90200 &address, addrlen);
90201 }
90202 +error:
90203 fput_light(sock->file, fput_needed);
90204 }
90205 return err;
90206 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90207 if ((unsigned int)backlog > somaxconn)
90208 backlog = somaxconn;
90209
90210 + if (gr_handle_sock_server_other(sock->sk)) {
90211 + err = -EPERM;
90212 + goto error;
90213 + }
90214 +
90215 + err = gr_search_listen(sock);
90216 + if (err)
90217 + goto error;
90218 +
90219 err = security_socket_listen(sock, backlog);
90220 if (!err)
90221 err = sock->ops->listen(sock, backlog);
90222
90223 +error:
90224 fput_light(sock->file, fput_needed);
90225 }
90226 return err;
90227 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90228 newsock->type = sock->type;
90229 newsock->ops = sock->ops;
90230
90231 + if (gr_handle_sock_server_other(sock->sk)) {
90232 + err = -EPERM;
90233 + sock_release(newsock);
90234 + goto out_put;
90235 + }
90236 +
90237 + err = gr_search_accept(sock);
90238 + if (err) {
90239 + sock_release(newsock);
90240 + goto out_put;
90241 + }
90242 +
90243 /*
90244 * We don't need try_module_get here, as the listening socket (sock)
90245 * has the protocol module (sock->ops->owner) held.
90246 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90247 fd_install(newfd, newfile);
90248 err = newfd;
90249
90250 + gr_attach_curr_ip(newsock->sk);
90251 +
90252 out_put:
90253 fput_light(sock->file, fput_needed);
90254 out:
90255 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90256 int, addrlen)
90257 {
90258 struct socket *sock;
90259 + struct sockaddr *sck;
90260 struct sockaddr_storage address;
90261 int err, fput_needed;
90262
90263 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90264 if (err < 0)
90265 goto out_put;
90266
90267 + sck = (struct sockaddr *)&address;
90268 +
90269 + if (gr_handle_sock_client(sck)) {
90270 + err = -EACCES;
90271 + goto out_put;
90272 + }
90273 +
90274 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90275 + if (err)
90276 + goto out_put;
90277 +
90278 err =
90279 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90280 if (err)
90281 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90282 * the protocol.
90283 */
90284
90285 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90286 +
90287 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90288 unsigned int, flags, struct sockaddr __user *, addr,
90289 int, addr_len)
90290 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90291 struct socket *sock;
90292 struct iovec iov;
90293 struct msghdr msg;
90294 - struct sockaddr_storage address;
90295 + struct sockaddr_storage address = { };
90296 int err, err2;
90297 int fput_needed;
90298
90299 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90300 * checking falls down on this.
90301 */
90302 if (copy_from_user(ctl_buf,
90303 - (void __user __force *)msg_sys->msg_control,
90304 + (void __force_user *)msg_sys->msg_control,
90305 ctl_len))
90306 goto out_freectl;
90307 msg_sys->msg_control = ctl_buf;
90308 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90309 int err, total_len, len;
90310
90311 /* kernel mode address */
90312 - struct sockaddr_storage addr;
90313 + struct sockaddr_storage addr = { };
90314
90315 /* user mode address pointers */
90316 struct sockaddr __user *uaddr;
90317 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90318 * kernel msghdr to use the kernel address space)
90319 */
90320
90321 - uaddr = (__force void __user *)msg_sys->msg_name;
90322 + uaddr = (void __force_user *)msg_sys->msg_name;
90323 uaddr_len = COMPAT_NAMELEN(msg);
90324 if (MSG_CMSG_COMPAT & flags) {
90325 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90326 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90327 }
90328
90329 ifr = compat_alloc_user_space(buf_size);
90330 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90331 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90332
90333 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90334 return -EFAULT;
90335 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90336 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90337
90338 if (copy_in_user(rxnfc, compat_rxnfc,
90339 - (void *)(&rxnfc->fs.m_ext + 1) -
90340 - (void *)rxnfc) ||
90341 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90342 + (void __user *)rxnfc) ||
90343 copy_in_user(&rxnfc->fs.ring_cookie,
90344 &compat_rxnfc->fs.ring_cookie,
90345 - (void *)(&rxnfc->fs.location + 1) -
90346 - (void *)&rxnfc->fs.ring_cookie) ||
90347 + (void __user *)(&rxnfc->fs.location + 1) -
90348 + (void __user *)&rxnfc->fs.ring_cookie) ||
90349 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90350 sizeof(rxnfc->rule_cnt)))
90351 return -EFAULT;
90352 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90353
90354 if (convert_out) {
90355 if (copy_in_user(compat_rxnfc, rxnfc,
90356 - (const void *)(&rxnfc->fs.m_ext + 1) -
90357 - (const void *)rxnfc) ||
90358 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90359 + (const void __user *)rxnfc) ||
90360 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90361 &rxnfc->fs.ring_cookie,
90362 - (const void *)(&rxnfc->fs.location + 1) -
90363 - (const void *)&rxnfc->fs.ring_cookie) ||
90364 + (const void __user *)(&rxnfc->fs.location + 1) -
90365 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90366 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90367 sizeof(rxnfc->rule_cnt)))
90368 return -EFAULT;
90369 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90370 old_fs = get_fs();
90371 set_fs(KERNEL_DS);
90372 err = dev_ioctl(net, cmd,
90373 - (struct ifreq __user __force *) &kifr);
90374 + (struct ifreq __force_user *) &kifr);
90375 set_fs(old_fs);
90376
90377 return err;
90378 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90379
90380 old_fs = get_fs();
90381 set_fs(KERNEL_DS);
90382 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90383 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90384 set_fs(old_fs);
90385
90386 if (cmd == SIOCGIFMAP && !err) {
90387 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90388 ret |= __get_user(rtdev, &(ur4->rt_dev));
90389 if (rtdev) {
90390 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90391 - r4.rt_dev = (char __user __force *)devname;
90392 + r4.rt_dev = (char __force_user *)devname;
90393 devname[15] = 0;
90394 } else
90395 r4.rt_dev = NULL;
90396 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90397 int __user *uoptlen;
90398 int err;
90399
90400 - uoptval = (char __user __force *) optval;
90401 - uoptlen = (int __user __force *) optlen;
90402 + uoptval = (char __force_user *) optval;
90403 + uoptlen = (int __force_user *) optlen;
90404
90405 set_fs(KERNEL_DS);
90406 if (level == SOL_SOCKET)
90407 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90408 char __user *uoptval;
90409 int err;
90410
90411 - uoptval = (char __user __force *) optval;
90412 + uoptval = (char __force_user *) optval;
90413
90414 set_fs(KERNEL_DS);
90415 if (level == SOL_SOCKET)
90416 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90417 index 716aa41..75e88ea 100644
90418 --- a/net/sunrpc/clnt.c
90419 +++ b/net/sunrpc/clnt.c
90420 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90421 err = rpciod_up();
90422 if (err)
90423 goto out_no_rpciod;
90424 +
90425 err = -EINVAL;
90426 - if (!xprt)
90427 - goto out_no_xprt;
90428 -
90429 if (args->version >= program->nrvers)
90430 goto out_err;
90431 version = program->version[args->version];
90432 @@ -381,10 +379,9 @@ out_no_principal:
90433 out_no_stats:
90434 kfree(clnt);
90435 out_err:
90436 - xprt_put(xprt);
90437 -out_no_xprt:
90438 rpciod_down();
90439 out_no_rpciod:
90440 + xprt_put(xprt);
90441 return ERR_PTR(err);
90442 }
90443
90444 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90445 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90446
90447 /* Increment call count */
90448 - task->tk_msg.rpc_proc->p_count++;
90449 + pax_open_kernel();
90450 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90451 + pax_close_kernel();
90452 clnt->cl_stats->rpccnt++;
90453 task->tk_action = call_reserve;
90454 }
90455 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90456 index f8529fc..ce8c643 100644
90457 --- a/net/sunrpc/sched.c
90458 +++ b/net/sunrpc/sched.c
90459 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90460 #ifdef RPC_DEBUG
90461 static void rpc_task_set_debuginfo(struct rpc_task *task)
90462 {
90463 - static atomic_t rpc_pid;
90464 + static atomic_unchecked_t rpc_pid;
90465
90466 - task->tk_pid = atomic_inc_return(&rpc_pid);
90467 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90468 }
90469 #else
90470 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90471 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90472 index 2d34b6b..e2d584d 100644
90473 --- a/net/sunrpc/svc.c
90474 +++ b/net/sunrpc/svc.c
90475 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90476 svc_putnl(resv, RPC_SUCCESS);
90477
90478 /* Bump per-procedure stats counter */
90479 - procp->pc_count++;
90480 + pax_open_kernel();
90481 + (*(unsigned int *)&procp->pc_count)++;
90482 + pax_close_kernel();
90483
90484 /* Initialize storage for argp and resp */
90485 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90486 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90487 index 8343737..677025e 100644
90488 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90489 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90490 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90491 static unsigned int min_max_inline = 4096;
90492 static unsigned int max_max_inline = 65536;
90493
90494 -atomic_t rdma_stat_recv;
90495 -atomic_t rdma_stat_read;
90496 -atomic_t rdma_stat_write;
90497 -atomic_t rdma_stat_sq_starve;
90498 -atomic_t rdma_stat_rq_starve;
90499 -atomic_t rdma_stat_rq_poll;
90500 -atomic_t rdma_stat_rq_prod;
90501 -atomic_t rdma_stat_sq_poll;
90502 -atomic_t rdma_stat_sq_prod;
90503 +atomic_unchecked_t rdma_stat_recv;
90504 +atomic_unchecked_t rdma_stat_read;
90505 +atomic_unchecked_t rdma_stat_write;
90506 +atomic_unchecked_t rdma_stat_sq_starve;
90507 +atomic_unchecked_t rdma_stat_rq_starve;
90508 +atomic_unchecked_t rdma_stat_rq_poll;
90509 +atomic_unchecked_t rdma_stat_rq_prod;
90510 +atomic_unchecked_t rdma_stat_sq_poll;
90511 +atomic_unchecked_t rdma_stat_sq_prod;
90512
90513 /* Temporary NFS request map and context caches */
90514 struct kmem_cache *svc_rdma_map_cachep;
90515 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90516 len -= *ppos;
90517 if (len > *lenp)
90518 len = *lenp;
90519 - if (len && copy_to_user(buffer, str_buf, len))
90520 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90521 return -EFAULT;
90522 *lenp = len;
90523 *ppos += len;
90524 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90525 {
90526 .procname = "rdma_stat_read",
90527 .data = &rdma_stat_read,
90528 - .maxlen = sizeof(atomic_t),
90529 + .maxlen = sizeof(atomic_unchecked_t),
90530 .mode = 0644,
90531 .proc_handler = read_reset_stat,
90532 },
90533 {
90534 .procname = "rdma_stat_recv",
90535 .data = &rdma_stat_recv,
90536 - .maxlen = sizeof(atomic_t),
90537 + .maxlen = sizeof(atomic_unchecked_t),
90538 .mode = 0644,
90539 .proc_handler = read_reset_stat,
90540 },
90541 {
90542 .procname = "rdma_stat_write",
90543 .data = &rdma_stat_write,
90544 - .maxlen = sizeof(atomic_t),
90545 + .maxlen = sizeof(atomic_unchecked_t),
90546 .mode = 0644,
90547 .proc_handler = read_reset_stat,
90548 },
90549 {
90550 .procname = "rdma_stat_sq_starve",
90551 .data = &rdma_stat_sq_starve,
90552 - .maxlen = sizeof(atomic_t),
90553 + .maxlen = sizeof(atomic_unchecked_t),
90554 .mode = 0644,
90555 .proc_handler = read_reset_stat,
90556 },
90557 {
90558 .procname = "rdma_stat_rq_starve",
90559 .data = &rdma_stat_rq_starve,
90560 - .maxlen = sizeof(atomic_t),
90561 + .maxlen = sizeof(atomic_unchecked_t),
90562 .mode = 0644,
90563 .proc_handler = read_reset_stat,
90564 },
90565 {
90566 .procname = "rdma_stat_rq_poll",
90567 .data = &rdma_stat_rq_poll,
90568 - .maxlen = sizeof(atomic_t),
90569 + .maxlen = sizeof(atomic_unchecked_t),
90570 .mode = 0644,
90571 .proc_handler = read_reset_stat,
90572 },
90573 {
90574 .procname = "rdma_stat_rq_prod",
90575 .data = &rdma_stat_rq_prod,
90576 - .maxlen = sizeof(atomic_t),
90577 + .maxlen = sizeof(atomic_unchecked_t),
90578 .mode = 0644,
90579 .proc_handler = read_reset_stat,
90580 },
90581 {
90582 .procname = "rdma_stat_sq_poll",
90583 .data = &rdma_stat_sq_poll,
90584 - .maxlen = sizeof(atomic_t),
90585 + .maxlen = sizeof(atomic_unchecked_t),
90586 .mode = 0644,
90587 .proc_handler = read_reset_stat,
90588 },
90589 {
90590 .procname = "rdma_stat_sq_prod",
90591 .data = &rdma_stat_sq_prod,
90592 - .maxlen = sizeof(atomic_t),
90593 + .maxlen = sizeof(atomic_unchecked_t),
90594 .mode = 0644,
90595 .proc_handler = read_reset_stat,
90596 },
90597 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90598 index 0ce7552..d074459 100644
90599 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90600 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90601 @@ -501,7 +501,7 @@ next_sge:
90602 svc_rdma_put_context(ctxt, 0);
90603 goto out;
90604 }
90605 - atomic_inc(&rdma_stat_read);
90606 + atomic_inc_unchecked(&rdma_stat_read);
90607
90608 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90609 chl_map->ch[ch_no].count -= read_wr.num_sge;
90610 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90611 dto_q);
90612 list_del_init(&ctxt->dto_q);
90613 } else {
90614 - atomic_inc(&rdma_stat_rq_starve);
90615 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90616 clear_bit(XPT_DATA, &xprt->xpt_flags);
90617 ctxt = NULL;
90618 }
90619 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90620 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90621 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90622 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90623 - atomic_inc(&rdma_stat_recv);
90624 + atomic_inc_unchecked(&rdma_stat_recv);
90625
90626 /* Build up the XDR from the receive buffers. */
90627 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90628 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90629 index c1d124d..acfc59e 100644
90630 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90631 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90632 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90633 write_wr.wr.rdma.remote_addr = to;
90634
90635 /* Post It */
90636 - atomic_inc(&rdma_stat_write);
90637 + atomic_inc_unchecked(&rdma_stat_write);
90638 if (svc_rdma_send(xprt, &write_wr))
90639 goto err;
90640 return 0;
90641 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90642 index 62e4f9b..dd3f2d7 100644
90643 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90644 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90645 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90646 return;
90647
90648 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90649 - atomic_inc(&rdma_stat_rq_poll);
90650 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90651
90652 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90653 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90654 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90655 }
90656
90657 if (ctxt)
90658 - atomic_inc(&rdma_stat_rq_prod);
90659 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90660
90661 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90662 /*
90663 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90664 return;
90665
90666 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90667 - atomic_inc(&rdma_stat_sq_poll);
90668 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90669 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90670 if (wc.status != IB_WC_SUCCESS)
90671 /* Close the transport */
90672 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90673 }
90674
90675 if (ctxt)
90676 - atomic_inc(&rdma_stat_sq_prod);
90677 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90678 }
90679
90680 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90681 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90682 spin_lock_bh(&xprt->sc_lock);
90683 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90684 spin_unlock_bh(&xprt->sc_lock);
90685 - atomic_inc(&rdma_stat_sq_starve);
90686 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90687
90688 /* See if we can opportunistically reap SQ WR to make room */
90689 sq_cq_reap(xprt);
90690 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90691 index 9bc6db0..47ac8c0 100644
90692 --- a/net/sysctl_net.c
90693 +++ b/net/sysctl_net.c
90694 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90695 kgid_t root_gid = make_kgid(net->user_ns, 0);
90696
90697 /* Allow network administrator to have same access as root. */
90698 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90699 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90700 uid_eq(root_uid, current_uid())) {
90701 int mode = (table->mode >> 6) & 7;
90702 return (mode << 6) | (mode << 3) | mode;
90703 diff --git a/net/tipc/link.c b/net/tipc/link.c
90704 index daa6080..02d357f 100644
90705 --- a/net/tipc/link.c
90706 +++ b/net/tipc/link.c
90707 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90708 struct tipc_msg fragm_hdr;
90709 struct sk_buff *buf, *buf_chain, *prev;
90710 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90711 - const unchar *sect_crs;
90712 + const unchar __user *sect_crs;
90713 int curr_sect;
90714 u32 fragm_no;
90715
90716 @@ -1242,7 +1242,7 @@ again:
90717
90718 if (!sect_rest) {
90719 sect_rest = msg_sect[++curr_sect].iov_len;
90720 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90721 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90722 }
90723
90724 if (sect_rest < fragm_rest)
90725 @@ -1261,7 +1261,7 @@ error:
90726 }
90727 } else
90728 skb_copy_to_linear_data_offset(buf, fragm_crs,
90729 - sect_crs, sz);
90730 + (const void __force_kernel *)sect_crs, sz);
90731 sect_crs += sz;
90732 sect_rest -= sz;
90733 fragm_crs += sz;
90734 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90735 index f2db8a8..9245aa4 100644
90736 --- a/net/tipc/msg.c
90737 +++ b/net/tipc/msg.c
90738 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90739 msg_sect[cnt].iov_len);
90740 else
90741 skb_copy_to_linear_data_offset(*buf, pos,
90742 - msg_sect[cnt].iov_base,
90743 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90744 msg_sect[cnt].iov_len);
90745 pos += msg_sect[cnt].iov_len;
90746 }
90747 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90748 index 6b42d47..2ac24d5 100644
90749 --- a/net/tipc/subscr.c
90750 +++ b/net/tipc/subscr.c
90751 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90752 {
90753 struct iovec msg_sect;
90754
90755 - msg_sect.iov_base = (void *)&sub->evt;
90756 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90757 msg_sect.iov_len = sizeof(struct tipc_event);
90758
90759 sub->evt.event = htohl(event, sub->swap);
90760 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90761 index f347754..bb4b223 100644
90762 --- a/net/unix/af_unix.c
90763 +++ b/net/unix/af_unix.c
90764 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90765 err = -ECONNREFUSED;
90766 if (!S_ISSOCK(inode->i_mode))
90767 goto put_fail;
90768 +
90769 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90770 + err = -EACCES;
90771 + goto put_fail;
90772 + }
90773 +
90774 u = unix_find_socket_byinode(inode);
90775 if (!u)
90776 goto put_fail;
90777 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90778 if (u) {
90779 struct dentry *dentry;
90780 dentry = unix_sk(u)->path.dentry;
90781 +
90782 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90783 + err = -EPERM;
90784 + sock_put(u);
90785 + goto fail;
90786 + }
90787 +
90788 if (dentry)
90789 touch_atime(&unix_sk(u)->path);
90790 } else
90791 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90792 */
90793 err = security_path_mknod(&path, dentry, mode, 0);
90794 if (!err) {
90795 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90796 + err = -EACCES;
90797 + goto out;
90798 + }
90799 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90800 if (!err) {
90801 res->mnt = mntget(path.mnt);
90802 res->dentry = dget(dentry);
90803 + gr_handle_create(dentry, path.mnt);
90804 }
90805 }
90806 +out:
90807 done_path_create(&path, dentry);
90808 return err;
90809 }
90810 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90811 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90812 "Inode Path\n");
90813 else {
90814 - struct sock *s = v;
90815 + struct sock *s = v, *peer;
90816 struct unix_sock *u = unix_sk(s);
90817 unix_state_lock(s);
90818 + peer = unix_peer(s);
90819 + unix_state_unlock(s);
90820 +
90821 + unix_state_double_lock(s, peer);
90822
90823 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90824 s,
90825 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90826 }
90827 for ( ; i < len; i++)
90828 seq_putc(seq, u->addr->name->sun_path[i]);
90829 - }
90830 - unix_state_unlock(s);
90831 + } else if (peer)
90832 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90833 +
90834 + unix_state_double_unlock(s, peer);
90835 seq_putc(seq, '\n');
90836 }
90837
90838 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90839 index 8800604..0526440 100644
90840 --- a/net/unix/sysctl_net_unix.c
90841 +++ b/net/unix/sysctl_net_unix.c
90842 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90843
90844 int __net_init unix_sysctl_register(struct net *net)
90845 {
90846 - struct ctl_table *table;
90847 + ctl_table_no_const *table;
90848
90849 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90850 if (table == NULL)
90851 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90852 index 2134576..5d71a5a 100644
90853 --- a/net/wireless/trace.h
90854 +++ b/net/wireless/trace.h
90855 @@ -27,7 +27,8 @@
90856 #define WIPHY_PR_ARG __entry->wiphy_name
90857
90858 #define WDEV_ENTRY __field(u32, id)
90859 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90860 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90861 + ? wdev->identifier : 0)
90862 #define WDEV_PR_FMT "wdev(%u)"
90863 #define WDEV_PR_ARG (__entry->id)
90864
90865 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90866 index c8717c1..08539f5 100644
90867 --- a/net/wireless/wext-core.c
90868 +++ b/net/wireless/wext-core.c
90869 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90870 */
90871
90872 /* Support for very large requests */
90873 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90874 - (user_length > descr->max_tokens)) {
90875 + if (user_length > descr->max_tokens) {
90876 /* Allow userspace to GET more than max so
90877 * we can support any size GET requests.
90878 * There is still a limit : -ENOMEM.
90879 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90880 }
90881 }
90882
90883 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90884 - /*
90885 - * If this is a GET, but not NOMAX, it means that the extra
90886 - * data is not bounded by userspace, but by max_tokens. Thus
90887 - * set the length to max_tokens. This matches the extra data
90888 - * allocation.
90889 - * The driver should fill it with the number of tokens it
90890 - * provided, and it may check iwp->length rather than having
90891 - * knowledge of max_tokens. If the driver doesn't change the
90892 - * iwp->length, this ioctl just copies back max_token tokens
90893 - * filled with zeroes. Hopefully the driver isn't claiming
90894 - * them to be valid data.
90895 - */
90896 - iwp->length = descr->max_tokens;
90897 - }
90898 -
90899 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90900
90901 iwp->length += essid_compat;
90902 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90903 index 07c5857..fde4018 100644
90904 --- a/net/xfrm/xfrm_policy.c
90905 +++ b/net/xfrm/xfrm_policy.c
90906 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90907 {
90908 policy->walk.dead = 1;
90909
90910 - atomic_inc(&policy->genid);
90911 + atomic_inc_unchecked(&policy->genid);
90912
90913 if (del_timer(&policy->timer))
90914 xfrm_pol_put(policy);
90915 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90916 hlist_add_head(&policy->bydst, chain);
90917 xfrm_pol_hold(policy);
90918 net->xfrm.policy_count[dir]++;
90919 - atomic_inc(&flow_cache_genid);
90920 + atomic_inc_unchecked(&flow_cache_genid);
90921 rt_genid_bump(net);
90922 if (delpol)
90923 __xfrm_policy_unlink(delpol, dir);
90924 @@ -1550,7 +1550,7 @@ free_dst:
90925 goto out;
90926 }
90927
90928 -static int inline
90929 +static inline int
90930 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90931 {
90932 if (!*target) {
90933 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90934 return 0;
90935 }
90936
90937 -static int inline
90938 +static inline int
90939 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90940 {
90941 #ifdef CONFIG_XFRM_SUB_POLICY
90942 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90943 #endif
90944 }
90945
90946 -static int inline
90947 +static inline int
90948 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90949 {
90950 #ifdef CONFIG_XFRM_SUB_POLICY
90951 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90952
90953 xdst->num_pols = num_pols;
90954 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90955 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90956 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90957
90958 return xdst;
90959 }
90960 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90961 if (xdst->xfrm_genid != dst->xfrm->genid)
90962 return 0;
90963 if (xdst->num_pols > 0 &&
90964 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90965 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90966 return 0;
90967
90968 mtu = dst_mtu(dst->child);
90969 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90970 dst_ops->link_failure = xfrm_link_failure;
90971 if (likely(dst_ops->neigh_lookup == NULL))
90972 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90973 - if (likely(afinfo->garbage_collect == NULL))
90974 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90975 + if (likely(afinfo->garbage_collect == NULL)) {
90976 + pax_open_kernel();
90977 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90978 + pax_close_kernel();
90979 + }
90980 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90981 }
90982 spin_unlock(&xfrm_policy_afinfo_lock);
90983 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90984 dst_ops->check = NULL;
90985 dst_ops->negative_advice = NULL;
90986 dst_ops->link_failure = NULL;
90987 - afinfo->garbage_collect = NULL;
90988 + pax_open_kernel();
90989 + *(void **)&afinfo->garbage_collect = NULL;
90990 + pax_close_kernel();
90991 }
90992 return err;
90993 }
90994 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90995 sizeof(pol->xfrm_vec[i].saddr));
90996 pol->xfrm_vec[i].encap_family = mp->new_family;
90997 /* flush bundles */
90998 - atomic_inc(&pol->genid);
90999 + atomic_inc_unchecked(&pol->genid);
91000 }
91001 }
91002
91003 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91004 index 3459692..e7cdb1a 100644
91005 --- a/net/xfrm/xfrm_state.c
91006 +++ b/net/xfrm/xfrm_state.c
91007 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91008
91009 if (unlikely(afinfo == NULL))
91010 return -EAFNOSUPPORT;
91011 - typemap = afinfo->type_map;
91012 + typemap = (const struct xfrm_type **)afinfo->type_map;
91013
91014 - if (likely(typemap[type->proto] == NULL))
91015 + if (likely(typemap[type->proto] == NULL)) {
91016 + pax_open_kernel();
91017 typemap[type->proto] = type;
91018 - else
91019 + pax_close_kernel();
91020 + } else
91021 err = -EEXIST;
91022 xfrm_state_unlock_afinfo(afinfo);
91023 return err;
91024 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91025
91026 if (unlikely(afinfo == NULL))
91027 return -EAFNOSUPPORT;
91028 - typemap = afinfo->type_map;
91029 + typemap = (const struct xfrm_type **)afinfo->type_map;
91030
91031 if (unlikely(typemap[type->proto] != type))
91032 err = -ENOENT;
91033 - else
91034 + else {
91035 + pax_open_kernel();
91036 typemap[type->proto] = NULL;
91037 + pax_close_kernel();
91038 + }
91039 xfrm_state_unlock_afinfo(afinfo);
91040 return err;
91041 }
91042 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91043 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91044 {
91045 struct xfrm_state_afinfo *afinfo;
91046 - const struct xfrm_type **typemap;
91047 const struct xfrm_type *type;
91048 int modload_attempted = 0;
91049
91050 @@ -235,9 +239,8 @@ retry:
91051 afinfo = xfrm_state_get_afinfo(family);
91052 if (unlikely(afinfo == NULL))
91053 return NULL;
91054 - typemap = afinfo->type_map;
91055
91056 - type = typemap[proto];
91057 + type = afinfo->type_map[proto];
91058 if (unlikely(type && !try_module_get(type->owner)))
91059 type = NULL;
91060 if (!type && !modload_attempted) {
91061 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91062 return -EAFNOSUPPORT;
91063
91064 err = -EEXIST;
91065 - modemap = afinfo->mode_map;
91066 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91067 if (modemap[mode->encap])
91068 goto out;
91069
91070 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91071 if (!try_module_get(afinfo->owner))
91072 goto out;
91073
91074 - mode->afinfo = afinfo;
91075 + pax_open_kernel();
91076 + *(const void **)&mode->afinfo = afinfo;
91077 modemap[mode->encap] = mode;
91078 + pax_close_kernel();
91079 err = 0;
91080
91081 out:
91082 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91083 return -EAFNOSUPPORT;
91084
91085 err = -ENOENT;
91086 - modemap = afinfo->mode_map;
91087 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91088 if (likely(modemap[mode->encap] == mode)) {
91089 + pax_open_kernel();
91090 modemap[mode->encap] = NULL;
91091 + pax_close_kernel();
91092 module_put(mode->afinfo->owner);
91093 err = 0;
91094 }
91095 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91096 index 05a6e3d..6716ec9 100644
91097 --- a/net/xfrm/xfrm_sysctl.c
91098 +++ b/net/xfrm/xfrm_sysctl.c
91099 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91100
91101 int __net_init xfrm_sysctl_init(struct net *net)
91102 {
91103 - struct ctl_table *table;
91104 + ctl_table_no_const *table;
91105
91106 __xfrm_sysctl_init(net);
91107
91108 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91109 index 0e801c3..5c8ad3b 100644
91110 --- a/scripts/Makefile.build
91111 +++ b/scripts/Makefile.build
91112 @@ -111,7 +111,7 @@ endif
91113 endif
91114
91115 # Do not include host rules unless needed
91116 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91117 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91118 include scripts/Makefile.host
91119 endif
91120
91121 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91122 index 686cb0d..9d653bf 100644
91123 --- a/scripts/Makefile.clean
91124 +++ b/scripts/Makefile.clean
91125 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91126 __clean-files := $(extra-y) $(always) \
91127 $(targets) $(clean-files) \
91128 $(host-progs) \
91129 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91130 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91131 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91132
91133 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91134
91135 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91136 index 1ac414f..38575f7 100644
91137 --- a/scripts/Makefile.host
91138 +++ b/scripts/Makefile.host
91139 @@ -31,6 +31,8 @@
91140 # Note: Shared libraries consisting of C++ files are not supported
91141
91142 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91143 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91144 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91145
91146 # C code
91147 # Executables compiled from a single .c file
91148 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91149 # Shared libaries (only .c supported)
91150 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91151 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91152 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91153 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91154 # Remove .so files from "xxx-objs"
91155 host-cobjs := $(filter-out %.so,$(host-cobjs))
91156 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91157
91158 -#Object (.o) files used by the shared libaries
91159 +# Object (.o) files used by the shared libaries
91160 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91161 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91162
91163 # output directory for programs/.o files
91164 # hostprogs-y := tools/build may have been specified. Retrieve directory
91165 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91166 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91167 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91168 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91169 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91170 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91171 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91172 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91173
91174 obj-dirs += $(host-objdirs)
91175 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91176 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91177 $(call if_changed_dep,host-cshobjs)
91178
91179 +# Compile .c file, create position independent .o file
91180 +# host-cxxshobjs -> .o
91181 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91182 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91183 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91184 + $(call if_changed_dep,host-cxxshobjs)
91185 +
91186 # Link a shared library, based on position independent .o files
91187 # *.o -> .so shared library (host-cshlib)
91188 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91189 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91190 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91191 $(call if_changed,host-cshlib)
91192
91193 +# Link a shared library, based on position independent .o files
91194 +# *.o -> .so shared library (host-cxxshlib)
91195 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91196 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91197 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91198 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91199 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91200 + $(call if_changed,host-cxxshlib)
91201 +
91202 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91203 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91204 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91205
91206 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91207 index cb1f50c..cef2a7c 100644
91208 --- a/scripts/basic/fixdep.c
91209 +++ b/scripts/basic/fixdep.c
91210 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91211 /*
91212 * Lookup a value in the configuration string.
91213 */
91214 -static int is_defined_config(const char *name, int len, unsigned int hash)
91215 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91216 {
91217 struct item *aux;
91218
91219 @@ -211,10 +211,10 @@ static void clear_config(void)
91220 /*
91221 * Record the use of a CONFIG_* word.
91222 */
91223 -static void use_config(const char *m, int slen)
91224 +static void use_config(const char *m, unsigned int slen)
91225 {
91226 unsigned int hash = strhash(m, slen);
91227 - int c, i;
91228 + unsigned int c, i;
91229
91230 if (is_defined_config(m, slen, hash))
91231 return;
91232 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91233
91234 static void parse_config_file(const char *map, size_t len)
91235 {
91236 - const int *end = (const int *) (map + len);
91237 + const unsigned int *end = (const unsigned int *) (map + len);
91238 /* start at +1, so that p can never be < map */
91239 - const int *m = (const int *) map + 1;
91240 + const unsigned int *m = (const unsigned int *) map + 1;
91241 const char *p, *q;
91242
91243 for (; m < end; m++) {
91244 @@ -406,7 +406,7 @@ static void print_deps(void)
91245 static void traps(void)
91246 {
91247 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91248 - int *p = (int *)test;
91249 + unsigned int *p = (unsigned int *)test;
91250
91251 if (*p != INT_CONF) {
91252 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91253 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91254 new file mode 100644
91255 index 0000000..5e0222d
91256 --- /dev/null
91257 +++ b/scripts/gcc-plugin.sh
91258 @@ -0,0 +1,17 @@
91259 +#!/bin/bash
91260 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91261 +#include "gcc-plugin.h"
91262 +#include "tree.h"
91263 +#include "tm.h"
91264 +#include "rtl.h"
91265 +#ifdef ENABLE_BUILD_WITH_CXX
91266 +#warning $2
91267 +#else
91268 +#warning $1
91269 +#endif
91270 +EOF`
91271 +if [ $? -eq 0 ]
91272 +then
91273 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91274 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91275 +fi
91276 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91277 index 581ca99..a6ff02e 100644
91278 --- a/scripts/headers_install.pl
91279 +++ b/scripts/headers_install.pl
91280 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91281 $line =~ s/([\s(])__user\s/$1/g;
91282 $line =~ s/([\s(])__force\s/$1/g;
91283 $line =~ s/([\s(])__iomem\s/$1/g;
91284 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91285 $line =~ s/\s__attribute_const__\s/ /g;
91286 $line =~ s/\s__attribute_const__$//g;
91287 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91288 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91289 index b3d907e..a4782ab 100644
91290 --- a/scripts/link-vmlinux.sh
91291 +++ b/scripts/link-vmlinux.sh
91292 @@ -152,7 +152,7 @@ else
91293 fi;
91294
91295 # final build of init/
91296 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91297 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91298
91299 kallsymso=""
91300 kallsyms_vmlinux=""
91301 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91302 index df4fc23..0ea719d 100644
91303 --- a/scripts/mod/file2alias.c
91304 +++ b/scripts/mod/file2alias.c
91305 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91306 unsigned long size, unsigned long id_size,
91307 void *symval)
91308 {
91309 - int i;
91310 + unsigned int i;
91311
91312 if (size % id_size || size < id_size) {
91313 if (cross_build != 0)
91314 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91315 /* USB is special because the bcdDevice can be matched against a numeric range */
91316 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91317 static void do_usb_entry(struct usb_device_id *id,
91318 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91319 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91320 unsigned char range_lo, unsigned char range_hi,
91321 unsigned char max, struct module *mod)
91322 {
91323 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91324 {
91325 unsigned int devlo, devhi;
91326 unsigned char chi, clo, max;
91327 - int ndigits;
91328 + unsigned int ndigits;
91329
91330 id->match_flags = TO_NATIVE(id->match_flags);
91331 id->idVendor = TO_NATIVE(id->idVendor);
91332 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91333 for (i = 0; i < count; i++) {
91334 const char *id = (char *)devs[i].id;
91335 char acpi_id[sizeof(devs[0].id)];
91336 - int j;
91337 + unsigned int j;
91338
91339 buf_printf(&mod->dev_table_buf,
91340 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91341 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91342
91343 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91344 const char *id = (char *)card->devs[j].id;
91345 - int i2, j2;
91346 + unsigned int i2, j2;
91347 int dup = 0;
91348
91349 if (!id[0])
91350 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91351 /* add an individual alias for every device entry */
91352 if (!dup) {
91353 char acpi_id[sizeof(card->devs[0].id)];
91354 - int k;
91355 + unsigned int k;
91356
91357 buf_printf(&mod->dev_table_buf,
91358 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91359 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91360 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91361 char *alias)
91362 {
91363 - int i, j;
91364 + unsigned int i, j;
91365
91366 sprintf(alias, "dmi*");
91367
91368 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91369 index ff36c50..7ab4fa9 100644
91370 --- a/scripts/mod/modpost.c
91371 +++ b/scripts/mod/modpost.c
91372 @@ -929,6 +929,7 @@ enum mismatch {
91373 ANY_INIT_TO_ANY_EXIT,
91374 ANY_EXIT_TO_ANY_INIT,
91375 EXPORT_TO_INIT_EXIT,
91376 + DATA_TO_TEXT
91377 };
91378
91379 struct sectioncheck {
91380 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91381 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91382 .mismatch = EXPORT_TO_INIT_EXIT,
91383 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91384 +},
91385 +/* Do not reference code from writable data */
91386 +{
91387 + .fromsec = { DATA_SECTIONS, NULL },
91388 + .tosec = { TEXT_SECTIONS, NULL },
91389 + .mismatch = DATA_TO_TEXT
91390 }
91391 };
91392
91393 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91394 continue;
91395 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91396 continue;
91397 - if (sym->st_value == addr)
91398 - return sym;
91399 /* Find a symbol nearby - addr are maybe negative */
91400 d = sym->st_value - addr;
91401 + if (d == 0)
91402 + return sym;
91403 if (d < 0)
91404 d = addr - sym->st_value;
91405 if (d < distance) {
91406 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91407 tosym, prl_to, prl_to, tosym);
91408 free(prl_to);
91409 break;
91410 + case DATA_TO_TEXT:
91411 +#if 0
91412 + fprintf(stderr,
91413 + "The %s %s:%s references\n"
91414 + "the %s %s:%s%s\n",
91415 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91416 +#endif
91417 + break;
91418 }
91419 fprintf(stderr, "\n");
91420 }
91421 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91422 static void check_sec_ref(struct module *mod, const char *modname,
91423 struct elf_info *elf)
91424 {
91425 - int i;
91426 + unsigned int i;
91427 Elf_Shdr *sechdrs = elf->sechdrs;
91428
91429 /* Walk through all sections */
91430 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91431 va_end(ap);
91432 }
91433
91434 -void buf_write(struct buffer *buf, const char *s, int len)
91435 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91436 {
91437 if (buf->size - buf->pos < len) {
91438 buf->size += len + SZ;
91439 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91440 if (fstat(fileno(file), &st) < 0)
91441 goto close_write;
91442
91443 - if (st.st_size != b->pos)
91444 + if (st.st_size != (off_t)b->pos)
91445 goto close_write;
91446
91447 tmp = NOFAIL(malloc(b->pos));
91448 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91449 index 51207e4..f7d603d 100644
91450 --- a/scripts/mod/modpost.h
91451 +++ b/scripts/mod/modpost.h
91452 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91453
91454 struct buffer {
91455 char *p;
91456 - int pos;
91457 - int size;
91458 + unsigned int pos;
91459 + unsigned int size;
91460 };
91461
91462 void __attribute__((format(printf, 2, 3)))
91463 buf_printf(struct buffer *buf, const char *fmt, ...);
91464
91465 void
91466 -buf_write(struct buffer *buf, const char *s, int len);
91467 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91468
91469 struct module {
91470 struct module *next;
91471 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91472 index 9dfcd6d..099068e 100644
91473 --- a/scripts/mod/sumversion.c
91474 +++ b/scripts/mod/sumversion.c
91475 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91476 goto out;
91477 }
91478
91479 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91480 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91481 warn("writing sum in %s failed: %s\n",
91482 filename, strerror(errno));
91483 goto out;
91484 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91485 index acb8650..b8c5f02 100644
91486 --- a/scripts/package/builddeb
91487 +++ b/scripts/package/builddeb
91488 @@ -246,6 +246,7 @@ fi
91489 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91490 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91491 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91492 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91493 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91494 mkdir -p "$destdir"
91495 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91496 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91497 index 68bb4ef..2f419e1 100644
91498 --- a/scripts/pnmtologo.c
91499 +++ b/scripts/pnmtologo.c
91500 @@ -244,14 +244,14 @@ static void write_header(void)
91501 fprintf(out, " * Linux logo %s\n", logoname);
91502 fputs(" */\n\n", out);
91503 fputs("#include <linux/linux_logo.h>\n\n", out);
91504 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91505 + fprintf(out, "static unsigned char %s_data[] = {\n",
91506 logoname);
91507 }
91508
91509 static void write_footer(void)
91510 {
91511 fputs("\n};\n\n", out);
91512 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91513 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91514 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91515 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91516 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91517 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91518 fputs("\n};\n\n", out);
91519
91520 /* write logo clut */
91521 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91522 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91523 logoname);
91524 write_hex_cnt = 0;
91525 for (i = 0; i < logo_clutsize; i++) {
91526 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91527 index e4fd45b..2eeb5c4 100644
91528 --- a/scripts/sortextable.h
91529 +++ b/scripts/sortextable.h
91530 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91531 const char *secstrtab;
91532 const char *strtab;
91533 char *extab_image;
91534 - int extab_index = 0;
91535 - int i;
91536 - int idx;
91537 + unsigned int extab_index = 0;
91538 + unsigned int i;
91539 + unsigned int idx;
91540
91541 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91542 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91543 diff --git a/security/Kconfig b/security/Kconfig
91544 index e9c6ac7..eef8ada 100644
91545 --- a/security/Kconfig
91546 +++ b/security/Kconfig
91547 @@ -4,6 +4,943 @@
91548
91549 menu "Security options"
91550
91551 +menu "Grsecurity"
91552 +
91553 + config ARCH_TRACK_EXEC_LIMIT
91554 + bool
91555 +
91556 + config PAX_KERNEXEC_PLUGIN
91557 + bool
91558 +
91559 + config PAX_PER_CPU_PGD
91560 + bool
91561 +
91562 + config TASK_SIZE_MAX_SHIFT
91563 + int
91564 + depends on X86_64
91565 + default 47 if !PAX_PER_CPU_PGD
91566 + default 42 if PAX_PER_CPU_PGD
91567 +
91568 + config PAX_ENABLE_PAE
91569 + bool
91570 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91571 +
91572 + config PAX_USERCOPY_SLABS
91573 + bool
91574 +
91575 +config GRKERNSEC
91576 + bool "Grsecurity"
91577 + select CRYPTO
91578 + select CRYPTO_SHA256
91579 + select PROC_FS
91580 + select STOP_MACHINE
91581 + help
91582 + If you say Y here, you will be able to configure many features
91583 + that will enhance the security of your system. It is highly
91584 + recommended that you say Y here and read through the help
91585 + for each option so that you fully understand the features and
91586 + can evaluate their usefulness for your machine.
91587 +
91588 +choice
91589 + prompt "Configuration Method"
91590 + depends on GRKERNSEC
91591 + default GRKERNSEC_CONFIG_CUSTOM
91592 + help
91593 +
91594 +config GRKERNSEC_CONFIG_AUTO
91595 + bool "Automatic"
91596 + help
91597 + If you choose this configuration method, you'll be able to answer a small
91598 + number of simple questions about how you plan to use this kernel.
91599 + The settings of grsecurity and PaX will be automatically configured for
91600 + the highest commonly-used settings within the provided constraints.
91601 +
91602 + If you require additional configuration, custom changes can still be made
91603 + from the "custom configuration" menu.
91604 +
91605 +config GRKERNSEC_CONFIG_CUSTOM
91606 + bool "Custom"
91607 + help
91608 + If you choose this configuration method, you'll be able to configure all
91609 + grsecurity and PaX settings manually. Via this method, no options are
91610 + automatically enabled.
91611 +
91612 +endchoice
91613 +
91614 +choice
91615 + prompt "Usage Type"
91616 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91617 + default GRKERNSEC_CONFIG_SERVER
91618 + help
91619 +
91620 +config GRKERNSEC_CONFIG_SERVER
91621 + bool "Server"
91622 + help
91623 + Choose this option if you plan to use this kernel on a server.
91624 +
91625 +config GRKERNSEC_CONFIG_DESKTOP
91626 + bool "Desktop"
91627 + help
91628 + Choose this option if you plan to use this kernel on a desktop.
91629 +
91630 +endchoice
91631 +
91632 +choice
91633 + prompt "Virtualization Type"
91634 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91635 + default GRKERNSEC_CONFIG_VIRT_NONE
91636 + help
91637 +
91638 +config GRKERNSEC_CONFIG_VIRT_NONE
91639 + bool "None"
91640 + help
91641 + Choose this option if this kernel will be run on bare metal.
91642 +
91643 +config GRKERNSEC_CONFIG_VIRT_GUEST
91644 + bool "Guest"
91645 + help
91646 + Choose this option if this kernel will be run as a VM guest.
91647 +
91648 +config GRKERNSEC_CONFIG_VIRT_HOST
91649 + bool "Host"
91650 + help
91651 + Choose this option if this kernel will be run as a VM host.
91652 +
91653 +endchoice
91654 +
91655 +choice
91656 + prompt "Virtualization Hardware"
91657 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91658 + help
91659 +
91660 +config GRKERNSEC_CONFIG_VIRT_EPT
91661 + bool "EPT/RVI Processor Support"
91662 + depends on X86
91663 + help
91664 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91665 + hardware virtualization. This allows for additional kernel hardening protections
91666 + to operate without additional performance impact.
91667 +
91668 + To see if your Intel processor supports EPT, see:
91669 + http://ark.intel.com/Products/VirtualizationTechnology
91670 + (Most Core i3/5/7 support EPT)
91671 +
91672 + To see if your AMD processor supports RVI, see:
91673 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91674 +
91675 +config GRKERNSEC_CONFIG_VIRT_SOFT
91676 + bool "First-gen/No Hardware Virtualization"
91677 + help
91678 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91679 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91680 +
91681 +endchoice
91682 +
91683 +choice
91684 + prompt "Virtualization Software"
91685 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91686 + help
91687 +
91688 +config GRKERNSEC_CONFIG_VIRT_XEN
91689 + bool "Xen"
91690 + help
91691 + Choose this option if this kernel is running as a Xen guest or host.
91692 +
91693 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91694 + bool "VMWare"
91695 + help
91696 + Choose this option if this kernel is running as a VMWare guest or host.
91697 +
91698 +config GRKERNSEC_CONFIG_VIRT_KVM
91699 + bool "KVM"
91700 + help
91701 + Choose this option if this kernel is running as a KVM guest or host.
91702 +
91703 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91704 + bool "VirtualBox"
91705 + help
91706 + Choose this option if this kernel is running as a VirtualBox guest or host.
91707 +
91708 +endchoice
91709 +
91710 +choice
91711 + prompt "Required Priorities"
91712 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91713 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91714 + help
91715 +
91716 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91717 + bool "Performance"
91718 + help
91719 + Choose this option if performance is of highest priority for this deployment
91720 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91721 + clearing of structures intended for userland, and freed memory sanitizing will
91722 + be disabled.
91723 +
91724 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91725 + bool "Security"
91726 + help
91727 + Choose this option if security is of highest priority for this deployment of
91728 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91729 + for userland, and freed memory sanitizing will be enabled for this kernel.
91730 + In a worst-case scenario, these features can introduce a 20% performance hit
91731 + (UDEREF on x64 contributing half of this hit).
91732 +
91733 +endchoice
91734 +
91735 +menu "Default Special Groups"
91736 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91737 +
91738 +config GRKERNSEC_PROC_GID
91739 + int "GID exempted from /proc restrictions"
91740 + default 1001
91741 + help
91742 + Setting this GID determines which group will be exempted from
91743 + grsecurity's /proc restrictions, allowing users of the specified
91744 + group to view network statistics and the existence of other users'
91745 + processes on the system. This GID may also be chosen at boot time
91746 + via "grsec_proc_gid=" on the kernel commandline.
91747 +
91748 +config GRKERNSEC_TPE_UNTRUSTED_GID
91749 + int "GID for TPE-untrusted users"
91750 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91751 + default 1005
91752 + help
91753 + Setting this GID determines which group untrusted users should
91754 + be added to. These users will be placed under grsecurity's Trusted Path
91755 + Execution mechanism, preventing them from executing their own binaries.
91756 + The users will only be able to execute binaries in directories owned and
91757 + writable only by the root user. If the sysctl option is enabled, a sysctl
91758 + option with name "tpe_gid" is created.
91759 +
91760 +config GRKERNSEC_TPE_TRUSTED_GID
91761 + int "GID for TPE-trusted users"
91762 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91763 + default 1005
91764 + help
91765 + Setting this GID determines what group TPE restrictions will be
91766 + *disabled* for. If the sysctl option is enabled, a sysctl option
91767 + with name "tpe_gid" is created.
91768 +
91769 +config GRKERNSEC_SYMLINKOWN_GID
91770 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91771 + depends on GRKERNSEC_CONFIG_SERVER
91772 + default 1006
91773 + help
91774 + Setting this GID determines what group kernel-enforced
91775 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91776 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91777 +
91778 +
91779 +endmenu
91780 +
91781 +menu "Customize Configuration"
91782 +depends on GRKERNSEC
91783 +
91784 +menu "PaX"
91785 +
91786 +config PAX
91787 + bool "Enable various PaX features"
91788 + default y if GRKERNSEC_CONFIG_AUTO
91789 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91790 + help
91791 + This allows you to enable various PaX features. PaX adds
91792 + intrusion prevention mechanisms to the kernel that reduce
91793 + the risks posed by exploitable memory corruption bugs.
91794 +
91795 +menu "PaX Control"
91796 + depends on PAX
91797 +
91798 +config PAX_SOFTMODE
91799 + bool 'Support soft mode'
91800 + help
91801 + Enabling this option will allow you to run PaX in soft mode, that
91802 + is, PaX features will not be enforced by default, only on executables
91803 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91804 + support as they are the only way to mark executables for soft mode use.
91805 +
91806 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91807 + line option on boot. Furthermore you can control various PaX features
91808 + at runtime via the entries in /proc/sys/kernel/pax.
91809 +
91810 +config PAX_EI_PAX
91811 + bool 'Use legacy ELF header marking'
91812 + default y if GRKERNSEC_CONFIG_AUTO
91813 + help
91814 + Enabling this option will allow you to control PaX features on
91815 + a per executable basis via the 'chpax' utility available at
91816 + http://pax.grsecurity.net/. The control flags will be read from
91817 + an otherwise reserved part of the ELF header. This marking has
91818 + numerous drawbacks (no support for soft-mode, toolchain does not
91819 + know about the non-standard use of the ELF header) therefore it
91820 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91821 + support.
91822 +
91823 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91824 + support as well, they will override the legacy EI_PAX marks.
91825 +
91826 + If you enable none of the marking options then all applications
91827 + will run with PaX enabled on them by default.
91828 +
91829 +config PAX_PT_PAX_FLAGS
91830 + bool 'Use ELF program header marking'
91831 + default y if GRKERNSEC_CONFIG_AUTO
91832 + help
91833 + Enabling this option will allow you to control PaX features on
91834 + a per executable basis via the 'paxctl' utility available at
91835 + http://pax.grsecurity.net/. The control flags will be read from
91836 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91837 + has the benefits of supporting both soft mode and being fully
91838 + integrated into the toolchain (the binutils patch is available
91839 + from http://pax.grsecurity.net).
91840 +
91841 + Note that if you enable the legacy EI_PAX marking support as well,
91842 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91843 +
91844 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91845 + must make sure that the marks are the same if a binary has both marks.
91846 +
91847 + If you enable none of the marking options then all applications
91848 + will run with PaX enabled on them by default.
91849 +
91850 +config PAX_XATTR_PAX_FLAGS
91851 + bool 'Use filesystem extended attributes marking'
91852 + default y if GRKERNSEC_CONFIG_AUTO
91853 + select CIFS_XATTR if CIFS
91854 + select EXT2_FS_XATTR if EXT2_FS
91855 + select EXT3_FS_XATTR if EXT3_FS
91856 + select EXT4_FS_XATTR if EXT4_FS
91857 + select JFFS2_FS_XATTR if JFFS2_FS
91858 + select REISERFS_FS_XATTR if REISERFS_FS
91859 + select SQUASHFS_XATTR if SQUASHFS
91860 + select TMPFS_XATTR if TMPFS
91861 + select UBIFS_FS_XATTR if UBIFS_FS
91862 + help
91863 + Enabling this option will allow you to control PaX features on
91864 + a per executable basis via the 'setfattr' utility. The control
91865 + flags will be read from the user.pax.flags extended attribute of
91866 + the file. This marking has the benefit of supporting binary-only
91867 + applications that self-check themselves (e.g., skype) and would
91868 + not tolerate chpax/paxctl changes. The main drawback is that
91869 + extended attributes are not supported by some filesystems (e.g.,
91870 + isofs, udf, vfat) so copying files through such filesystems will
91871 + lose the extended attributes and these PaX markings.
91872 +
91873 + Note that if you enable the legacy EI_PAX marking support as well,
91874 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91875 +
91876 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91877 + must make sure that the marks are the same if a binary has both marks.
91878 +
91879 + If you enable none of the marking options then all applications
91880 + will run with PaX enabled on them by default.
91881 +
91882 +choice
91883 + prompt 'MAC system integration'
91884 + default PAX_HAVE_ACL_FLAGS
91885 + help
91886 + Mandatory Access Control systems have the option of controlling
91887 + PaX flags on a per executable basis, choose the method supported
91888 + by your particular system.
91889 +
91890 + - "none": if your MAC system does not interact with PaX,
91891 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91892 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91893 +
91894 + NOTE: this option is for developers/integrators only.
91895 +
91896 + config PAX_NO_ACL_FLAGS
91897 + bool 'none'
91898 +
91899 + config PAX_HAVE_ACL_FLAGS
91900 + bool 'direct'
91901 +
91902 + config PAX_HOOK_ACL_FLAGS
91903 + bool 'hook'
91904 +endchoice
91905 +
91906 +endmenu
91907 +
91908 +menu "Non-executable pages"
91909 + depends on PAX
91910 +
91911 +config PAX_NOEXEC
91912 + bool "Enforce non-executable pages"
91913 + default y if GRKERNSEC_CONFIG_AUTO
91914 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91915 + help
91916 + By design some architectures do not allow for protecting memory
91917 + pages against execution or even if they do, Linux does not make
91918 + use of this feature. In practice this means that if a page is
91919 + readable (such as the stack or heap) it is also executable.
91920 +
91921 + There is a well known exploit technique that makes use of this
91922 + fact and a common programming mistake where an attacker can
91923 + introduce code of his choice somewhere in the attacked program's
91924 + memory (typically the stack or the heap) and then execute it.
91925 +
91926 + If the attacked program was running with different (typically
91927 + higher) privileges than that of the attacker, then he can elevate
91928 + his own privilege level (e.g. get a root shell, write to files for
91929 + which he does not have write access to, etc).
91930 +
91931 + Enabling this option will let you choose from various features
91932 + that prevent the injection and execution of 'foreign' code in
91933 + a program.
91934 +
91935 + This will also break programs that rely on the old behaviour and
91936 + expect that dynamically allocated memory via the malloc() family
91937 + of functions is executable (which it is not). Notable examples
91938 + are the XFree86 4.x server, the java runtime and wine.
91939 +
91940 +config PAX_PAGEEXEC
91941 + bool "Paging based non-executable pages"
91942 + default y if GRKERNSEC_CONFIG_AUTO
91943 + 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)
91944 + select S390_SWITCH_AMODE if S390
91945 + select S390_EXEC_PROTECT if S390
91946 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91947 + help
91948 + This implementation is based on the paging feature of the CPU.
91949 + On i386 without hardware non-executable bit support there is a
91950 + variable but usually low performance impact, however on Intel's
91951 + P4 core based CPUs it is very high so you should not enable this
91952 + for kernels meant to be used on such CPUs.
91953 +
91954 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91955 + with hardware non-executable bit support there is no performance
91956 + impact, on ppc the impact is negligible.
91957 +
91958 + Note that several architectures require various emulations due to
91959 + badly designed userland ABIs, this will cause a performance impact
91960 + but will disappear as soon as userland is fixed. For example, ppc
91961 + userland MUST have been built with secure-plt by a recent toolchain.
91962 +
91963 +config PAX_SEGMEXEC
91964 + bool "Segmentation based non-executable pages"
91965 + default y if GRKERNSEC_CONFIG_AUTO
91966 + depends on PAX_NOEXEC && X86_32
91967 + help
91968 + This implementation is based on the segmentation feature of the
91969 + CPU and has a very small performance impact, however applications
91970 + will be limited to a 1.5 GB address space instead of the normal
91971 + 3 GB.
91972 +
91973 +config PAX_EMUTRAMP
91974 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91975 + default y if PARISC
91976 + help
91977 + There are some programs and libraries that for one reason or
91978 + another attempt to execute special small code snippets from
91979 + non-executable memory pages. Most notable examples are the
91980 + signal handler return code generated by the kernel itself and
91981 + the GCC trampolines.
91982 +
91983 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91984 + such programs will no longer work under your kernel.
91985 +
91986 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91987 + utilities to enable trampoline emulation for the affected programs
91988 + yet still have the protection provided by the non-executable pages.
91989 +
91990 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91991 + your system will not even boot.
91992 +
91993 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91994 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91995 + for the affected files.
91996 +
91997 + NOTE: enabling this feature *may* open up a loophole in the
91998 + protection provided by non-executable pages that an attacker
91999 + could abuse. Therefore the best solution is to not have any
92000 + files on your system that would require this option. This can
92001 + be achieved by not using libc5 (which relies on the kernel
92002 + signal handler return code) and not using or rewriting programs
92003 + that make use of the nested function implementation of GCC.
92004 + Skilled users can just fix GCC itself so that it implements
92005 + nested function calls in a way that does not interfere with PaX.
92006 +
92007 +config PAX_EMUSIGRT
92008 + bool "Automatically emulate sigreturn trampolines"
92009 + depends on PAX_EMUTRAMP && PARISC
92010 + default y
92011 + help
92012 + Enabling this option will have the kernel automatically detect
92013 + and emulate signal return trampolines executing on the stack
92014 + that would otherwise lead to task termination.
92015 +
92016 + This solution is intended as a temporary one for users with
92017 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92018 + Modula-3 runtime, etc) or executables linked to such, basically
92019 + everything that does not specify its own SA_RESTORER function in
92020 + normal executable memory like glibc 2.1+ does.
92021 +
92022 + On parisc you MUST enable this option, otherwise your system will
92023 + not even boot.
92024 +
92025 + NOTE: this feature cannot be disabled on a per executable basis
92026 + and since it *does* open up a loophole in the protection provided
92027 + by non-executable pages, the best solution is to not have any
92028 + files on your system that would require this option.
92029 +
92030 +config PAX_MPROTECT
92031 + bool "Restrict mprotect()"
92032 + default y if GRKERNSEC_CONFIG_AUTO
92033 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92034 + help
92035 + Enabling this option will prevent programs from
92036 + - changing the executable status of memory pages that were
92037 + not originally created as executable,
92038 + - making read-only executable pages writable again,
92039 + - creating executable pages from anonymous memory,
92040 + - making read-only-after-relocations (RELRO) data pages writable again.
92041 +
92042 + You should say Y here to complete the protection provided by
92043 + the enforcement of non-executable pages.
92044 +
92045 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92046 + this feature on a per file basis.
92047 +
92048 +config PAX_MPROTECT_COMPAT
92049 + bool "Use legacy/compat protection demoting (read help)"
92050 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92051 + depends on PAX_MPROTECT
92052 + help
92053 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92054 + by sending the proper error code to the application. For some broken
92055 + userland, this can cause problems with Python or other applications. The
92056 + current implementation however allows for applications like clamav to
92057 + detect if JIT compilation/execution is allowed and to fall back gracefully
92058 + to an interpreter-based mode if it does not. While we encourage everyone
92059 + to use the current implementation as-is and push upstream to fix broken
92060 + userland (note that the RWX logging option can assist with this), in some
92061 + environments this may not be possible. Having to disable MPROTECT
92062 + completely on certain binaries reduces the security benefit of PaX,
92063 + so this option is provided for those environments to revert to the old
92064 + behavior.
92065 +
92066 +config PAX_ELFRELOCS
92067 + bool "Allow ELF text relocations (read help)"
92068 + depends on PAX_MPROTECT
92069 + default n
92070 + help
92071 + Non-executable pages and mprotect() restrictions are effective
92072 + in preventing the introduction of new executable code into an
92073 + attacked task's address space. There remain only two venues
92074 + for this kind of attack: if the attacker can execute already
92075 + existing code in the attacked task then he can either have it
92076 + create and mmap() a file containing his code or have it mmap()
92077 + an already existing ELF library that does not have position
92078 + independent code in it and use mprotect() on it to make it
92079 + writable and copy his code there. While protecting against
92080 + the former approach is beyond PaX, the latter can be prevented
92081 + by having only PIC ELF libraries on one's system (which do not
92082 + need to relocate their code). If you are sure this is your case,
92083 + as is the case with all modern Linux distributions, then leave
92084 + this option disabled. You should say 'n' here.
92085 +
92086 +config PAX_ETEXECRELOCS
92087 + bool "Allow ELF ET_EXEC text relocations"
92088 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92089 + select PAX_ELFRELOCS
92090 + default y
92091 + help
92092 + On some architectures there are incorrectly created applications
92093 + that require text relocations and would not work without enabling
92094 + this option. If you are an alpha, ia64 or parisc user, you should
92095 + enable this option and disable it once you have made sure that
92096 + none of your applications need it.
92097 +
92098 +config PAX_EMUPLT
92099 + bool "Automatically emulate ELF PLT"
92100 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92101 + default y
92102 + help
92103 + Enabling this option will have the kernel automatically detect
92104 + and emulate the Procedure Linkage Table entries in ELF files.
92105 + On some architectures such entries are in writable memory, and
92106 + become non-executable leading to task termination. Therefore
92107 + it is mandatory that you enable this option on alpha, parisc,
92108 + sparc and sparc64, otherwise your system would not even boot.
92109 +
92110 + NOTE: this feature *does* open up a loophole in the protection
92111 + provided by the non-executable pages, therefore the proper
92112 + solution is to modify the toolchain to produce a PLT that does
92113 + not need to be writable.
92114 +
92115 +config PAX_DLRESOLVE
92116 + bool 'Emulate old glibc resolver stub'
92117 + depends on PAX_EMUPLT && SPARC
92118 + default n
92119 + help
92120 + This option is needed if userland has an old glibc (before 2.4)
92121 + that puts a 'save' instruction into the runtime generated resolver
92122 + stub that needs special emulation.
92123 +
92124 +config PAX_KERNEXEC
92125 + bool "Enforce non-executable kernel pages"
92126 + 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))
92127 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92128 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92129 + select PAX_KERNEXEC_PLUGIN if X86_64
92130 + help
92131 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92132 + that is, enabling this option will make it harder to inject
92133 + and execute 'foreign' code in kernel memory itself.
92134 +
92135 +choice
92136 + prompt "Return Address Instrumentation Method"
92137 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92138 + depends on PAX_KERNEXEC_PLUGIN
92139 + help
92140 + Select the method used to instrument function pointer dereferences.
92141 + Note that binary modules cannot be instrumented by this approach.
92142 +
92143 + Note that the implementation requires a gcc with plugin support,
92144 + i.e., gcc 4.5 or newer. You may need to install the supporting
92145 + headers explicitly in addition to the normal gcc package.
92146 +
92147 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92148 + bool "bts"
92149 + help
92150 + This method is compatible with binary only modules but has
92151 + a higher runtime overhead.
92152 +
92153 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92154 + bool "or"
92155 + depends on !PARAVIRT
92156 + help
92157 + This method is incompatible with binary only modules but has
92158 + a lower runtime overhead.
92159 +endchoice
92160 +
92161 +config PAX_KERNEXEC_PLUGIN_METHOD
92162 + string
92163 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92164 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92165 + default ""
92166 +
92167 +config PAX_KERNEXEC_MODULE_TEXT
92168 + int "Minimum amount of memory reserved for module code"
92169 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92170 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92171 + depends on PAX_KERNEXEC && X86_32 && MODULES
92172 + help
92173 + Due to implementation details the kernel must reserve a fixed
92174 + amount of memory for module code at compile time that cannot be
92175 + changed at runtime. Here you can specify the minimum amount
92176 + in MB that will be reserved. Due to the same implementation
92177 + details this size will always be rounded up to the next 2/4 MB
92178 + boundary (depends on PAE) so the actually available memory for
92179 + module code will usually be more than this minimum.
92180 +
92181 + The default 4 MB should be enough for most users but if you have
92182 + an excessive number of modules (e.g., most distribution configs
92183 + compile many drivers as modules) or use huge modules such as
92184 + nvidia's kernel driver, you will need to adjust this amount.
92185 + A good rule of thumb is to look at your currently loaded kernel
92186 + modules and add up their sizes.
92187 +
92188 +endmenu
92189 +
92190 +menu "Address Space Layout Randomization"
92191 + depends on PAX
92192 +
92193 +config PAX_ASLR
92194 + bool "Address Space Layout Randomization"
92195 + default y if GRKERNSEC_CONFIG_AUTO
92196 + help
92197 + Many if not most exploit techniques rely on the knowledge of
92198 + certain addresses in the attacked program. The following options
92199 + will allow the kernel to apply a certain amount of randomization
92200 + to specific parts of the program thereby forcing an attacker to
92201 + guess them in most cases. Any failed guess will most likely crash
92202 + the attacked program which allows the kernel to detect such attempts
92203 + and react on them. PaX itself provides no reaction mechanisms,
92204 + instead it is strongly encouraged that you make use of Nergal's
92205 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92206 + (http://www.grsecurity.net/) built-in crash detection features or
92207 + develop one yourself.
92208 +
92209 + By saying Y here you can choose to randomize the following areas:
92210 + - top of the task's kernel stack
92211 + - top of the task's userland stack
92212 + - base address for mmap() requests that do not specify one
92213 + (this includes all libraries)
92214 + - base address of the main executable
92215 +
92216 + It is strongly recommended to say Y here as address space layout
92217 + randomization has negligible impact on performance yet it provides
92218 + a very effective protection.
92219 +
92220 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92221 + this feature on a per file basis.
92222 +
92223 +config PAX_RANDKSTACK
92224 + bool "Randomize kernel stack base"
92225 + default y if GRKERNSEC_CONFIG_AUTO
92226 + depends on X86_TSC && X86
92227 + help
92228 + By saying Y here the kernel will randomize every task's kernel
92229 + stack on every system call. This will not only force an attacker
92230 + to guess it but also prevent him from making use of possible
92231 + leaked information about it.
92232 +
92233 + Since the kernel stack is a rather scarce resource, randomization
92234 + may cause unexpected stack overflows, therefore you should very
92235 + carefully test your system. Note that once enabled in the kernel
92236 + configuration, this feature cannot be disabled on a per file basis.
92237 +
92238 +config PAX_RANDUSTACK
92239 + bool "Randomize user stack base"
92240 + default y if GRKERNSEC_CONFIG_AUTO
92241 + depends on PAX_ASLR
92242 + help
92243 + By saying Y here the kernel will randomize every task's userland
92244 + stack. The randomization is done in two steps where the second
92245 + one may apply a big amount of shift to the top of the stack and
92246 + cause problems for programs that want to use lots of memory (more
92247 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92248 + For this reason the second step can be controlled by 'chpax' or
92249 + 'paxctl' on a per file basis.
92250 +
92251 +config PAX_RANDMMAP
92252 + bool "Randomize mmap() base"
92253 + default y if GRKERNSEC_CONFIG_AUTO
92254 + depends on PAX_ASLR
92255 + help
92256 + By saying Y here the kernel will use a randomized base address for
92257 + mmap() requests that do not specify one themselves. As a result
92258 + all dynamically loaded libraries will appear at random addresses
92259 + and therefore be harder to exploit by a technique where an attacker
92260 + attempts to execute library code for his purposes (e.g. spawn a
92261 + shell from an exploited program that is running at an elevated
92262 + privilege level).
92263 +
92264 + Furthermore, if a program is relinked as a dynamic ELF file, its
92265 + base address will be randomized as well, completing the full
92266 + randomization of the address space layout. Attacking such programs
92267 + becomes a guess game. You can find an example of doing this at
92268 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92269 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92270 +
92271 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92272 + feature on a per file basis.
92273 +
92274 +endmenu
92275 +
92276 +menu "Miscellaneous hardening features"
92277 +
92278 +config PAX_MEMORY_SANITIZE
92279 + bool "Sanitize all freed memory"
92280 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92281 + depends on !HIBERNATION
92282 + help
92283 + By saying Y here the kernel will erase memory pages as soon as they
92284 + are freed. This in turn reduces the lifetime of data stored in the
92285 + pages, making it less likely that sensitive information such as
92286 + passwords, cryptographic secrets, etc stay in memory for too long.
92287 +
92288 + This is especially useful for programs whose runtime is short, long
92289 + lived processes and the kernel itself benefit from this as long as
92290 + they operate on whole memory pages and ensure timely freeing of pages
92291 + that may hold sensitive information.
92292 +
92293 + The tradeoff is performance impact, on a single CPU system kernel
92294 + compilation sees a 3% slowdown, other systems and workloads may vary
92295 + and you are advised to test this feature on your expected workload
92296 + before deploying it.
92297 +
92298 + Note that this feature does not protect data stored in live pages,
92299 + e.g., process memory swapped to disk may stay there for a long time.
92300 +
92301 +config PAX_MEMORY_STACKLEAK
92302 + bool "Sanitize kernel stack"
92303 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92304 + depends on X86
92305 + help
92306 + By saying Y here the kernel will erase the kernel stack before it
92307 + returns from a system call. This in turn reduces the information
92308 + that a kernel stack leak bug can reveal.
92309 +
92310 + Note that such a bug can still leak information that was put on
92311 + the stack by the current system call (the one eventually triggering
92312 + the bug) but traces of earlier system calls on the kernel stack
92313 + cannot leak anymore.
92314 +
92315 + The tradeoff is performance impact: on a single CPU system kernel
92316 + compilation sees a 1% slowdown, other systems and workloads may vary
92317 + and you are advised to test this feature on your expected workload
92318 + before deploying it.
92319 +
92320 + Note that the full feature requires a gcc with plugin support,
92321 + i.e., gcc 4.5 or newer. You may need to install the supporting
92322 + headers explicitly in addition to the normal gcc package. Using
92323 + older gcc versions means that functions with large enough stack
92324 + frames may leave uninitialized memory behind that may be exposed
92325 + to a later syscall leaking the stack.
92326 +
92327 +config PAX_MEMORY_STRUCTLEAK
92328 + bool "Forcibly initialize local variables copied to userland"
92329 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92330 + help
92331 + By saying Y here the kernel will zero initialize some local
92332 + variables that are going to be copied to userland. This in
92333 + turn prevents unintended information leakage from the kernel
92334 + stack should later code forget to explicitly set all parts of
92335 + the copied variable.
92336 +
92337 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92338 + at a much smaller coverage.
92339 +
92340 + Note that the implementation requires a gcc with plugin support,
92341 + i.e., gcc 4.5 or newer. You may need to install the supporting
92342 + headers explicitly in addition to the normal gcc package.
92343 +
92344 +config PAX_MEMORY_UDEREF
92345 + bool "Prevent invalid userland pointer dereference"
92346 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92347 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92348 + select PAX_PER_CPU_PGD if X86_64
92349 + help
92350 + By saying Y here the kernel will be prevented from dereferencing
92351 + userland pointers in contexts where the kernel expects only kernel
92352 + pointers. This is both a useful runtime debugging feature and a
92353 + security measure that prevents exploiting a class of kernel bugs.
92354 +
92355 + The tradeoff is that some virtualization solutions may experience
92356 + a huge slowdown and therefore you should not enable this feature
92357 + for kernels meant to run in such environments. Whether a given VM
92358 + solution is affected or not is best determined by simply trying it
92359 + out, the performance impact will be obvious right on boot as this
92360 + mechanism engages from very early on. A good rule of thumb is that
92361 + VMs running on CPUs without hardware virtualization support (i.e.,
92362 + the majority of IA-32 CPUs) will likely experience the slowdown.
92363 +
92364 +config PAX_REFCOUNT
92365 + bool "Prevent various kernel object reference counter overflows"
92366 + default y if GRKERNSEC_CONFIG_AUTO
92367 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92368 + help
92369 + By saying Y here the kernel will detect and prevent overflowing
92370 + various (but not all) kinds of object reference counters. Such
92371 + overflows can normally occur due to bugs only and are often, if
92372 + not always, exploitable.
92373 +
92374 + The tradeoff is that data structures protected by an overflowed
92375 + refcount will never be freed and therefore will leak memory. Note
92376 + that this leak also happens even without this protection but in
92377 + that case the overflow can eventually trigger the freeing of the
92378 + data structure while it is still being used elsewhere, resulting
92379 + in the exploitable situation that this feature prevents.
92380 +
92381 + Since this has a negligible performance impact, you should enable
92382 + this feature.
92383 +
92384 +config PAX_CONSTIFY_PLUGIN
92385 + bool "Automatically constify eligible structures"
92386 + default y
92387 + depends on !UML && PAX_KERNEXEC
92388 + help
92389 + By saying Y here the compiler will automatically constify a class
92390 + of types that contain only function pointers. This reduces the
92391 + kernel's attack surface and also produces a better memory layout.
92392 +
92393 + Note that the implementation requires a gcc with plugin support,
92394 + i.e., gcc 4.5 or newer. You may need to install the supporting
92395 + headers explicitly in addition to the normal gcc package.
92396 +
92397 + Note that if some code really has to modify constified variables
92398 + then the source code will have to be patched to allow it. Examples
92399 + can be found in PaX itself (the no_const attribute) and for some
92400 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92401 +
92402 +config PAX_USERCOPY
92403 + bool "Harden heap object copies between kernel and userland"
92404 + default y if GRKERNSEC_CONFIG_AUTO
92405 + depends on ARM || IA64 || PPC || SPARC || X86
92406 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92407 + select PAX_USERCOPY_SLABS
92408 + help
92409 + By saying Y here the kernel will enforce the size of heap objects
92410 + when they are copied in either direction between the kernel and
92411 + userland, even if only a part of the heap object is copied.
92412 +
92413 + Specifically, this checking prevents information leaking from the
92414 + kernel heap during kernel to userland copies (if the kernel heap
92415 + object is otherwise fully initialized) and prevents kernel heap
92416 + overflows during userland to kernel copies.
92417 +
92418 + Note that the current implementation provides the strictest bounds
92419 + checks for the SLUB allocator.
92420 +
92421 + Enabling this option also enables per-slab cache protection against
92422 + data in a given cache being copied into/out of via userland
92423 + accessors. Though the whitelist of regions will be reduced over
92424 + time, it notably protects important data structures like task structs.
92425 +
92426 + If frame pointers are enabled on x86, this option will also restrict
92427 + copies into and out of the kernel stack to local variables within a
92428 + single frame.
92429 +
92430 + Since this has a negligible performance impact, you should enable
92431 + this feature.
92432 +
92433 +config PAX_USERCOPY_DEBUG
92434 + bool
92435 + depends on X86 && PAX_USERCOPY
92436 + default n
92437 +
92438 +config PAX_SIZE_OVERFLOW
92439 + bool "Prevent various integer overflows in function size parameters"
92440 + default y if GRKERNSEC_CONFIG_AUTO
92441 + depends on X86
92442 + help
92443 + By saying Y here the kernel recomputes expressions of function
92444 + arguments marked by a size_overflow attribute with double integer
92445 + precision (DImode/TImode for 32/64 bit integer types).
92446 +
92447 + The recomputed argument is checked against TYPE_MAX and an event
92448 + is logged on overflow and the triggering process is killed.
92449 +
92450 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92451 +
92452 + Note that the implementation requires a gcc with plugin support,
92453 + i.e., gcc 4.5 or newer. You may need to install the supporting
92454 + headers explicitly in addition to the normal gcc package.
92455 +
92456 +config PAX_LATENT_ENTROPY
92457 + bool "Generate some entropy during boot"
92458 + default y if GRKERNSEC_CONFIG_AUTO
92459 + help
92460 + By saying Y here the kernel will instrument early boot code to
92461 + extract some entropy from both original and artificially created
92462 + program state. This will help especially embedded systems where
92463 + there is little 'natural' source of entropy normally. The cost
92464 + is some slowdown of the boot process.
92465 +
92466 + When pax_extra_latent_entropy is passed on the kernel command line,
92467 + entropy will be extracted from up to the first 4GB of RAM while the
92468 + runtime memory allocator is being initialized. This costs even more
92469 + slowdown of the boot process.
92470 +
92471 + Note that the implementation requires a gcc with plugin support,
92472 + i.e., gcc 4.5 or newer. You may need to install the supporting
92473 + headers explicitly in addition to the normal gcc package.
92474 +
92475 + Note that entropy extracted this way is not cryptographically
92476 + secure!
92477 +
92478 +endmenu
92479 +
92480 +endmenu
92481 +
92482 +source grsecurity/Kconfig
92483 +
92484 +endmenu
92485 +
92486 +endmenu
92487 +
92488 source security/keys/Kconfig
92489
92490 config SECURITY_DMESG_RESTRICT
92491 @@ -103,7 +1040,7 @@ config INTEL_TXT
92492 config LSM_MMAP_MIN_ADDR
92493 int "Low address space for LSM to protect from user allocation"
92494 depends on SECURITY && SECURITY_SELINUX
92495 - default 32768 if ARM
92496 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92497 default 65536
92498 help
92499 This is the portion of low virtual memory which should be protected
92500 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92501 index 8c2a7f6..b133ac9 100644
92502 --- a/security/apparmor/lsm.c
92503 +++ b/security/apparmor/lsm.c
92504 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92505 return error;
92506 }
92507
92508 -static struct security_operations apparmor_ops = {
92509 +static struct security_operations apparmor_ops __read_only = {
92510 .name = "apparmor",
92511
92512 .ptrace_access_check = apparmor_ptrace_access_check,
92513 diff --git a/security/commoncap.c b/security/commoncap.c
92514 index 7ee08c7..8d1a9d6 100644
92515 --- a/security/commoncap.c
92516 +++ b/security/commoncap.c
92517 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92518 return 0;
92519 }
92520
92521 +/* returns:
92522 + 1 for suid privilege
92523 + 2 for sgid privilege
92524 + 3 for fscap privilege
92525 +*/
92526 +int is_privileged_binary(const struct dentry *dentry)
92527 +{
92528 + struct cpu_vfs_cap_data capdata;
92529 + struct inode *inode = dentry->d_inode;
92530 +
92531 + if (!inode || S_ISDIR(inode->i_mode))
92532 + return 0;
92533 +
92534 + if (inode->i_mode & S_ISUID)
92535 + return 1;
92536 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92537 + return 2;
92538 +
92539 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92540 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92541 + return 3;
92542 + }
92543 +
92544 + return 0;
92545 +}
92546 +
92547 /*
92548 * Attempt to get the on-exec apply capability sets for an executable file from
92549 * its xattrs and, if present, apply them to the proposed credentials being
92550 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92551 const struct cred *cred = current_cred();
92552 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92553
92554 + if (gr_acl_enable_at_secure())
92555 + return 1;
92556 +
92557 if (!uid_eq(cred->uid, root_uid)) {
92558 if (bprm->cap_effective)
92559 return 1;
92560 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92561 index 079a85d..12e93f8 100644
92562 --- a/security/integrity/ima/ima.h
92563 +++ b/security/integrity/ima/ima.h
92564 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92565 extern spinlock_t ima_queue_lock;
92566
92567 struct ima_h_table {
92568 - atomic_long_t len; /* number of stored measurements in the list */
92569 - atomic_long_t violations;
92570 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92571 + atomic_long_unchecked_t violations;
92572 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92573 };
92574 extern struct ima_h_table ima_htable;
92575 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92576 index 0cea3db..2f0ef77 100644
92577 --- a/security/integrity/ima/ima_api.c
92578 +++ b/security/integrity/ima/ima_api.c
92579 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92580 int result;
92581
92582 /* can overflow, only indicator */
92583 - atomic_long_inc(&ima_htable.violations);
92584 + atomic_long_inc_unchecked(&ima_htable.violations);
92585
92586 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92587 if (!entry) {
92588 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92589 index 38477c9..87a60c7 100644
92590 --- a/security/integrity/ima/ima_fs.c
92591 +++ b/security/integrity/ima/ima_fs.c
92592 @@ -28,12 +28,12 @@
92593 static int valid_policy = 1;
92594 #define TMPBUFLEN 12
92595 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92596 - loff_t *ppos, atomic_long_t *val)
92597 + loff_t *ppos, atomic_long_unchecked_t *val)
92598 {
92599 char tmpbuf[TMPBUFLEN];
92600 ssize_t len;
92601
92602 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92603 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92604 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92605 }
92606
92607 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92608 index 55a6271..ad829c3 100644
92609 --- a/security/integrity/ima/ima_queue.c
92610 +++ b/security/integrity/ima/ima_queue.c
92611 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92612 INIT_LIST_HEAD(&qe->later);
92613 list_add_tail_rcu(&qe->later, &ima_measurements);
92614
92615 - atomic_long_inc(&ima_htable.len);
92616 + atomic_long_inc_unchecked(&ima_htable.len);
92617 key = ima_hash_key(entry->digest);
92618 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92619 return 0;
92620 diff --git a/security/keys/compat.c b/security/keys/compat.c
92621 index d65fa7f..cbfe366 100644
92622 --- a/security/keys/compat.c
92623 +++ b/security/keys/compat.c
92624 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92625 if (ret == 0)
92626 goto no_payload_free;
92627
92628 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92629 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92630 err:
92631 if (iov != iovstack)
92632 kfree(iov);
92633 diff --git a/security/keys/key.c b/security/keys/key.c
92634 index 8fb7c7b..ba3610d 100644
92635 --- a/security/keys/key.c
92636 +++ b/security/keys/key.c
92637 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92638
92639 atomic_set(&key->usage, 1);
92640 init_rwsem(&key->sem);
92641 - lockdep_set_class(&key->sem, &type->lock_class);
92642 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92643 key->type = type;
92644 key->user = user;
92645 key->quotalen = quotalen;
92646 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92647 struct key_type *p;
92648 int ret;
92649
92650 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92651 + pax_open_kernel();
92652 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92653 + pax_close_kernel();
92654
92655 ret = -EEXIST;
92656 down_write(&key_types_sem);
92657 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92658 }
92659
92660 /* store the type */
92661 - list_add(&ktype->link, &key_types_list);
92662 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92663
92664 pr_notice("Key type %s registered\n", ktype->name);
92665 ret = 0;
92666 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92667 void unregister_key_type(struct key_type *ktype)
92668 {
92669 down_write(&key_types_sem);
92670 - list_del_init(&ktype->link);
92671 + pax_list_del_init((struct list_head *)&ktype->link);
92672 downgrade_write(&key_types_sem);
92673 key_gc_keytype(ktype);
92674 pr_notice("Key type %s unregistered\n", ktype->name);
92675 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92676 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92677
92678 /* add the special key types */
92679 - list_add_tail(&key_type_keyring.link, &key_types_list);
92680 - list_add_tail(&key_type_dead.link, &key_types_list);
92681 - list_add_tail(&key_type_user.link, &key_types_list);
92682 - list_add_tail(&key_type_logon.link, &key_types_list);
92683 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92684 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92685 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92686 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92687
92688 /* record the root user tracking */
92689 rb_link_node(&root_key_user.node,
92690 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92691 index 4b5c948..2054dc1 100644
92692 --- a/security/keys/keyctl.c
92693 +++ b/security/keys/keyctl.c
92694 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92695 /*
92696 * Copy the iovec data from userspace
92697 */
92698 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92699 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92700 unsigned ioc)
92701 {
92702 for (; ioc > 0; ioc--) {
92703 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92704 * If successful, 0 will be returned.
92705 */
92706 long keyctl_instantiate_key_common(key_serial_t id,
92707 - const struct iovec *payload_iov,
92708 + const struct iovec __user *payload_iov,
92709 unsigned ioc,
92710 size_t plen,
92711 key_serial_t ringid)
92712 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92713 [0].iov_len = plen
92714 };
92715
92716 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92717 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92718 }
92719
92720 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92721 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92722 if (ret == 0)
92723 goto no_payload_free;
92724
92725 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92726 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92727 err:
92728 if (iov != iovstack)
92729 kfree(iov);
92730 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92731 index 6ece7f2..ecdb55c 100644
92732 --- a/security/keys/keyring.c
92733 +++ b/security/keys/keyring.c
92734 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92735 ret = -EFAULT;
92736
92737 for (loop = 0; loop < klist->nkeys; loop++) {
92738 + key_serial_t serial;
92739 key = rcu_deref_link_locked(klist, loop,
92740 keyring);
92741 + serial = key->serial;
92742
92743 tmp = sizeof(key_serial_t);
92744 if (tmp > buflen)
92745 tmp = buflen;
92746
92747 - if (copy_to_user(buffer,
92748 - &key->serial,
92749 - tmp) != 0)
92750 + if (copy_to_user(buffer, &serial, tmp))
92751 goto error;
92752
92753 buflen -= tmp;
92754 diff --git a/security/min_addr.c b/security/min_addr.c
92755 index f728728..6457a0c 100644
92756 --- a/security/min_addr.c
92757 +++ b/security/min_addr.c
92758 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92759 */
92760 static void update_mmap_min_addr(void)
92761 {
92762 +#ifndef SPARC
92763 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92764 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92765 mmap_min_addr = dac_mmap_min_addr;
92766 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92767 #else
92768 mmap_min_addr = dac_mmap_min_addr;
92769 #endif
92770 +#endif
92771 }
92772
92773 /*
92774 diff --git a/security/security.c b/security/security.c
92775 index 7b88c6a..1e3ea8f 100644
92776 --- a/security/security.c
92777 +++ b/security/security.c
92778 @@ -20,6 +20,7 @@
92779 #include <linux/ima.h>
92780 #include <linux/evm.h>
92781 #include <linux/fsnotify.h>
92782 +#include <linux/mm.h>
92783 #include <linux/mman.h>
92784 #include <linux/mount.h>
92785 #include <linux/personality.h>
92786 @@ -32,8 +33,8 @@
92787 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92788 CONFIG_DEFAULT_SECURITY;
92789
92790 -static struct security_operations *security_ops;
92791 -static struct security_operations default_security_ops = {
92792 +static struct security_operations *security_ops __read_only;
92793 +static struct security_operations default_security_ops __read_only = {
92794 .name = "default",
92795 };
92796
92797 @@ -74,7 +75,9 @@ int __init security_init(void)
92798
92799 void reset_security_ops(void)
92800 {
92801 + pax_open_kernel();
92802 security_ops = &default_security_ops;
92803 + pax_close_kernel();
92804 }
92805
92806 /* Save user chosen LSM */
92807 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92808 index ef26e96..642fb78 100644
92809 --- a/security/selinux/hooks.c
92810 +++ b/security/selinux/hooks.c
92811 @@ -95,8 +95,6 @@
92812
92813 #define NUM_SEL_MNT_OPTS 5
92814
92815 -extern struct security_operations *security_ops;
92816 -
92817 /* SECMARK reference count */
92818 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92819
92820 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92821
92822 #endif
92823
92824 -static struct security_operations selinux_ops = {
92825 +static struct security_operations selinux_ops __read_only = {
92826 .name = "selinux",
92827
92828 .ptrace_access_check = selinux_ptrace_access_check,
92829 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92830 index 65f67cb..3f141ef 100644
92831 --- a/security/selinux/include/xfrm.h
92832 +++ b/security/selinux/include/xfrm.h
92833 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92834
92835 static inline void selinux_xfrm_notify_policyload(void)
92836 {
92837 - atomic_inc(&flow_cache_genid);
92838 + atomic_inc_unchecked(&flow_cache_genid);
92839 rt_genid_bump(&init_net);
92840 }
92841 #else
92842 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92843 index 38be92c..21f49ee 100644
92844 --- a/security/smack/smack_lsm.c
92845 +++ b/security/smack/smack_lsm.c
92846 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92847 return 0;
92848 }
92849
92850 -struct security_operations smack_ops = {
92851 +struct security_operations smack_ops __read_only = {
92852 .name = "smack",
92853
92854 .ptrace_access_check = smack_ptrace_access_check,
92855 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92856 index 390c646..f2f8db3 100644
92857 --- a/security/tomoyo/mount.c
92858 +++ b/security/tomoyo/mount.c
92859 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92860 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92861 need_dev = -1; /* dev_name is a directory */
92862 } else {
92863 + if (!capable(CAP_SYS_ADMIN)) {
92864 + error = -EPERM;
92865 + goto out;
92866 + }
92867 fstype = get_fs_type(type);
92868 if (!fstype) {
92869 error = -ENODEV;
92870 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92871 index a2ee362..5754f34 100644
92872 --- a/security/tomoyo/tomoyo.c
92873 +++ b/security/tomoyo/tomoyo.c
92874 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92875 * tomoyo_security_ops is a "struct security_operations" which is used for
92876 * registering TOMOYO.
92877 */
92878 -static struct security_operations tomoyo_security_ops = {
92879 +static struct security_operations tomoyo_security_ops __read_only = {
92880 .name = "tomoyo",
92881 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92882 .cred_prepare = tomoyo_cred_prepare,
92883 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92884 index 20ef514..4182bed 100644
92885 --- a/security/yama/Kconfig
92886 +++ b/security/yama/Kconfig
92887 @@ -1,6 +1,6 @@
92888 config SECURITY_YAMA
92889 bool "Yama support"
92890 - depends on SECURITY
92891 + depends on SECURITY && !GRKERNSEC
92892 select SECURITYFS
92893 select SECURITY_PATH
92894 default n
92895 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92896 index 23414b9..f8c115e 100644
92897 --- a/security/yama/yama_lsm.c
92898 +++ b/security/yama/yama_lsm.c
92899 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92900 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92901 switch (ptrace_scope) {
92902 case YAMA_SCOPE_CAPABILITY:
92903 - rcu_read_lock();
92904 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92905 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92906 rc = -EPERM;
92907 - rcu_read_unlock();
92908 break;
92909 case YAMA_SCOPE_NO_ATTACH:
92910 rc = -EPERM;
92911 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92912 }
92913
92914 #ifndef CONFIG_SECURITY_YAMA_STACKED
92915 -static struct security_operations yama_ops = {
92916 +static struct security_operations yama_ops __read_only = {
92917 .name = "yama",
92918
92919 .ptrace_access_check = yama_ptrace_access_check,
92920 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92921 #endif
92922
92923 #ifdef CONFIG_SYSCTL
92924 +static int zero __read_only;
92925 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92926 +
92927 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92928 void __user *buffer, size_t *lenp, loff_t *ppos)
92929 {
92930 - int rc;
92931 + ctl_table_no_const yama_table;
92932
92933 if (write && !capable(CAP_SYS_PTRACE))
92934 return -EPERM;
92935
92936 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92937 - if (rc)
92938 - return rc;
92939 -
92940 + yama_table = *table;
92941 /* Lock the max value if it ever gets set. */
92942 - if (write && *(int *)table->data == *(int *)table->extra2)
92943 - table->extra1 = table->extra2;
92944 -
92945 - return rc;
92946 + if (ptrace_scope == max_scope)
92947 + yama_table.extra1 = &max_scope;
92948 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92949 }
92950
92951 -static int zero;
92952 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92953 -
92954 struct ctl_path yama_sysctl_path[] = {
92955 { .procname = "kernel", },
92956 { .procname = "yama", },
92957 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92958 index 4cedc69..e59d8a3 100644
92959 --- a/sound/aoa/codecs/onyx.c
92960 +++ b/sound/aoa/codecs/onyx.c
92961 @@ -54,7 +54,7 @@ struct onyx {
92962 spdif_locked:1,
92963 analog_locked:1,
92964 original_mute:2;
92965 - int open_count;
92966 + local_t open_count;
92967 struct codec_info *codec_info;
92968
92969 /* mutex serializes concurrent access to the device
92970 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92971 struct onyx *onyx = cii->codec_data;
92972
92973 mutex_lock(&onyx->mutex);
92974 - onyx->open_count++;
92975 + local_inc(&onyx->open_count);
92976 mutex_unlock(&onyx->mutex);
92977
92978 return 0;
92979 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92980 struct onyx *onyx = cii->codec_data;
92981
92982 mutex_lock(&onyx->mutex);
92983 - onyx->open_count--;
92984 - if (!onyx->open_count)
92985 + if (local_dec_and_test(&onyx->open_count))
92986 onyx->spdif_locked = onyx->analog_locked = 0;
92987 mutex_unlock(&onyx->mutex);
92988
92989 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92990 index ffd2025..df062c9 100644
92991 --- a/sound/aoa/codecs/onyx.h
92992 +++ b/sound/aoa/codecs/onyx.h
92993 @@ -11,6 +11,7 @@
92994 #include <linux/i2c.h>
92995 #include <asm/pmac_low_i2c.h>
92996 #include <asm/prom.h>
92997 +#include <asm/local.h>
92998
92999 /* PCM3052 register definitions */
93000
93001 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93002 index 4c1cc51..16040040 100644
93003 --- a/sound/core/oss/pcm_oss.c
93004 +++ b/sound/core/oss/pcm_oss.c
93005 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93006 if (in_kernel) {
93007 mm_segment_t fs;
93008 fs = snd_enter_user();
93009 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93010 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93011 snd_leave_user(fs);
93012 } else {
93013 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93014 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93015 }
93016 if (ret != -EPIPE && ret != -ESTRPIPE)
93017 break;
93018 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93019 if (in_kernel) {
93020 mm_segment_t fs;
93021 fs = snd_enter_user();
93022 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93023 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93024 snd_leave_user(fs);
93025 } else {
93026 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93027 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93028 }
93029 if (ret == -EPIPE) {
93030 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93031 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93032 struct snd_pcm_plugin_channel *channels;
93033 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93034 if (!in_kernel) {
93035 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93036 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93037 return -EFAULT;
93038 buf = runtime->oss.buffer;
93039 }
93040 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93041 }
93042 } else {
93043 tmp = snd_pcm_oss_write2(substream,
93044 - (const char __force *)buf,
93045 + (const char __force_kernel *)buf,
93046 runtime->oss.period_bytes, 0);
93047 if (tmp <= 0)
93048 goto err;
93049 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93050 struct snd_pcm_runtime *runtime = substream->runtime;
93051 snd_pcm_sframes_t frames, frames1;
93052 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93053 - char __user *final_dst = (char __force __user *)buf;
93054 + char __user *final_dst = (char __force_user *)buf;
93055 if (runtime->oss.plugin_first) {
93056 struct snd_pcm_plugin_channel *channels;
93057 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93058 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93059 xfer += tmp;
93060 runtime->oss.buffer_used -= tmp;
93061 } else {
93062 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93063 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93064 runtime->oss.period_bytes, 0);
93065 if (tmp <= 0)
93066 goto err;
93067 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93068 size1);
93069 size1 /= runtime->channels; /* frames */
93070 fs = snd_enter_user();
93071 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93072 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93073 snd_leave_user(fs);
93074 }
93075 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93076 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93077 index af49721..e85058e 100644
93078 --- a/sound/core/pcm_compat.c
93079 +++ b/sound/core/pcm_compat.c
93080 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93081 int err;
93082
93083 fs = snd_enter_user();
93084 - err = snd_pcm_delay(substream, &delay);
93085 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93086 snd_leave_user(fs);
93087 if (err < 0)
93088 return err;
93089 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93090 index f4aaf5a..3b04e3b 100644
93091 --- a/sound/core/pcm_native.c
93092 +++ b/sound/core/pcm_native.c
93093 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93094 switch (substream->stream) {
93095 case SNDRV_PCM_STREAM_PLAYBACK:
93096 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93097 - (void __user *)arg);
93098 + (void __force_user *)arg);
93099 break;
93100 case SNDRV_PCM_STREAM_CAPTURE:
93101 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93102 - (void __user *)arg);
93103 + (void __force_user *)arg);
93104 break;
93105 default:
93106 result = -EINVAL;
93107 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93108 index 040c60e..989a19a 100644
93109 --- a/sound/core/seq/seq_device.c
93110 +++ b/sound/core/seq/seq_device.c
93111 @@ -64,7 +64,7 @@ struct ops_list {
93112 int argsize; /* argument size */
93113
93114 /* operators */
93115 - struct snd_seq_dev_ops ops;
93116 + struct snd_seq_dev_ops *ops;
93117
93118 /* registered devices */
93119 struct list_head dev_list; /* list of devices */
93120 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93121
93122 mutex_lock(&ops->reg_mutex);
93123 /* copy driver operators */
93124 - ops->ops = *entry;
93125 + ops->ops = entry;
93126 ops->driver |= DRIVER_LOADED;
93127 ops->argsize = argsize;
93128
93129 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93130 dev->name, ops->id, ops->argsize, dev->argsize);
93131 return -EINVAL;
93132 }
93133 - if (ops->ops.init_device(dev) >= 0) {
93134 + if (ops->ops->init_device(dev) >= 0) {
93135 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93136 ops->num_init_devices++;
93137 } else {
93138 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93139 dev->name, ops->id, ops->argsize, dev->argsize);
93140 return -EINVAL;
93141 }
93142 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93143 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93144 dev->status = SNDRV_SEQ_DEVICE_FREE;
93145 dev->driver_data = NULL;
93146 ops->num_init_devices--;
93147 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93148 index 4e0dd22..7a1f32c 100644
93149 --- a/sound/drivers/mts64.c
93150 +++ b/sound/drivers/mts64.c
93151 @@ -29,6 +29,7 @@
93152 #include <sound/initval.h>
93153 #include <sound/rawmidi.h>
93154 #include <sound/control.h>
93155 +#include <asm/local.h>
93156
93157 #define CARD_NAME "Miditerminal 4140"
93158 #define DRIVER_NAME "MTS64"
93159 @@ -67,7 +68,7 @@ struct mts64 {
93160 struct pardevice *pardev;
93161 int pardev_claimed;
93162
93163 - int open_count;
93164 + local_t open_count;
93165 int current_midi_output_port;
93166 int current_midi_input_port;
93167 u8 mode[MTS64_NUM_INPUT_PORTS];
93168 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93169 {
93170 struct mts64 *mts = substream->rmidi->private_data;
93171
93172 - if (mts->open_count == 0) {
93173 + if (local_read(&mts->open_count) == 0) {
93174 /* We don't need a spinlock here, because this is just called
93175 if the device has not been opened before.
93176 So there aren't any IRQs from the device */
93177 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93178
93179 msleep(50);
93180 }
93181 - ++(mts->open_count);
93182 + local_inc(&mts->open_count);
93183
93184 return 0;
93185 }
93186 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93187 struct mts64 *mts = substream->rmidi->private_data;
93188 unsigned long flags;
93189
93190 - --(mts->open_count);
93191 - if (mts->open_count == 0) {
93192 + if (local_dec_return(&mts->open_count) == 0) {
93193 /* We need the spinlock_irqsave here because we can still
93194 have IRQs at this point */
93195 spin_lock_irqsave(&mts->lock, flags);
93196 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93197
93198 msleep(500);
93199
93200 - } else if (mts->open_count < 0)
93201 - mts->open_count = 0;
93202 + } else if (local_read(&mts->open_count) < 0)
93203 + local_set(&mts->open_count, 0);
93204
93205 return 0;
93206 }
93207 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93208 index b953fb4..1999c01 100644
93209 --- a/sound/drivers/opl4/opl4_lib.c
93210 +++ b/sound/drivers/opl4/opl4_lib.c
93211 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93212 MODULE_DESCRIPTION("OPL4 driver");
93213 MODULE_LICENSE("GPL");
93214
93215 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93216 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93217 {
93218 int timeout = 10;
93219 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93220 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93221 index 991018d..8984740 100644
93222 --- a/sound/drivers/portman2x4.c
93223 +++ b/sound/drivers/portman2x4.c
93224 @@ -48,6 +48,7 @@
93225 #include <sound/initval.h>
93226 #include <sound/rawmidi.h>
93227 #include <sound/control.h>
93228 +#include <asm/local.h>
93229
93230 #define CARD_NAME "Portman 2x4"
93231 #define DRIVER_NAME "portman"
93232 @@ -85,7 +86,7 @@ struct portman {
93233 struct pardevice *pardev;
93234 int pardev_claimed;
93235
93236 - int open_count;
93237 + local_t open_count;
93238 int mode[PORTMAN_NUM_INPUT_PORTS];
93239 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93240 };
93241 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93242 index ea995af..f1bfa37 100644
93243 --- a/sound/firewire/amdtp.c
93244 +++ b/sound/firewire/amdtp.c
93245 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93246 ptr = s->pcm_buffer_pointer + data_blocks;
93247 if (ptr >= pcm->runtime->buffer_size)
93248 ptr -= pcm->runtime->buffer_size;
93249 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93250 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93251
93252 s->pcm_period_pointer += data_blocks;
93253 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93254 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93255 */
93256 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93257 {
93258 - ACCESS_ONCE(s->source_node_id_field) =
93259 + ACCESS_ONCE_RW(s->source_node_id_field) =
93260 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93261 }
93262 EXPORT_SYMBOL(amdtp_out_stream_update);
93263 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93264 index b680c5e..061b7a0 100644
93265 --- a/sound/firewire/amdtp.h
93266 +++ b/sound/firewire/amdtp.h
93267 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93268 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93269 struct snd_pcm_substream *pcm)
93270 {
93271 - ACCESS_ONCE(s->pcm) = pcm;
93272 + ACCESS_ONCE_RW(s->pcm) = pcm;
93273 }
93274
93275 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93276 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93277 index d428ffe..751ef78 100644
93278 --- a/sound/firewire/isight.c
93279 +++ b/sound/firewire/isight.c
93280 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93281 ptr += count;
93282 if (ptr >= runtime->buffer_size)
93283 ptr -= runtime->buffer_size;
93284 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93285 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93286
93287 isight->period_counter += count;
93288 if (isight->period_counter >= runtime->period_size) {
93289 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93290 if (err < 0)
93291 return err;
93292
93293 - ACCESS_ONCE(isight->pcm_active) = true;
93294 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93295
93296 return 0;
93297 }
93298 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93299 {
93300 struct isight *isight = substream->private_data;
93301
93302 - ACCESS_ONCE(isight->pcm_active) = false;
93303 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93304
93305 mutex_lock(&isight->mutex);
93306 isight_stop_streaming(isight);
93307 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93308
93309 switch (cmd) {
93310 case SNDRV_PCM_TRIGGER_START:
93311 - ACCESS_ONCE(isight->pcm_running) = true;
93312 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93313 break;
93314 case SNDRV_PCM_TRIGGER_STOP:
93315 - ACCESS_ONCE(isight->pcm_running) = false;
93316 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93317 break;
93318 default:
93319 return -EINVAL;
93320 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93321 index 844a555..985ab83 100644
93322 --- a/sound/firewire/scs1x.c
93323 +++ b/sound/firewire/scs1x.c
93324 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93325 {
93326 struct scs *scs = stream->rmidi->private_data;
93327
93328 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93329 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93330 if (up) {
93331 scs->output_idle = false;
93332 tasklet_schedule(&scs->tasklet);
93333 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93334 {
93335 struct scs *scs = stream->rmidi->private_data;
93336
93337 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93338 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93339 }
93340
93341 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93342 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93343
93344 snd_card_disconnect(scs->card);
93345
93346 - ACCESS_ONCE(scs->output) = NULL;
93347 - ACCESS_ONCE(scs->input) = NULL;
93348 + ACCESS_ONCE_RW(scs->output) = NULL;
93349 + ACCESS_ONCE_RW(scs->input) = NULL;
93350
93351 wait_event(scs->idle_wait, scs->output_idle);
93352
93353 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93354 index 048439a..3be9f6f 100644
93355 --- a/sound/oss/sb_audio.c
93356 +++ b/sound/oss/sb_audio.c
93357 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93358 buf16 = (signed short *)(localbuf + localoffs);
93359 while (c)
93360 {
93361 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93362 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93363 if (copy_from_user(lbuf8,
93364 userbuf+useroffs + p,
93365 locallen))
93366 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93367 index 7d8803a..559f8d0 100644
93368 --- a/sound/oss/swarm_cs4297a.c
93369 +++ b/sound/oss/swarm_cs4297a.c
93370 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93371 {
93372 struct cs4297a_state *s;
93373 u32 pwr, id;
93374 - mm_segment_t fs;
93375 int rval;
93376 #ifndef CONFIG_BCM_CS4297A_CSWARM
93377 u64 cfg;
93378 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93379 if (!rval) {
93380 char *sb1250_duart_present;
93381
93382 +#if 0
93383 + mm_segment_t fs;
93384 fs = get_fs();
93385 set_fs(KERNEL_DS);
93386 -#if 0
93387 val = SOUND_MASK_LINE;
93388 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93389 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93390 val = initvol[i].vol;
93391 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93392 }
93393 + set_fs(fs);
93394 // cs4297a_write_ac97(s, 0x18, 0x0808);
93395 #else
93396 // cs4297a_write_ac97(s, 0x5e, 0x180);
93397 cs4297a_write_ac97(s, 0x02, 0x0808);
93398 cs4297a_write_ac97(s, 0x18, 0x0808);
93399 #endif
93400 - set_fs(fs);
93401
93402 list_add(&s->list, &cs4297a_devs);
93403
93404 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93405 index 4631a23..001ae57 100644
93406 --- a/sound/pci/ymfpci/ymfpci.h
93407 +++ b/sound/pci/ymfpci/ymfpci.h
93408 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93409 spinlock_t reg_lock;
93410 spinlock_t voice_lock;
93411 wait_queue_head_t interrupt_sleep;
93412 - atomic_t interrupt_sleep_count;
93413 + atomic_unchecked_t interrupt_sleep_count;
93414 struct snd_info_entry *proc_entry;
93415 const struct firmware *dsp_microcode;
93416 const struct firmware *controller_microcode;
93417 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93418 index 22056c5..25d3244 100644
93419 --- a/sound/pci/ymfpci/ymfpci_main.c
93420 +++ b/sound/pci/ymfpci/ymfpci_main.c
93421 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93422 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93423 break;
93424 }
93425 - if (atomic_read(&chip->interrupt_sleep_count)) {
93426 - atomic_set(&chip->interrupt_sleep_count, 0);
93427 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93428 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93429 wake_up(&chip->interrupt_sleep);
93430 }
93431 __end:
93432 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93433 continue;
93434 init_waitqueue_entry(&wait, current);
93435 add_wait_queue(&chip->interrupt_sleep, &wait);
93436 - atomic_inc(&chip->interrupt_sleep_count);
93437 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93438 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93439 remove_wait_queue(&chip->interrupt_sleep, &wait);
93440 }
93441 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93442 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93443 spin_unlock(&chip->reg_lock);
93444
93445 - if (atomic_read(&chip->interrupt_sleep_count)) {
93446 - atomic_set(&chip->interrupt_sleep_count, 0);
93447 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93448 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93449 wake_up(&chip->interrupt_sleep);
93450 }
93451 }
93452 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93453 spin_lock_init(&chip->reg_lock);
93454 spin_lock_init(&chip->voice_lock);
93455 init_waitqueue_head(&chip->interrupt_sleep);
93456 - atomic_set(&chip->interrupt_sleep_count, 0);
93457 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93458 chip->card = card;
93459 chip->pci = pci;
93460 chip->irq = -1;
93461 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93462 new file mode 100644
93463 index 0000000..50f2f2f
93464 --- /dev/null
93465 +++ b/tools/gcc/.gitignore
93466 @@ -0,0 +1 @@
93467 +size_overflow_hash.h
93468 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93469 new file mode 100644
93470 index 0000000..144dbee
93471 --- /dev/null
93472 +++ b/tools/gcc/Makefile
93473 @@ -0,0 +1,45 @@
93474 +#CC := gcc
93475 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93476 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93477 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93478 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93479 +
93480 +ifeq ($(PLUGINCC),$(HOSTCC))
93481 +HOSTLIBS := hostlibs
93482 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93483 +else
93484 +HOSTLIBS := hostcxxlibs
93485 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93486 +endif
93487 +
93488 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93489 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93490 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93491 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93492 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93493 +$(HOSTLIBS)-y += colorize_plugin.so
93494 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93495 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93496 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93497 +
93498 +always := $($(HOSTLIBS)-y)
93499 +
93500 +constify_plugin-objs := constify_plugin.o
93501 +stackleak_plugin-objs := stackleak_plugin.o
93502 +kallocstat_plugin-objs := kallocstat_plugin.o
93503 +kernexec_plugin-objs := kernexec_plugin.o
93504 +checker_plugin-objs := checker_plugin.o
93505 +colorize_plugin-objs := colorize_plugin.o
93506 +size_overflow_plugin-objs := size_overflow_plugin.o
93507 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93508 +structleak_plugin-objs := structleak_plugin.o
93509 +
93510 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93511 +
93512 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93513 + cmd_build_size_overflow_hash = \
93514 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93515 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93516 + $(call if_changed,build_size_overflow_hash)
93517 +
93518 +targets += size_overflow_hash.h
93519 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93520 new file mode 100644
93521 index 0000000..d41b5af
93522 --- /dev/null
93523 +++ b/tools/gcc/checker_plugin.c
93524 @@ -0,0 +1,171 @@
93525 +/*
93526 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93527 + * Licensed under the GPL v2
93528 + *
93529 + * Note: the choice of the license means that the compilation process is
93530 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93531 + * but for the kernel it doesn't matter since it doesn't link against
93532 + * any of the gcc libraries
93533 + *
93534 + * gcc plugin to implement various sparse (source code checker) features
93535 + *
93536 + * TODO:
93537 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93538 + *
93539 + * BUGS:
93540 + * - none known
93541 + */
93542 +#include "gcc-plugin.h"
93543 +#include "config.h"
93544 +#include "system.h"
93545 +#include "coretypes.h"
93546 +#include "tree.h"
93547 +#include "tree-pass.h"
93548 +#include "flags.h"
93549 +#include "intl.h"
93550 +#include "toplev.h"
93551 +#include "plugin.h"
93552 +//#include "expr.h" where are you...
93553 +#include "diagnostic.h"
93554 +#include "plugin-version.h"
93555 +#include "tm.h"
93556 +#include "function.h"
93557 +#include "basic-block.h"
93558 +#include "gimple.h"
93559 +#include "rtl.h"
93560 +#include "emit-rtl.h"
93561 +#include "tree-flow.h"
93562 +#include "target.h"
93563 +
93564 +extern void c_register_addr_space (const char *str, addr_space_t as);
93565 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93566 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93567 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93568 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93569 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93570 +
93571 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93572 +extern rtx emit_move_insn(rtx x, rtx y);
93573 +
93574 +int plugin_is_GPL_compatible;
93575 +
93576 +static struct plugin_info checker_plugin_info = {
93577 + .version = "201111150100",
93578 +};
93579 +
93580 +#define ADDR_SPACE_KERNEL 0
93581 +#define ADDR_SPACE_FORCE_KERNEL 1
93582 +#define ADDR_SPACE_USER 2
93583 +#define ADDR_SPACE_FORCE_USER 3
93584 +#define ADDR_SPACE_IOMEM 0
93585 +#define ADDR_SPACE_FORCE_IOMEM 0
93586 +#define ADDR_SPACE_PERCPU 0
93587 +#define ADDR_SPACE_FORCE_PERCPU 0
93588 +#define ADDR_SPACE_RCU 0
93589 +#define ADDR_SPACE_FORCE_RCU 0
93590 +
93591 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93592 +{
93593 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93594 +}
93595 +
93596 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93597 +{
93598 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93599 +}
93600 +
93601 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93602 +{
93603 + return default_addr_space_valid_pointer_mode(mode, as);
93604 +}
93605 +
93606 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93607 +{
93608 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93609 +}
93610 +
93611 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93612 +{
93613 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93614 +}
93615 +
93616 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93617 +{
93618 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93619 + return true;
93620 +
93621 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93622 + return true;
93623 +
93624 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93625 + return true;
93626 +
93627 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93628 + return true;
93629 +
93630 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93631 + return true;
93632 +
93633 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93634 + return true;
93635 +
93636 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93637 + return true;
93638 +
93639 + return subset == superset;
93640 +}
93641 +
93642 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93643 +{
93644 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93645 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93646 +
93647 + return op;
93648 +}
93649 +
93650 +static void register_checker_address_spaces(void *event_data, void *data)
93651 +{
93652 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93653 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93654 + c_register_addr_space("__user", ADDR_SPACE_USER);
93655 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93656 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93657 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93658 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93659 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93660 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93661 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93662 +
93663 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93664 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93665 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93666 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93667 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93668 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93669 + targetm.addr_space.convert = checker_addr_space_convert;
93670 +}
93671 +
93672 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93673 +{
93674 + const char * const plugin_name = plugin_info->base_name;
93675 + const int argc = plugin_info->argc;
93676 + const struct plugin_argument * const argv = plugin_info->argv;
93677 + int i;
93678 +
93679 + if (!plugin_default_version_check(version, &gcc_version)) {
93680 + error(G_("incompatible gcc/plugin versions"));
93681 + return 1;
93682 + }
93683 +
93684 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93685 +
93686 + for (i = 0; i < argc; ++i)
93687 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93688 +
93689 + if (TARGET_64BIT == 0)
93690 + return 0;
93691 +
93692 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93693 +
93694 + return 0;
93695 +}
93696 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93697 new file mode 100644
93698 index 0000000..414fe5e
93699 --- /dev/null
93700 +++ b/tools/gcc/colorize_plugin.c
93701 @@ -0,0 +1,151 @@
93702 +/*
93703 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93704 + * Licensed under the GPL v2
93705 + *
93706 + * Note: the choice of the license means that the compilation process is
93707 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93708 + * but for the kernel it doesn't matter since it doesn't link against
93709 + * any of the gcc libraries
93710 + *
93711 + * gcc plugin to colorize diagnostic output
93712 + *
93713 + */
93714 +
93715 +#include "gcc-plugin.h"
93716 +#include "config.h"
93717 +#include "system.h"
93718 +#include "coretypes.h"
93719 +#include "tree.h"
93720 +#include "tree-pass.h"
93721 +#include "flags.h"
93722 +#include "intl.h"
93723 +#include "toplev.h"
93724 +#include "plugin.h"
93725 +#include "diagnostic.h"
93726 +#include "plugin-version.h"
93727 +#include "tm.h"
93728 +
93729 +int plugin_is_GPL_compatible;
93730 +
93731 +static struct plugin_info colorize_plugin_info = {
93732 + .version = "201302112000",
93733 + .help = NULL,
93734 +};
93735 +
93736 +#define GREEN "\033[32m\033[2m"
93737 +#define LIGHTGREEN "\033[32m\033[1m"
93738 +#define YELLOW "\033[33m\033[2m"
93739 +#define LIGHTYELLOW "\033[33m\033[1m"
93740 +#define RED "\033[31m\033[2m"
93741 +#define LIGHTRED "\033[31m\033[1m"
93742 +#define BLUE "\033[34m\033[2m"
93743 +#define LIGHTBLUE "\033[34m\033[1m"
93744 +#define BRIGHT "\033[m\033[1m"
93745 +#define NORMAL "\033[m"
93746 +
93747 +static diagnostic_starter_fn old_starter;
93748 +static diagnostic_finalizer_fn old_finalizer;
93749 +
93750 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93751 +{
93752 + const char *color;
93753 + char *newprefix;
93754 +
93755 + switch (diagnostic->kind) {
93756 + case DK_NOTE:
93757 + color = LIGHTBLUE;
93758 + break;
93759 +
93760 + case DK_PEDWARN:
93761 + case DK_WARNING:
93762 + color = LIGHTYELLOW;
93763 + break;
93764 +
93765 + case DK_ERROR:
93766 + case DK_FATAL:
93767 + case DK_ICE:
93768 + case DK_PERMERROR:
93769 + case DK_SORRY:
93770 + color = LIGHTRED;
93771 + break;
93772 +
93773 + default:
93774 + color = NORMAL;
93775 + }
93776 +
93777 + old_starter(context, diagnostic);
93778 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93779 + return;
93780 + pp_destroy_prefix(context->printer);
93781 + pp_set_prefix(context->printer, newprefix);
93782 +}
93783 +
93784 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93785 +{
93786 + old_finalizer(context, diagnostic);
93787 +}
93788 +
93789 +static void colorize_arm(void)
93790 +{
93791 + old_starter = diagnostic_starter(global_dc);
93792 + old_finalizer = diagnostic_finalizer(global_dc);
93793 +
93794 + diagnostic_starter(global_dc) = start_colorize;
93795 + diagnostic_finalizer(global_dc) = finalize_colorize;
93796 +}
93797 +
93798 +static unsigned int execute_colorize_rearm(void)
93799 +{
93800 + if (diagnostic_starter(global_dc) == start_colorize)
93801 + return 0;
93802 +
93803 + colorize_arm();
93804 + return 0;
93805 +}
93806 +
93807 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93808 + .pass = {
93809 + .type = SIMPLE_IPA_PASS,
93810 + .name = "colorize_rearm",
93811 +#if BUILDING_GCC_VERSION >= 4008
93812 + .optinfo_flags = OPTGROUP_NONE,
93813 +#endif
93814 + .gate = NULL,
93815 + .execute = execute_colorize_rearm,
93816 + .sub = NULL,
93817 + .next = NULL,
93818 + .static_pass_number = 0,
93819 + .tv_id = TV_NONE,
93820 + .properties_required = 0,
93821 + .properties_provided = 0,
93822 + .properties_destroyed = 0,
93823 + .todo_flags_start = 0,
93824 + .todo_flags_finish = 0
93825 + }
93826 +};
93827 +
93828 +static void colorize_start_unit(void *gcc_data, void *user_data)
93829 +{
93830 + colorize_arm();
93831 +}
93832 +
93833 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93834 +{
93835 + const char * const plugin_name = plugin_info->base_name;
93836 + struct register_pass_info colorize_rearm_pass_info = {
93837 + .pass = &pass_ipa_colorize_rearm.pass,
93838 + .reference_pass_name = "*free_lang_data",
93839 + .ref_pass_instance_number = 1,
93840 + .pos_op = PASS_POS_INSERT_AFTER
93841 + };
93842 +
93843 + if (!plugin_default_version_check(version, &gcc_version)) {
93844 + error(G_("incompatible gcc/plugin versions"));
93845 + return 1;
93846 + }
93847 +
93848 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93849 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93850 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93851 + return 0;
93852 +}
93853 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93854 new file mode 100644
93855 index 0000000..bee0acb
93856 --- /dev/null
93857 +++ b/tools/gcc/constify_plugin.c
93858 @@ -0,0 +1,518 @@
93859 +/*
93860 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93861 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93862 + * Licensed under the GPL v2, or (at your option) v3
93863 + *
93864 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93865 + *
93866 + * Homepage:
93867 + * http://www.grsecurity.net/~ephox/const_plugin/
93868 + *
93869 + * Usage:
93870 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93871 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93872 + */
93873 +
93874 +#include "gcc-plugin.h"
93875 +#include "config.h"
93876 +#include "system.h"
93877 +#include "coretypes.h"
93878 +#include "tree.h"
93879 +#include "tree-pass.h"
93880 +#include "flags.h"
93881 +#include "intl.h"
93882 +#include "toplev.h"
93883 +#include "plugin.h"
93884 +#include "diagnostic.h"
93885 +#include "plugin-version.h"
93886 +#include "tm.h"
93887 +#include "function.h"
93888 +#include "basic-block.h"
93889 +#include "gimple.h"
93890 +#include "rtl.h"
93891 +#include "emit-rtl.h"
93892 +#include "tree-flow.h"
93893 +#include "target.h"
93894 +#include "langhooks.h"
93895 +
93896 +// should come from c-tree.h if only it were installed for gcc 4.5...
93897 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93898 +
93899 +// unused type flag in all versions 4.5-4.8
93900 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93901 +
93902 +int plugin_is_GPL_compatible;
93903 +
93904 +static struct plugin_info const_plugin_info = {
93905 + .version = "201303270300",
93906 + .help = "no-constify\tturn off constification\n",
93907 +};
93908 +
93909 +typedef struct {
93910 + bool has_fptr_field;
93911 + bool has_writable_field;
93912 + bool has_do_const_field;
93913 + bool has_no_const_field;
93914 +} constify_info;
93915 +
93916 +static const_tree get_field_type(const_tree field)
93917 +{
93918 + return strip_array_types(TREE_TYPE(field));
93919 +}
93920 +
93921 +static bool is_fptr(const_tree field)
93922 +{
93923 + const_tree ptr = get_field_type(field);
93924 +
93925 + if (TREE_CODE(ptr) != POINTER_TYPE)
93926 + return false;
93927 +
93928 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93929 +}
93930 +
93931 +/*
93932 + * determine whether the given structure type meets the requirements for automatic constification,
93933 + * including the constification attributes on nested structure types
93934 + */
93935 +static void constifiable(const_tree node, constify_info *cinfo)
93936 +{
93937 + const_tree field;
93938 +
93939 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93940 +
93941 + // e.g., pointer to structure fields while still constructing the structure type
93942 + if (TYPE_FIELDS(node) == NULL_TREE)
93943 + return;
93944 +
93945 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93946 + const_tree type = get_field_type(field);
93947 + enum tree_code code = TREE_CODE(type);
93948 +
93949 + if (node == type)
93950 + continue;
93951 +
93952 + if (is_fptr(field))
93953 + cinfo->has_fptr_field = true;
93954 + else if (!TREE_READONLY(field))
93955 + cinfo->has_writable_field = true;
93956 +
93957 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93958 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93959 + cinfo->has_do_const_field = true;
93960 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93961 + cinfo->has_no_const_field = true;
93962 + else
93963 + constifiable(type, cinfo);
93964 + }
93965 + }
93966 +}
93967 +
93968 +static bool constified(const_tree node)
93969 +{
93970 + constify_info cinfo = {
93971 + .has_fptr_field = false,
93972 + .has_writable_field = false,
93973 + .has_do_const_field = false,
93974 + .has_no_const_field = false
93975 + };
93976 +
93977 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93978 +
93979 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93980 + gcc_assert(!TYPE_READONLY(node));
93981 + return false;
93982 + }
93983 +
93984 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93985 + gcc_assert(TYPE_READONLY(node));
93986 + return true;
93987 + }
93988 +
93989 + constifiable(node, &cinfo);
93990 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93991 + return false;
93992 +
93993 + return TYPE_READONLY(node);
93994 +}
93995 +
93996 +static void deconstify_tree(tree node);
93997 +
93998 +static void deconstify_type(tree type)
93999 +{
94000 + tree field;
94001 +
94002 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94003 +
94004 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94005 + const_tree fieldtype = get_field_type(field);
94006 +
94007 + // special case handling of simple ptr-to-same-array-type members
94008 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94009 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94010 +
94011 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94012 + continue;
94013 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94014 + continue;
94015 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94016 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94017 + TREE_TYPE(TREE_TYPE(field)) = type;
94018 + }
94019 + continue;
94020 + }
94021 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94022 + continue;
94023 + if (!constified(fieldtype))
94024 + continue;
94025 +
94026 + deconstify_tree(field);
94027 + TREE_READONLY(field) = 0;
94028 + }
94029 + TYPE_READONLY(type) = 0;
94030 + C_TYPE_FIELDS_READONLY(type) = 0;
94031 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94032 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94033 +}
94034 +
94035 +static void deconstify_tree(tree node)
94036 +{
94037 + tree old_type, new_type, field;
94038 +
94039 + old_type = TREE_TYPE(node);
94040 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94041 + node = TREE_TYPE(node) = copy_node(old_type);
94042 + old_type = TREE_TYPE(old_type);
94043 + }
94044 +
94045 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94046 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94047 +
94048 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94049 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94050 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94051 + DECL_FIELD_CONTEXT(field) = new_type;
94052 +
94053 + deconstify_type(new_type);
94054 +
94055 + TREE_TYPE(node) = new_type;
94056 +}
94057 +
94058 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94059 +{
94060 + tree type;
94061 + constify_info cinfo = {
94062 + .has_fptr_field = false,
94063 + .has_writable_field = false,
94064 + .has_do_const_field = false,
94065 + .has_no_const_field = false
94066 + };
94067 +
94068 + *no_add_attrs = true;
94069 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94070 + error("%qE attribute does not apply to functions", name);
94071 + return NULL_TREE;
94072 + }
94073 +
94074 + if (TREE_CODE(*node) == PARM_DECL) {
94075 + error("%qE attribute does not apply to function parameters", name);
94076 + return NULL_TREE;
94077 + }
94078 +
94079 + if (TREE_CODE(*node) == VAR_DECL) {
94080 + error("%qE attribute does not apply to variables", name);
94081 + return NULL_TREE;
94082 + }
94083 +
94084 + if (TYPE_P(*node)) {
94085 + *no_add_attrs = false;
94086 + type = *node;
94087 + } else {
94088 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94089 + type = TREE_TYPE(*node);
94090 + }
94091 +
94092 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94093 + error("%qE attribute applies to struct and union types only", name);
94094 + return NULL_TREE;
94095 + }
94096 +
94097 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94098 + error("%qE attribute is already applied to the type", name);
94099 + return NULL_TREE;
94100 + }
94101 +
94102 + if (TYPE_P(*node)) {
94103 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94104 + error("%qE attribute is incompatible with 'do_const'", name);
94105 + return NULL_TREE;
94106 + }
94107 +
94108 + constifiable(type, &cinfo);
94109 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94110 + deconstify_tree(*node);
94111 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94112 + return NULL_TREE;
94113 + }
94114 +
94115 + error("%qE attribute used on type that is not constified", name);
94116 + return NULL_TREE;
94117 +}
94118 +
94119 +static void constify_type(tree type)
94120 +{
94121 + TYPE_READONLY(type) = 1;
94122 + C_TYPE_FIELDS_READONLY(type) = 1;
94123 + TYPE_CONSTIFY_VISITED(type) = 1;
94124 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94125 +}
94126 +
94127 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94128 +{
94129 + *no_add_attrs = true;
94130 + if (!TYPE_P(*node)) {
94131 + error("%qE attribute applies to types only", name);
94132 + return NULL_TREE;
94133 + }
94134 +
94135 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94136 + error("%qE attribute applies to struct and union types only", name);
94137 + return NULL_TREE;
94138 + }
94139 +
94140 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94141 + error("%qE attribute is already applied to the type", name);
94142 + return NULL_TREE;
94143 + }
94144 +
94145 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94146 + error("%qE attribute is incompatible with 'no_const'", name);
94147 + return NULL_TREE;
94148 + }
94149 +
94150 + *no_add_attrs = false;
94151 + return NULL_TREE;
94152 +}
94153 +
94154 +static struct attribute_spec no_const_attr = {
94155 + .name = "no_const",
94156 + .min_length = 0,
94157 + .max_length = 0,
94158 + .decl_required = false,
94159 + .type_required = false,
94160 + .function_type_required = false,
94161 + .handler = handle_no_const_attribute,
94162 +#if BUILDING_GCC_VERSION >= 4007
94163 + .affects_type_identity = true
94164 +#endif
94165 +};
94166 +
94167 +static struct attribute_spec do_const_attr = {
94168 + .name = "do_const",
94169 + .min_length = 0,
94170 + .max_length = 0,
94171 + .decl_required = false,
94172 + .type_required = false,
94173 + .function_type_required = false,
94174 + .handler = handle_do_const_attribute,
94175 +#if BUILDING_GCC_VERSION >= 4007
94176 + .affects_type_identity = true
94177 +#endif
94178 +};
94179 +
94180 +static void register_attributes(void *event_data, void *data)
94181 +{
94182 + register_attribute(&no_const_attr);
94183 + register_attribute(&do_const_attr);
94184 +}
94185 +
94186 +static void finish_type(void *event_data, void *data)
94187 +{
94188 + tree type = (tree)event_data;
94189 + constify_info cinfo = {
94190 + .has_fptr_field = false,
94191 + .has_writable_field = false,
94192 + .has_do_const_field = false,
94193 + .has_no_const_field = false
94194 + };
94195 +
94196 + if (type == NULL_TREE || type == error_mark_node)
94197 + return;
94198 +
94199 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94200 + return;
94201 +
94202 + constifiable(type, &cinfo);
94203 +
94204 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94205 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94206 + return;
94207 + if (cinfo.has_writable_field)
94208 + return;
94209 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94210 + return;
94211 + }
94212 +
94213 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94214 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94215 + deconstify_type(type);
94216 + TYPE_CONSTIFY_VISITED(type) = 1;
94217 + } else
94218 + error("'no_const' attribute used on type that is not constified");
94219 + return;
94220 + }
94221 +
94222 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94223 + constify_type(type);
94224 + return;
94225 + }
94226 +
94227 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94228 + constify_type(type);
94229 + return;
94230 + }
94231 +
94232 + deconstify_type(type);
94233 + TYPE_CONSTIFY_VISITED(type) = 1;
94234 +}
94235 +
94236 +static unsigned int check_local_variables(void)
94237 +{
94238 + unsigned int ret = 0;
94239 + tree var;
94240 +
94241 +#if BUILDING_GCC_VERSION == 4005
94242 + tree vars;
94243 +#else
94244 + unsigned int i;
94245 +#endif
94246 +
94247 +#if BUILDING_GCC_VERSION == 4005
94248 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94249 + var = TREE_VALUE(vars);
94250 +#else
94251 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94252 +#endif
94253 + tree type = TREE_TYPE(var);
94254 +
94255 + gcc_assert(DECL_P(var));
94256 + if (is_global_var(var))
94257 + continue;
94258 +
94259 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94260 + continue;
94261 +
94262 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94263 + continue;
94264 +
94265 + if (!TYPE_CONSTIFY_VISITED(type))
94266 + continue;
94267 +
94268 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94269 + ret = 1;
94270 + }
94271 + return ret;
94272 +}
94273 +
94274 +static struct gimple_opt_pass pass_local_variable = {
94275 + {
94276 + .type = GIMPLE_PASS,
94277 + .name = "check_local_variables",
94278 +#if BUILDING_GCC_VERSION >= 4008
94279 + .optinfo_flags = OPTGROUP_NONE,
94280 +#endif
94281 + .gate = NULL,
94282 + .execute = check_local_variables,
94283 + .sub = NULL,
94284 + .next = NULL,
94285 + .static_pass_number = 0,
94286 + .tv_id = TV_NONE,
94287 + .properties_required = 0,
94288 + .properties_provided = 0,
94289 + .properties_destroyed = 0,
94290 + .todo_flags_start = 0,
94291 + .todo_flags_finish = 0
94292 + }
94293 +};
94294 +
94295 +static struct {
94296 + const char *name;
94297 + const char *asm_op;
94298 +} sections[] = {
94299 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94300 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94301 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94302 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94303 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94304 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94305 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94306 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94307 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94308 +};
94309 +
94310 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94311 +
94312 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94313 +{
94314 + size_t i;
94315 +
94316 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94317 + if (!strcmp(sections[i].name, name))
94318 + return 0;
94319 + return old_section_type_flags(decl, name, reloc);
94320 +}
94321 +
94322 +static void constify_start_unit(void *gcc_data, void *user_data)
94323 +{
94324 +// size_t i;
94325 +
94326 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94327 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94328 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94329 +
94330 + old_section_type_flags = targetm.section_type_flags;
94331 + targetm.section_type_flags = constify_section_type_flags;
94332 +}
94333 +
94334 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94335 +{
94336 + const char * const plugin_name = plugin_info->base_name;
94337 + const int argc = plugin_info->argc;
94338 + const struct plugin_argument * const argv = plugin_info->argv;
94339 + int i;
94340 + bool constify = true;
94341 +
94342 + struct register_pass_info local_variable_pass_info = {
94343 + .pass = &pass_local_variable.pass,
94344 + .reference_pass_name = "ssa",
94345 + .ref_pass_instance_number = 1,
94346 + .pos_op = PASS_POS_INSERT_BEFORE
94347 + };
94348 +
94349 + if (!plugin_default_version_check(version, &gcc_version)) {
94350 + error(G_("incompatible gcc/plugin versions"));
94351 + return 1;
94352 + }
94353 +
94354 + for (i = 0; i < argc; ++i) {
94355 + if (!(strcmp(argv[i].key, "no-constify"))) {
94356 + constify = false;
94357 + continue;
94358 + }
94359 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94360 + }
94361 +
94362 + if (strcmp(lang_hooks.name, "GNU C")) {
94363 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94364 + constify = false;
94365 + }
94366 +
94367 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94368 + if (constify) {
94369 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94370 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94371 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94372 + }
94373 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94374 +
94375 + return 0;
94376 +}
94377 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94378 new file mode 100644
94379 index 0000000..e518932
94380 --- /dev/null
94381 +++ b/tools/gcc/generate_size_overflow_hash.sh
94382 @@ -0,0 +1,94 @@
94383 +#!/bin/bash
94384 +
94385 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94386 +
94387 +header1="size_overflow_hash.h"
94388 +database="size_overflow_hash.data"
94389 +n=65536
94390 +
94391 +usage() {
94392 +cat <<EOF
94393 +usage: $0 options
94394 +OPTIONS:
94395 + -h|--help help
94396 + -o header file
94397 + -d database file
94398 + -n hash array size
94399 +EOF
94400 + return 0
94401 +}
94402 +
94403 +while true
94404 +do
94405 + case "$1" in
94406 + -h|--help) usage && exit 0;;
94407 + -n) n=$2; shift 2;;
94408 + -o) header1="$2"; shift 2;;
94409 + -d) database="$2"; shift 2;;
94410 + --) shift 1; break ;;
94411 + *) break ;;
94412 + esac
94413 +done
94414 +
94415 +create_defines() {
94416 + for i in `seq 0 31`
94417 + do
94418 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94419 + done
94420 + echo >> "$header1"
94421 +}
94422 +
94423 +create_structs() {
94424 + rm -f "$header1"
94425 +
94426 + create_defines
94427 +
94428 + cat "$database" | while read data
94429 + do
94430 + data_array=($data)
94431 + struct_hash_name="${data_array[0]}"
94432 + funcn="${data_array[1]}"
94433 + params="${data_array[2]}"
94434 + next="${data_array[4]}"
94435 +
94436 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94437 +
94438 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94439 + echo -en "\t.param\t= " >> "$header1"
94440 + line=
94441 + for param_num in ${params//-/ };
94442 + do
94443 + line="${line}PARAM"$param_num"|"
94444 + done
94445 +
94446 + echo -e "${line%?},\n};\n" >> "$header1"
94447 + done
94448 +}
94449 +
94450 +create_headers() {
94451 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94452 +}
94453 +
94454 +create_array_elements() {
94455 + index=0
94456 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94457 + do
94458 + data_array=($data)
94459 + i="${data_array[3]}"
94460 + hash="${data_array[0]}"
94461 + while [[ $index -lt $i ]]
94462 + do
94463 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94464 + index=$(($index + 1))
94465 + done
94466 + index=$(($index + 1))
94467 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94468 + done
94469 + echo '};' >> $header1
94470 +}
94471 +
94472 +create_structs
94473 +create_headers
94474 +create_array_elements
94475 +
94476 +exit 0
94477 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94478 new file mode 100644
94479 index 0000000..568b360
94480 --- /dev/null
94481 +++ b/tools/gcc/kallocstat_plugin.c
94482 @@ -0,0 +1,170 @@
94483 +/*
94484 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94485 + * Licensed under the GPL v2
94486 + *
94487 + * Note: the choice of the license means that the compilation process is
94488 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94489 + * but for the kernel it doesn't matter since it doesn't link against
94490 + * any of the gcc libraries
94491 + *
94492 + * gcc plugin to find the distribution of k*alloc sizes
94493 + *
94494 + * TODO:
94495 + *
94496 + * BUGS:
94497 + * - none known
94498 + */
94499 +#include "gcc-plugin.h"
94500 +#include "config.h"
94501 +#include "system.h"
94502 +#include "coretypes.h"
94503 +#include "tree.h"
94504 +#include "tree-pass.h"
94505 +#include "flags.h"
94506 +#include "intl.h"
94507 +#include "toplev.h"
94508 +#include "plugin.h"
94509 +//#include "expr.h" where are you...
94510 +#include "diagnostic.h"
94511 +#include "plugin-version.h"
94512 +#include "tm.h"
94513 +#include "function.h"
94514 +#include "basic-block.h"
94515 +#include "gimple.h"
94516 +#include "rtl.h"
94517 +#include "emit-rtl.h"
94518 +
94519 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94520 +
94521 +int plugin_is_GPL_compatible;
94522 +
94523 +static const char * const kalloc_functions[] = {
94524 + "__kmalloc",
94525 + "kmalloc",
94526 + "kmalloc_large",
94527 + "kmalloc_node",
94528 + "kmalloc_order",
94529 + "kmalloc_order_trace",
94530 + "kmalloc_slab",
94531 + "kzalloc",
94532 + "kzalloc_node",
94533 +};
94534 +
94535 +static struct plugin_info kallocstat_plugin_info = {
94536 + .version = "201302112000",
94537 +};
94538 +
94539 +static unsigned int execute_kallocstat(void);
94540 +
94541 +static struct gimple_opt_pass kallocstat_pass = {
94542 + .pass = {
94543 + .type = GIMPLE_PASS,
94544 + .name = "kallocstat",
94545 +#if BUILDING_GCC_VERSION >= 4008
94546 + .optinfo_flags = OPTGROUP_NONE,
94547 +#endif
94548 + .gate = NULL,
94549 + .execute = execute_kallocstat,
94550 + .sub = NULL,
94551 + .next = NULL,
94552 + .static_pass_number = 0,
94553 + .tv_id = TV_NONE,
94554 + .properties_required = 0,
94555 + .properties_provided = 0,
94556 + .properties_destroyed = 0,
94557 + .todo_flags_start = 0,
94558 + .todo_flags_finish = 0
94559 + }
94560 +};
94561 +
94562 +static bool is_kalloc(const char *fnname)
94563 +{
94564 + size_t i;
94565 +
94566 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94567 + if (!strcmp(fnname, kalloc_functions[i]))
94568 + return true;
94569 + return false;
94570 +}
94571 +
94572 +static unsigned int execute_kallocstat(void)
94573 +{
94574 + basic_block bb;
94575 +
94576 + // 1. loop through BBs and GIMPLE statements
94577 + FOR_EACH_BB(bb) {
94578 + gimple_stmt_iterator gsi;
94579 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94580 + // gimple match:
94581 + tree fndecl, size;
94582 + gimple call_stmt;
94583 + const char *fnname;
94584 +
94585 + // is it a call
94586 + call_stmt = gsi_stmt(gsi);
94587 + if (!is_gimple_call(call_stmt))
94588 + continue;
94589 + fndecl = gimple_call_fndecl(call_stmt);
94590 + if (fndecl == NULL_TREE)
94591 + continue;
94592 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94593 + continue;
94594 +
94595 + // is it a call to k*alloc
94596 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94597 + if (!is_kalloc(fnname))
94598 + continue;
94599 +
94600 + // is the size arg the result of a simple const assignment
94601 + size = gimple_call_arg(call_stmt, 0);
94602 + while (true) {
94603 + gimple def_stmt;
94604 + expanded_location xloc;
94605 + size_t size_val;
94606 +
94607 + if (TREE_CODE(size) != SSA_NAME)
94608 + break;
94609 + def_stmt = SSA_NAME_DEF_STMT(size);
94610 + if (!def_stmt || !is_gimple_assign(def_stmt))
94611 + break;
94612 + if (gimple_num_ops(def_stmt) != 2)
94613 + break;
94614 + size = gimple_assign_rhs1(def_stmt);
94615 + if (!TREE_CONSTANT(size))
94616 + continue;
94617 + xloc = expand_location(gimple_location(def_stmt));
94618 + if (!xloc.file)
94619 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94620 + size_val = TREE_INT_CST_LOW(size);
94621 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94622 + break;
94623 + }
94624 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94625 +//debug_tree(gimple_call_fn(call_stmt));
94626 +//print_node(stderr, "pax", fndecl, 4);
94627 + }
94628 + }
94629 +
94630 + return 0;
94631 +}
94632 +
94633 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94634 +{
94635 + const char * const plugin_name = plugin_info->base_name;
94636 + struct register_pass_info kallocstat_pass_info = {
94637 + .pass = &kallocstat_pass.pass,
94638 + .reference_pass_name = "ssa",
94639 + .ref_pass_instance_number = 1,
94640 + .pos_op = PASS_POS_INSERT_AFTER
94641 + };
94642 +
94643 + if (!plugin_default_version_check(version, &gcc_version)) {
94644 + error(G_("incompatible gcc/plugin versions"));
94645 + return 1;
94646 + }
94647 +
94648 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94649 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94650 +
94651 + return 0;
94652 +}
94653 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94654 new file mode 100644
94655 index 0000000..0408e06
94656 --- /dev/null
94657 +++ b/tools/gcc/kernexec_plugin.c
94658 @@ -0,0 +1,465 @@
94659 +/*
94660 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94661 + * Licensed under the GPL v2
94662 + *
94663 + * Note: the choice of the license means that the compilation process is
94664 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94665 + * but for the kernel it doesn't matter since it doesn't link against
94666 + * any of the gcc libraries
94667 + *
94668 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94669 + *
94670 + * TODO:
94671 + *
94672 + * BUGS:
94673 + * - none known
94674 + */
94675 +#include "gcc-plugin.h"
94676 +#include "config.h"
94677 +#include "system.h"
94678 +#include "coretypes.h"
94679 +#include "tree.h"
94680 +#include "tree-pass.h"
94681 +#include "flags.h"
94682 +#include "intl.h"
94683 +#include "toplev.h"
94684 +#include "plugin.h"
94685 +//#include "expr.h" where are you...
94686 +#include "diagnostic.h"
94687 +#include "plugin-version.h"
94688 +#include "tm.h"
94689 +#include "function.h"
94690 +#include "basic-block.h"
94691 +#include "gimple.h"
94692 +#include "rtl.h"
94693 +#include "emit-rtl.h"
94694 +#include "tree-flow.h"
94695 +
94696 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94697 +extern rtx emit_move_insn(rtx x, rtx y);
94698 +
94699 +#if BUILDING_GCC_VERSION <= 4006
94700 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94701 +#endif
94702 +
94703 +#if BUILDING_GCC_VERSION >= 4008
94704 +#define TODO_dump_func 0
94705 +#endif
94706 +
94707 +int plugin_is_GPL_compatible;
94708 +
94709 +static struct plugin_info kernexec_plugin_info = {
94710 + .version = "201302112000",
94711 + .help = "method=[bts|or]\tinstrumentation method\n"
94712 +};
94713 +
94714 +static unsigned int execute_kernexec_reload(void);
94715 +static unsigned int execute_kernexec_fptr(void);
94716 +static unsigned int execute_kernexec_retaddr(void);
94717 +static bool kernexec_cmodel_check(void);
94718 +
94719 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94720 +static void (*kernexec_instrument_retaddr)(rtx);
94721 +
94722 +static struct gimple_opt_pass kernexec_reload_pass = {
94723 + .pass = {
94724 + .type = GIMPLE_PASS,
94725 + .name = "kernexec_reload",
94726 +#if BUILDING_GCC_VERSION >= 4008
94727 + .optinfo_flags = OPTGROUP_NONE,
94728 +#endif
94729 + .gate = kernexec_cmodel_check,
94730 + .execute = execute_kernexec_reload,
94731 + .sub = NULL,
94732 + .next = NULL,
94733 + .static_pass_number = 0,
94734 + .tv_id = TV_NONE,
94735 + .properties_required = 0,
94736 + .properties_provided = 0,
94737 + .properties_destroyed = 0,
94738 + .todo_flags_start = 0,
94739 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94740 + }
94741 +};
94742 +
94743 +static struct gimple_opt_pass kernexec_fptr_pass = {
94744 + .pass = {
94745 + .type = GIMPLE_PASS,
94746 + .name = "kernexec_fptr",
94747 +#if BUILDING_GCC_VERSION >= 4008
94748 + .optinfo_flags = OPTGROUP_NONE,
94749 +#endif
94750 + .gate = kernexec_cmodel_check,
94751 + .execute = execute_kernexec_fptr,
94752 + .sub = NULL,
94753 + .next = NULL,
94754 + .static_pass_number = 0,
94755 + .tv_id = TV_NONE,
94756 + .properties_required = 0,
94757 + .properties_provided = 0,
94758 + .properties_destroyed = 0,
94759 + .todo_flags_start = 0,
94760 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94761 + }
94762 +};
94763 +
94764 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94765 + .pass = {
94766 + .type = RTL_PASS,
94767 + .name = "kernexec_retaddr",
94768 +#if BUILDING_GCC_VERSION >= 4008
94769 + .optinfo_flags = OPTGROUP_NONE,
94770 +#endif
94771 + .gate = kernexec_cmodel_check,
94772 + .execute = execute_kernexec_retaddr,
94773 + .sub = NULL,
94774 + .next = NULL,
94775 + .static_pass_number = 0,
94776 + .tv_id = TV_NONE,
94777 + .properties_required = 0,
94778 + .properties_provided = 0,
94779 + .properties_destroyed = 0,
94780 + .todo_flags_start = 0,
94781 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94782 + }
94783 +};
94784 +
94785 +static bool kernexec_cmodel_check(void)
94786 +{
94787 + tree section;
94788 +
94789 + if (ix86_cmodel != CM_KERNEL)
94790 + return false;
94791 +
94792 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94793 + if (!section || !TREE_VALUE(section))
94794 + return true;
94795 +
94796 + section = TREE_VALUE(TREE_VALUE(section));
94797 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94798 + return true;
94799 +
94800 + return false;
94801 +}
94802 +
94803 +/*
94804 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94805 + */
94806 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94807 +{
94808 + gimple asm_movabs_stmt;
94809 +
94810 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94811 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94812 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94813 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94814 + update_stmt(asm_movabs_stmt);
94815 +}
94816 +
94817 +/*
94818 + * find all asm() stmts that clobber r10 and add a reload of r10
94819 + */
94820 +static unsigned int execute_kernexec_reload(void)
94821 +{
94822 + basic_block bb;
94823 +
94824 + // 1. loop through BBs and GIMPLE statements
94825 + FOR_EACH_BB(bb) {
94826 + gimple_stmt_iterator gsi;
94827 +
94828 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94829 + // gimple match: __asm__ ("" : : : "r10");
94830 + gimple asm_stmt;
94831 + size_t nclobbers;
94832 +
94833 + // is it an asm ...
94834 + asm_stmt = gsi_stmt(gsi);
94835 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94836 + continue;
94837 +
94838 + // ... clobbering r10
94839 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94840 + while (nclobbers--) {
94841 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94842 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94843 + continue;
94844 + kernexec_reload_fptr_mask(&gsi);
94845 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94846 + break;
94847 + }
94848 + }
94849 + }
94850 +
94851 + return 0;
94852 +}
94853 +
94854 +/*
94855 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94856 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94857 + */
94858 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94859 +{
94860 + gimple assign_intptr, assign_new_fptr, call_stmt;
94861 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94862 +
94863 + call_stmt = gsi_stmt(*gsi);
94864 + old_fptr = gimple_call_fn(call_stmt);
94865 +
94866 + // create temporary unsigned long variable used for bitops and cast fptr to it
94867 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94868 +#if BUILDING_GCC_VERSION <= 4007
94869 + add_referenced_var(intptr);
94870 + mark_sym_for_renaming(intptr);
94871 +#endif
94872 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94873 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94874 + update_stmt(assign_intptr);
94875 +
94876 + // apply logical or to temporary unsigned long and bitmask
94877 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94878 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94879 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94880 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94881 + update_stmt(assign_intptr);
94882 +
94883 + // cast temporary unsigned long back to a temporary fptr variable
94884 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94885 +#if BUILDING_GCC_VERSION <= 4007
94886 + add_referenced_var(new_fptr);
94887 + mark_sym_for_renaming(new_fptr);
94888 +#endif
94889 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94890 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94891 + update_stmt(assign_new_fptr);
94892 +
94893 + // replace call stmt fn with the new fptr
94894 + gimple_call_set_fn(call_stmt, new_fptr);
94895 + update_stmt(call_stmt);
94896 +}
94897 +
94898 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94899 +{
94900 + gimple asm_or_stmt, call_stmt;
94901 + tree old_fptr, new_fptr, input, output;
94902 +#if BUILDING_GCC_VERSION <= 4007
94903 + VEC(tree, gc) *inputs = NULL;
94904 + VEC(tree, gc) *outputs = NULL;
94905 +#else
94906 + vec<tree, va_gc> *inputs = NULL;
94907 + vec<tree, va_gc> *outputs = NULL;
94908 +#endif
94909 +
94910 + call_stmt = gsi_stmt(*gsi);
94911 + old_fptr = gimple_call_fn(call_stmt);
94912 +
94913 + // create temporary fptr variable
94914 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94915 +#if BUILDING_GCC_VERSION <= 4007
94916 + add_referenced_var(new_fptr);
94917 + mark_sym_for_renaming(new_fptr);
94918 +#endif
94919 +
94920 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94921 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94922 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94923 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94924 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94925 +#if BUILDING_GCC_VERSION <= 4007
94926 + VEC_safe_push(tree, gc, inputs, input);
94927 + VEC_safe_push(tree, gc, outputs, output);
94928 +#else
94929 + vec_safe_push(inputs, input);
94930 + vec_safe_push(outputs, output);
94931 +#endif
94932 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94933 + gimple_asm_set_volatile(asm_or_stmt, true);
94934 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94935 + update_stmt(asm_or_stmt);
94936 +
94937 + // replace call stmt fn with the new fptr
94938 + gimple_call_set_fn(call_stmt, new_fptr);
94939 + update_stmt(call_stmt);
94940 +}
94941 +
94942 +/*
94943 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94944 + */
94945 +static unsigned int execute_kernexec_fptr(void)
94946 +{
94947 + basic_block bb;
94948 +
94949 + // 1. loop through BBs and GIMPLE statements
94950 + FOR_EACH_BB(bb) {
94951 + gimple_stmt_iterator gsi;
94952 +
94953 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94954 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94955 + tree fn;
94956 + gimple call_stmt;
94957 +
94958 + // is it a call ...
94959 + call_stmt = gsi_stmt(gsi);
94960 + if (!is_gimple_call(call_stmt))
94961 + continue;
94962 + fn = gimple_call_fn(call_stmt);
94963 + if (TREE_CODE(fn) == ADDR_EXPR)
94964 + continue;
94965 + if (TREE_CODE(fn) != SSA_NAME)
94966 + gcc_unreachable();
94967 +
94968 + // ... through a function pointer
94969 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94970 + fn = SSA_NAME_VAR(fn);
94971 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94972 + debug_tree(fn);
94973 + gcc_unreachable();
94974 + }
94975 + }
94976 + fn = TREE_TYPE(fn);
94977 + if (TREE_CODE(fn) != POINTER_TYPE)
94978 + continue;
94979 + fn = TREE_TYPE(fn);
94980 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94981 + continue;
94982 +
94983 + kernexec_instrument_fptr(&gsi);
94984 +
94985 +//debug_tree(gimple_call_fn(call_stmt));
94986 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94987 + }
94988 + }
94989 +
94990 + return 0;
94991 +}
94992 +
94993 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94994 +static void kernexec_instrument_retaddr_bts(rtx insn)
94995 +{
94996 + rtx btsq;
94997 + rtvec argvec, constraintvec, labelvec;
94998 + int line;
94999 +
95000 + // create asm volatile("btsq $63,(%%rsp)":::)
95001 + argvec = rtvec_alloc(0);
95002 + constraintvec = rtvec_alloc(0);
95003 + labelvec = rtvec_alloc(0);
95004 + line = expand_location(RTL_LOCATION(insn)).line;
95005 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95006 + MEM_VOLATILE_P(btsq) = 1;
95007 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95008 + emit_insn_before(btsq, insn);
95009 +}
95010 +
95011 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95012 +static void kernexec_instrument_retaddr_or(rtx insn)
95013 +{
95014 + rtx orq;
95015 + rtvec argvec, constraintvec, labelvec;
95016 + int line;
95017 +
95018 + // create asm volatile("orq %%r10,(%%rsp)":::)
95019 + argvec = rtvec_alloc(0);
95020 + constraintvec = rtvec_alloc(0);
95021 + labelvec = rtvec_alloc(0);
95022 + line = expand_location(RTL_LOCATION(insn)).line;
95023 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95024 + MEM_VOLATILE_P(orq) = 1;
95025 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95026 + emit_insn_before(orq, insn);
95027 +}
95028 +
95029 +/*
95030 + * find all asm level function returns and forcibly set the highest bit of the return address
95031 + */
95032 +static unsigned int execute_kernexec_retaddr(void)
95033 +{
95034 + rtx insn;
95035 +
95036 + // 1. find function returns
95037 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95038 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95039 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95040 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95041 + rtx body;
95042 +
95043 + // is it a retn
95044 + if (!JUMP_P(insn))
95045 + continue;
95046 + body = PATTERN(insn);
95047 + if (GET_CODE(body) == PARALLEL)
95048 + body = XVECEXP(body, 0, 0);
95049 + if (!ANY_RETURN_P(body))
95050 + continue;
95051 + kernexec_instrument_retaddr(insn);
95052 + }
95053 +
95054 +// print_simple_rtl(stderr, get_insns());
95055 +// print_rtl(stderr, get_insns());
95056 +
95057 + return 0;
95058 +}
95059 +
95060 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95061 +{
95062 + const char * const plugin_name = plugin_info->base_name;
95063 + const int argc = plugin_info->argc;
95064 + const struct plugin_argument * const argv = plugin_info->argv;
95065 + int i;
95066 + struct register_pass_info kernexec_reload_pass_info = {
95067 + .pass = &kernexec_reload_pass.pass,
95068 + .reference_pass_name = "ssa",
95069 + .ref_pass_instance_number = 1,
95070 + .pos_op = PASS_POS_INSERT_AFTER
95071 + };
95072 + struct register_pass_info kernexec_fptr_pass_info = {
95073 + .pass = &kernexec_fptr_pass.pass,
95074 + .reference_pass_name = "ssa",
95075 + .ref_pass_instance_number = 1,
95076 + .pos_op = PASS_POS_INSERT_AFTER
95077 + };
95078 + struct register_pass_info kernexec_retaddr_pass_info = {
95079 + .pass = &kernexec_retaddr_pass.pass,
95080 + .reference_pass_name = "pro_and_epilogue",
95081 + .ref_pass_instance_number = 1,
95082 + .pos_op = PASS_POS_INSERT_AFTER
95083 + };
95084 +
95085 + if (!plugin_default_version_check(version, &gcc_version)) {
95086 + error(G_("incompatible gcc/plugin versions"));
95087 + return 1;
95088 + }
95089 +
95090 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95091 +
95092 + if (TARGET_64BIT == 0)
95093 + return 0;
95094 +
95095 + for (i = 0; i < argc; ++i) {
95096 + if (!strcmp(argv[i].key, "method")) {
95097 + if (!argv[i].value) {
95098 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95099 + continue;
95100 + }
95101 + if (!strcmp(argv[i].value, "bts")) {
95102 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95103 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95104 + } else if (!strcmp(argv[i].value, "or")) {
95105 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95106 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95107 + fix_register("r10", 1, 1);
95108 + } else
95109 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95110 + continue;
95111 + }
95112 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95113 + }
95114 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95115 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95116 +
95117 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95118 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95119 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95120 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95121 +
95122 + return 0;
95123 +}
95124 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95125 new file mode 100644
95126 index 0000000..b5395ba
95127 --- /dev/null
95128 +++ b/tools/gcc/latent_entropy_plugin.c
95129 @@ -0,0 +1,327 @@
95130 +/*
95131 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95132 + * Licensed under the GPL v2
95133 + *
95134 + * Note: the choice of the license means that the compilation process is
95135 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95136 + * but for the kernel it doesn't matter since it doesn't link against
95137 + * any of the gcc libraries
95138 + *
95139 + * gcc plugin to help generate a little bit of entropy from program state,
95140 + * used during boot in the kernel
95141 + *
95142 + * TODO:
95143 + * - add ipa pass to identify not explicitly marked candidate functions
95144 + * - mix in more program state (function arguments/return values, loop variables, etc)
95145 + * - more instrumentation control via attribute parameters
95146 + *
95147 + * BUGS:
95148 + * - LTO needs -flto-partition=none for now
95149 + */
95150 +#include "gcc-plugin.h"
95151 +#include "config.h"
95152 +#include "system.h"
95153 +#include "coretypes.h"
95154 +#include "tree.h"
95155 +#include "tree-pass.h"
95156 +#include "flags.h"
95157 +#include "intl.h"
95158 +#include "toplev.h"
95159 +#include "plugin.h"
95160 +//#include "expr.h" where are you...
95161 +#include "diagnostic.h"
95162 +#include "plugin-version.h"
95163 +#include "tm.h"
95164 +#include "function.h"
95165 +#include "basic-block.h"
95166 +#include "gimple.h"
95167 +#include "rtl.h"
95168 +#include "emit-rtl.h"
95169 +#include "tree-flow.h"
95170 +#include "langhooks.h"
95171 +
95172 +#if BUILDING_GCC_VERSION >= 4008
95173 +#define TODO_dump_func 0
95174 +#endif
95175 +
95176 +int plugin_is_GPL_compatible;
95177 +
95178 +static tree latent_entropy_decl;
95179 +
95180 +static struct plugin_info latent_entropy_plugin_info = {
95181 + .version = "201303102320",
95182 + .help = NULL
95183 +};
95184 +
95185 +static unsigned int execute_latent_entropy(void);
95186 +static bool gate_latent_entropy(void);
95187 +
95188 +static struct gimple_opt_pass latent_entropy_pass = {
95189 + .pass = {
95190 + .type = GIMPLE_PASS,
95191 + .name = "latent_entropy",
95192 +#if BUILDING_GCC_VERSION >= 4008
95193 + .optinfo_flags = OPTGROUP_NONE,
95194 +#endif
95195 + .gate = gate_latent_entropy,
95196 + .execute = execute_latent_entropy,
95197 + .sub = NULL,
95198 + .next = NULL,
95199 + .static_pass_number = 0,
95200 + .tv_id = TV_NONE,
95201 + .properties_required = PROP_gimple_leh | PROP_cfg,
95202 + .properties_provided = 0,
95203 + .properties_destroyed = 0,
95204 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95205 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95206 + }
95207 +};
95208 +
95209 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95210 +{
95211 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95212 + *no_add_attrs = true;
95213 + error("%qE attribute only applies to functions", name);
95214 + }
95215 + return NULL_TREE;
95216 +}
95217 +
95218 +static struct attribute_spec latent_entropy_attr = {
95219 + .name = "latent_entropy",
95220 + .min_length = 0,
95221 + .max_length = 0,
95222 + .decl_required = true,
95223 + .type_required = false,
95224 + .function_type_required = false,
95225 + .handler = handle_latent_entropy_attribute,
95226 +#if BUILDING_GCC_VERSION >= 4007
95227 + .affects_type_identity = false
95228 +#endif
95229 +};
95230 +
95231 +static void register_attributes(void *event_data, void *data)
95232 +{
95233 + register_attribute(&latent_entropy_attr);
95234 +}
95235 +
95236 +static bool gate_latent_entropy(void)
95237 +{
95238 + tree latent_entropy_attr;
95239 +
95240 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95241 + return latent_entropy_attr != NULL_TREE;
95242 +}
95243 +
95244 +static unsigned HOST_WIDE_INT seed;
95245 +static unsigned HOST_WIDE_INT get_random_const(void)
95246 +{
95247 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95248 + return seed;
95249 +}
95250 +
95251 +static enum tree_code get_op(tree *rhs)
95252 +{
95253 + static enum tree_code op;
95254 + unsigned HOST_WIDE_INT random_const;
95255 +
95256 + random_const = get_random_const();
95257 +
95258 + switch (op) {
95259 + case BIT_XOR_EXPR:
95260 + op = PLUS_EXPR;
95261 + break;
95262 +
95263 + case PLUS_EXPR:
95264 + if (rhs) {
95265 + op = LROTATE_EXPR;
95266 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95267 + break;
95268 + }
95269 +
95270 + case LROTATE_EXPR:
95271 + default:
95272 + op = BIT_XOR_EXPR;
95273 + break;
95274 + }
95275 + if (rhs)
95276 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95277 + return op;
95278 +}
95279 +
95280 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95281 +{
95282 + gimple_stmt_iterator gsi;
95283 + gimple assign;
95284 + tree addxorrol, rhs;
95285 + enum tree_code op;
95286 +
95287 + op = get_op(&rhs);
95288 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95289 + assign = gimple_build_assign(local_entropy, addxorrol);
95290 +#if BUILDING_GCC_VERSION <= 4007
95291 + find_referenced_vars_in(assign);
95292 +#endif
95293 +//debug_bb(bb);
95294 + gsi = gsi_after_labels(bb);
95295 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95296 + update_stmt(assign);
95297 +}
95298 +
95299 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95300 +{
95301 + gimple_stmt_iterator gsi;
95302 + gimple assign;
95303 + tree addxorrol, temp;
95304 +
95305 + // 1. create temporary copy of latent_entropy
95306 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95307 +#if BUILDING_GCC_VERSION <= 4007
95308 + add_referenced_var(temp);
95309 + mark_sym_for_renaming(temp);
95310 +#endif
95311 +
95312 + // 2. read...
95313 + assign = gimple_build_assign(temp, latent_entropy_decl);
95314 +#if BUILDING_GCC_VERSION <= 4007
95315 + find_referenced_vars_in(assign);
95316 +#endif
95317 + gsi = gsi_after_labels(bb);
95318 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95319 + update_stmt(assign);
95320 +
95321 + // 3. ...modify...
95322 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95323 + assign = gimple_build_assign(temp, addxorrol);
95324 +#if BUILDING_GCC_VERSION <= 4007
95325 + find_referenced_vars_in(assign);
95326 +#endif
95327 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95328 + update_stmt(assign);
95329 +
95330 + // 4. ...write latent_entropy
95331 + assign = gimple_build_assign(latent_entropy_decl, temp);
95332 +#if BUILDING_GCC_VERSION <= 4007
95333 + find_referenced_vars_in(assign);
95334 +#endif
95335 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95336 + update_stmt(assign);
95337 +}
95338 +
95339 +static unsigned int execute_latent_entropy(void)
95340 +{
95341 + basic_block bb;
95342 + gimple assign;
95343 + gimple_stmt_iterator gsi;
95344 + tree local_entropy;
95345 +
95346 + if (!latent_entropy_decl) {
95347 + struct varpool_node *node;
95348 +
95349 +#if BUILDING_GCC_VERSION <= 4007
95350 + for (node = varpool_nodes; node; node = node->next) {
95351 + tree var = node->decl;
95352 +#else
95353 + FOR_EACH_VARIABLE(node) {
95354 + tree var = node->symbol.decl;
95355 +#endif
95356 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95357 + continue;
95358 + latent_entropy_decl = var;
95359 +// debug_tree(var);
95360 + break;
95361 + }
95362 + if (!latent_entropy_decl) {
95363 +// debug_tree(current_function_decl);
95364 + return 0;
95365 + }
95366 + }
95367 +
95368 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95369 +
95370 + // 1. create local entropy variable
95371 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95372 +#if BUILDING_GCC_VERSION <= 4007
95373 + add_referenced_var(local_entropy);
95374 + mark_sym_for_renaming(local_entropy);
95375 +#endif
95376 +
95377 + // 2. initialize local entropy variable
95378 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95379 + if (dom_info_available_p(CDI_DOMINATORS))
95380 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95381 + gsi = gsi_start_bb(bb);
95382 +
95383 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95384 +// gimple_set_location(assign, loc);
95385 +#if BUILDING_GCC_VERSION <= 4007
95386 + find_referenced_vars_in(assign);
95387 +#endif
95388 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95389 + update_stmt(assign);
95390 + bb = bb->next_bb;
95391 +
95392 + // 3. instrument each BB with an operation on the local entropy variable
95393 + while (bb != EXIT_BLOCK_PTR) {
95394 + perturb_local_entropy(bb, local_entropy);
95395 + bb = bb->next_bb;
95396 + };
95397 +
95398 + // 4. mix local entropy into the global entropy variable
95399 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95400 + return 0;
95401 +}
95402 +
95403 +static void start_unit_callback(void *gcc_data, void *user_data)
95404 +{
95405 + tree latent_entropy_type;
95406 +
95407 +#if BUILDING_GCC_VERSION >= 4007
95408 + seed = get_random_seed(false);
95409 +#else
95410 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95411 + seed *= seed;
95412 +#endif
95413 +
95414 + if (in_lto_p)
95415 + return;
95416 +
95417 + // extern volatile u64 latent_entropy
95418 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95419 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95420 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95421 +
95422 + TREE_STATIC(latent_entropy_decl) = 1;
95423 + TREE_PUBLIC(latent_entropy_decl) = 1;
95424 + TREE_USED(latent_entropy_decl) = 1;
95425 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95426 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95427 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95428 + DECL_INITIAL(latent_entropy_decl) = NULL;
95429 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95430 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95431 +// varpool_finalize_decl(latent_entropy_decl);
95432 +// varpool_mark_needed_node(latent_entropy_decl);
95433 +}
95434 +
95435 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95436 +{
95437 + const char * const plugin_name = plugin_info->base_name;
95438 + struct register_pass_info latent_entropy_pass_info = {
95439 + .pass = &latent_entropy_pass.pass,
95440 + .reference_pass_name = "optimized",
95441 + .ref_pass_instance_number = 1,
95442 + .pos_op = PASS_POS_INSERT_BEFORE
95443 + };
95444 +
95445 + if (!plugin_default_version_check(version, &gcc_version)) {
95446 + error(G_("incompatible gcc/plugin versions"));
95447 + return 1;
95448 + }
95449 +
95450 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95451 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95452 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95453 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95454 +
95455 + return 0;
95456 +}
95457 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95458 new file mode 100644
95459 index 0000000..ddd5b2e
95460 --- /dev/null
95461 +++ b/tools/gcc/size_overflow_hash.data
95462 @@ -0,0 +1,5876 @@
95463 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95464 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95465 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95466 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95467 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95468 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95469 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95470 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95471 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95472 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95473 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95474 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95475 +load_msg_95 load_msg 2 95 NULL
95476 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95477 +init_q_132 init_q 4 132 NULL
95478 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95479 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95480 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95481 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95482 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95483 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95484 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95485 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95486 +br_port_info_size_268 br_port_info_size 0 268 NULL
95487 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95488 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95489 +syslog_print_307 syslog_print 2 307 NULL
95490 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95491 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95492 +next_node_allowed_318 next_node_allowed 1 318 NULL
95493 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95494 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95495 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95496 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95497 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95498 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95499 +pidlist_resize_496 pidlist_resize 2 496 NULL
95500 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95501 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95502 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95503 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95504 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95505 +dle_count_543 dle_count 0 543 NULL
95506 +devres_alloc_551 devres_alloc 2 551 NULL
95507 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95508 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95509 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95510 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95511 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95512 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95513 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95514 +isp1760_register_628 isp1760_register 1-2 628 NULL
95515 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95516 +unlink_queued_645 unlink_queued 3-4 645 NULL
95517 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95518 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95519 +div_u64_rem_672 div_u64_rem 0 672 NULL
95520 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95521 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95522 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95523 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95524 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95525 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95526 +dvb_video_write_754 dvb_video_write 3 754 NULL
95527 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95528 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95529 +if_writecmd_815 if_writecmd 2 815 NULL
95530 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95531 +read_fifo_826 read_fifo 3 826 NULL
95532 +read_tree_block_841 read_tree_block 3 841 NULL
95533 +um_idi_read_850 um_idi_read 3 850 NULL
95534 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95535 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95536 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95537 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95538 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95539 +readw_931 readw 0 931 NULL
95540 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95541 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95542 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95543 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95544 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95545 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95546 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95547 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95548 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95549 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95550 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95551 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95552 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95553 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95554 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95555 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95556 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95557 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95558 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95559 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95560 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95561 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95562 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95563 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95564 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95565 +thin_status_1239 thin_status 5 1239 NULL
95566 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95567 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95568 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95569 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95570 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95571 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95572 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95573 +ffs_1322 ffs 0 1322 NULL
95574 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95575 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95576 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95577 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95578 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95579 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95580 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95581 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95582 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95583 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95584 +zone_page_state_1393 zone_page_state 0 1393 NULL
95585 +file_read_actor_1401 file_read_actor 4 1401 NULL
95586 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95587 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95588 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95589 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95590 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95591 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95592 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95593 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95594 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95595 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95596 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95597 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95598 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95599 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95600 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95601 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95602 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95603 +rmap_add_1677 rmap_add 3 1677 NULL
95604 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95605 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95606 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95607 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95608 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95609 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95610 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95611 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95612 +cosa_write_1774 cosa_write 3 1774 NULL
95613 +update_macheader_1775 update_macheader 7 1775 NULL
95614 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95615 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95616 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95617 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95618 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95619 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95620 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95621 +read_swap_header_1957 read_swap_header 0 1957 NULL
95622 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95623 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95624 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95625 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95626 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95627 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95628 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95629 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95630 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95631 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95632 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95633 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95634 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95635 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95636 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95637 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95638 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95639 +audit_expand_2098 audit_expand 2 2098 NULL
95640 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95641 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95642 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95643 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95644 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95645 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95646 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95647 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95648 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95649 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95650 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95651 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95652 +u32_array_read_2219 u32_array_read 3 2219 NULL
95653 +vhci_write_2224 vhci_write 3 2224 NULL
95654 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95655 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95656 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95657 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95658 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95659 +do_update_counters_2259 do_update_counters 4 2259 NULL
95660 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95661 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95662 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95663 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95664 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95665 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95666 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95667 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95668 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95669 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95670 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95671 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95672 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95673 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95674 +raid1_size_2419 raid1_size 0-2 2419 NULL
95675 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95676 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95677 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95678 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95679 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95680 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95681 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95682 +update_pmkid_2481 update_pmkid 4 2481 NULL
95683 +wiphy_new_2482 wiphy_new 2 2482 NULL
95684 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95685 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95686 +dm_write_2513 dm_write 3 2513 NULL
95687 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95688 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95689 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95690 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95691 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95692 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95693 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95694 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95695 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95696 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95697 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95698 +__next_cpu_2782 __next_cpu 1 2782 NULL
95699 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95700 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95701 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95702 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95703 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95704 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95705 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95706 +__swab64p_2875 __swab64p 0 2875 NULL
95707 +nla_padlen_2883 nla_padlen 1 2883 NULL
95708 +cmm_write_2896 cmm_write 3 2896 NULL
95709 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95710 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95711 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95712 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95713 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95714 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95715 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95716 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95717 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95718 +depth_write_3021 depth_write 3 3021 NULL
95719 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95720 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95721 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95722 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95723 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95724 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95725 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95726 +free_coherent_3082 free_coherent 4-2 3082 NULL
95727 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95728 +rb_alloc_3102 rb_alloc 1 3102 NULL
95729 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95730 +print_time_3132 print_time 0 3132 NULL
95731 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95732 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95733 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95734 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95735 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95736 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95737 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95738 +alloc_context_3194 alloc_context 1 3194 NULL
95739 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95740 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95741 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95742 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95743 +key_key_read_3241 key_key_read 3 3241 NULL
95744 +number_3243 number 0 3243 NULL
95745 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95746 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95747 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95748 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95749 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95750 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95751 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95752 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95753 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95754 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95755 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95756 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95757 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95758 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95759 +send_stream_3397 send_stream 4 3397 NULL
95760 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95761 +msix_map_region_3411 msix_map_region 3 3411 NULL
95762 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95763 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95764 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95765 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95766 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95767 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95768 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95769 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95770 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95771 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95772 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95773 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95774 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95775 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95776 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95777 +evtchn_read_3569 evtchn_read 3 3569 NULL
95778 +vc_resize_3585 vc_resize 2-3 3585 NULL
95779 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95780 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95781 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95782 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95783 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95784 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95785 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95786 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95787 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95788 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95789 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95790 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95791 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95792 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95793 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95794 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95795 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95796 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95797 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95798 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95799 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95800 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95801 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95802 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95803 +get_fd_set_3866 get_fd_set 1 3866 NULL
95804 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95805 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95806 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95807 +nvram_write_3894 nvram_write 3 3894 NULL
95808 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95809 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95810 +vcs_write_3910 vcs_write 3 3910 NULL
95811 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95812 +do_add_counters_3992 do_add_counters 3 3992 NULL
95813 +userspace_status_4004 userspace_status 4 4004 NULL
95814 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95815 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95816 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95817 +blk_end_request_4024 blk_end_request 3 4024 NULL
95818 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95819 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95820 +read_file_queues_4078 read_file_queues 3 4078 NULL
95821 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95822 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95823 +tm6000_read_4151 tm6000_read 3 4151 NULL
95824 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95825 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95826 +get_alua_req_4166 get_alua_req 3 4166 NULL
95827 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95828 +read_file_bool_4180 read_file_bool 3 4180 NULL
95829 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95830 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95831 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95832 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95833 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95834 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95835 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95836 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95837 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95838 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95839 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95840 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95841 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95842 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95843 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95844 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95845 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95846 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95847 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95848 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95849 +set_link_security_4502 set_link_security 4 4502 NULL
95850 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95851 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95852 +tty_register_device_4544 tty_register_device 2 4544 NULL
95853 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95854 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95855 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95856 +bch_alloc_4593 bch_alloc 1 4593 NULL
95857 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95858 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95859 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95860 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95861 +kone_receive_4690 kone_receive 4 4690 NULL
95862 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95863 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95864 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95865 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95866 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95867 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95868 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95869 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95870 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95871 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95872 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95873 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95874 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95875 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95876 +sys_ipc_4889 sys_ipc 3 4889 NULL
95877 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95878 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95879 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95880 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95881 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95882 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95883 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95884 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95885 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95886 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95887 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95888 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95889 +do_mincore_5018 do_mincore 0-1 5018 NULL
95890 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95891 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95892 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95893 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95894 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95895 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95896 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95897 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95898 +sound_write_5102 sound_write 3 5102 NULL
95899 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95900 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95901 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95902 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95903 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95904 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95905 +skb_network_header_5203 skb_network_header 0 5203 NULL
95906 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95907 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95908 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95909 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95910 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95911 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95912 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95913 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95914 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95915 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95916 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95917 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95918 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95919 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95920 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95921 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95922 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95923 +tty_write_5494 tty_write 3 5494 NULL
95924 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95925 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95926 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95927 +spidev_message_5518 spidev_message 3 5518 NULL
95928 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95929 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95930 +le_readq_5557 le_readq 0 5557 NULL
95931 +inw_5558 inw 0 5558 NULL
95932 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95933 +fir16_create_5574 fir16_create 3 5574 NULL
95934 +bioset_create_5580 bioset_create 1 5580 NULL
95935 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95936 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95937 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95938 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95939 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95940 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95941 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95942 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95943 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95944 +get_arg_5694 get_arg 3 5694 NULL
95945 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95946 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95947 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95948 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95949 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95950 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95951 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95952 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95953 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95954 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95955 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95956 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95957 +setup_req_5848 setup_req 3 5848 NULL
95958 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95959 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95960 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95961 +port_show_regs_5904 port_show_regs 3 5904 NULL
95962 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95963 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95964 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95965 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95966 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95967 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95968 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95969 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95970 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95971 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95972 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95973 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95974 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95975 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95976 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95977 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95978 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95979 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95980 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95981 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95982 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95983 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95984 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95985 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95986 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95987 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95988 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95989 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95990 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95991 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95992 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95993 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95994 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95995 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95996 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95997 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95998 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95999 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96000 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
96001 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
96002 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96003 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96004 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96005 +mei_read_6507 mei_read 3 6507 NULL
96006 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
96007 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96008 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96009 +wdm_read_6549 wdm_read 3 6549 NULL
96010 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96011 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
96012 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
96013 +usemap_size_6601 usemap_size 0-1 6601 NULL
96014 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96015 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96016 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96017 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96018 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96019 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96020 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
96021 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96022 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96023 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96024 +mpeg_read_6708 mpeg_read 3 6708 NULL
96025 +video_proc_write_6724 video_proc_write 3 6724 NULL
96026 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96027 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96028 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96029 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96030 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96031 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96032 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96033 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96034 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96035 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96036 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96037 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96038 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96039 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96040 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96041 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96042 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96043 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96044 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
96045 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96046 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96047 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96048 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96049 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96050 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96051 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96052 +request_key_async_6990 request_key_async 4 6990 NULL
96053 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96054 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96055 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96056 +wimax_msg_7030 wimax_msg 4 7030 NULL
96057 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96058 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96059 +event_enable_read_7074 event_enable_read 3 7074 NULL
96060 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96061 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96062 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96063 +check_header_7108 check_header 0 7108 NULL
96064 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
96065 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
96066 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
96067 +get_param_h_7247 get_param_h 0 7247 NULL
96068 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96069 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96070 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96071 +mgmt_control_7349 mgmt_control 3 7349 NULL
96072 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96073 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96074 +hweight_long_7388 hweight_long 0-1 7388 NULL
96075 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96076 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96077 +readb_7401 readb 0 7401 NULL
96078 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96079 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96080 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
96081 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
96082 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
96083 +garp_request_join_7471 garp_request_join 4 7471 NULL
96084 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96085 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96086 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96087 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96088 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96089 +setup_usemap_7524 setup_usemap 3 7524 NULL
96090 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96091 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96092 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96093 +groups_alloc_7614 groups_alloc 1 7614 NULL
96094 +sg_virt_7616 sg_virt 0 7616 NULL
96095 +cpumask_first_7648 cpumask_first 0 7648 NULL
96096 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96097 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96098 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96099 +dev_write_7708 dev_write 3 7708 NULL
96100 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
96101 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
96102 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
96103 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96104 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96105 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96106 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96107 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96108 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96109 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96110 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96111 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96112 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
96113 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
96114 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96115 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96116 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96117 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96118 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96119 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96120 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96121 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96122 +sys_mbind_7990 sys_mbind 5 7990 NULL
96123 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96124 +vcs_read_8017 vcs_read 3 8017 NULL
96125 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96126 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96127 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96128 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96129 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96130 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96131 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96132 +venus_lookup_8121 venus_lookup 4 8121 NULL
96133 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96134 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96135 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96136 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96137 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96138 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96139 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96140 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96141 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96142 +play_iframe_8219 play_iframe 3 8219 NULL
96143 +create_log_8225 create_log 2 8225 NULL nohasharray
96144 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96145 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96146 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96147 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96148 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96149 +init_cdev_8274 init_cdev 1 8274 NULL
96150 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96151 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96152 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96153 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96154 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96155 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96156 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96157 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96158 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96159 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96160 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96161 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96162 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96163 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96164 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96165 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96166 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96167 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96168 +dev_config_8506 dev_config 3 8506 NULL
96169 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96170 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96171 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96172 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96173 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96174 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96175 +profile_remove_8556 profile_remove 3 8556 NULL
96176 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96177 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96178 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96179 +tower_write_8580 tower_write 3 8580 NULL
96180 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96181 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96182 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96183 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96184 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96185 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96186 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96187 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96188 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96189 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96190 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96191 +arcfb_write_8702 arcfb_write 3 8702 NULL
96192 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96193 +init_header_8703 init_header 0 8703 &i_size_read_8703
96194 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96195 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96196 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96197 +f_dupfd_8730 f_dupfd 1 8730 NULL
96198 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96199 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96200 +sys_prctl_8766 sys_prctl 4 8766 NULL
96201 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96202 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96203 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96204 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96205 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96206 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96207 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96208 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96209 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96210 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96211 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96212 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96213 +send_pages_8872 send_pages 3 8872 NULL
96214 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96215 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96216 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96217 +layout_commit_8926 layout_commit 3 8926 NULL
96218 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96219 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96220 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96221 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96222 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96223 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96224 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96225 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96226 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96227 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96228 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96229 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96230 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96231 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96232 +nla_put_9042 nla_put 3 9042 NULL
96233 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96234 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96235 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96236 +string_9080 string 0 9080 NULL
96237 +create_queues_9088 create_queues 2-3 9088 NULL
96238 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96239 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96240 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96241 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96242 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96243 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96244 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96245 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96246 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96247 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96248 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96249 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96250 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96251 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96252 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96253 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96254 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96255 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96256 +flakey_status_9274 flakey_status 5 9274 NULL
96257 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96258 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96259 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96260 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96261 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96262 +read_9397 read 3 9397 NULL
96263 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96264 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96265 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96266 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96267 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96268 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96269 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96270 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96271 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96272 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96273 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96274 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96275 +lp_write_9511 lp_write 3 9511 NULL
96276 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96277 +lm3533_update_9529 lm3533_update 2 9529 NULL
96278 +read_file_dma_9530 read_file_dma 3 9530 NULL
96279 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96280 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96281 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96282 +readl_9557 readl 0 9557 NULL
96283 +fw_node_create_9559 fw_node_create 2 9559 NULL
96284 +kobj_map_9566 kobj_map 2-3 9566 NULL
96285 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96286 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96287 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96288 +do_sync_9604 do_sync 1 9604 NULL
96289 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96290 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96291 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96292 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96293 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96294 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96295 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96296 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96297 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96298 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96299 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96300 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96301 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96302 +fnb_9703 fnb 2-3 9703 NULL
96303 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96304 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96305 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96306 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96307 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96308 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96309 +do_sigpending_9766 do_sigpending 2 9766 NULL
96310 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96311 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96312 +_regmap_write_9803 _regmap_write 2 9803 NULL
96313 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96314 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96315 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96316 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96317 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96318 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96319 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96320 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96321 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96322 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96323 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96324 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96325 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96326 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96327 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96328 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96329 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96330 +read_file_misc_9948 read_file_misc 3 9948 NULL
96331 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96332 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96333 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96334 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96335 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96336 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96337 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96338 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96339 +handle_request_10024 handle_request 9 10024 NULL
96340 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96341 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96342 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96343 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96344 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96345 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96346 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96347 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96348 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96349 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96350 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96351 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96352 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96353 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96354 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96355 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96356 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96357 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96358 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96359 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96360 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96361 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96362 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96363 +read_emulate_10310 read_emulate 2-4 10310 NULL
96364 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96365 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96366 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96367 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96368 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96369 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96370 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96371 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96372 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96373 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96374 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96375 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96376 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96377 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96378 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96379 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96380 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96381 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96382 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96383 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96384 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96385 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96386 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96387 +otp_read_10594 otp_read 2-4-5 10594 NULL
96388 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96389 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96390 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96391 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96392 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96393 +parport_write_10669 parport_write 0 10669 NULL
96394 +inl_10708 inl 0 10708 NULL nohasharray
96395 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96396 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96397 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96398 +spi_sync_10731 spi_sync 0 10731 NULL
96399 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96400 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96401 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96402 +sys_syslog_10746 sys_syslog 3 10746 NULL
96403 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96404 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96405 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96406 +sys_bind_10799 sys_bind 3 10799 NULL
96407 +compat_put_int_10828 compat_put_int 1 10828 NULL
96408 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96409 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96410 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96411 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96412 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96413 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96414 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96415 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96416 +get_scq_10897 get_scq 2 10897 NULL
96417 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96418 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96419 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96420 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96421 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96422 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96423 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96424 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96425 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96426 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96427 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96428 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96429 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96430 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96431 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96432 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96433 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96434 +count_argc_11083 count_argc 0 11083 NULL
96435 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96436 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96437 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96438 +page_offset_11120 page_offset 0 11120 NULL
96439 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96440 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96441 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96442 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96443 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96444 +__swab16p_11220 __swab16p 0 11220 NULL
96445 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96446 +of_irq_count_11253 of_irq_count 0 11253 NULL
96447 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96448 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96449 +cru_detect_11272 cru_detect 1 11272 NULL
96450 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96451 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96452 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96453 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96454 +next_segment_11330 next_segment 0-2-1 11330 NULL
96455 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96456 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96457 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96458 +sel_write_create_11353 sel_write_create 3 11353 NULL
96459 +handle_unit_11355 handle_unit 0-1 11355 NULL
96460 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96461 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96462 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96463 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96464 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96465 +str_to_user_11411 str_to_user 2 11411 NULL
96466 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96467 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96468 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96469 +trace_options_read_11419 trace_options_read 3 11419 NULL
96470 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96471 +prepare_image_11424 prepare_image 0 11424 NULL
96472 +vring_size_11426 vring_size 0-1-2 11426 NULL
96473 +bttv_read_11432 bttv_read 3 11432 NULL
96474 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96475 +swp_offset_11475 swp_offset 0 11475 NULL
96476 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96477 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96478 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96479 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96480 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96481 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96482 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96483 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96484 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96485 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96486 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96487 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96488 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96489 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96490 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96491 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96492 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96493 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96494 +split_11691 split 2 11691 NULL
96495 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96496 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96497 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96498 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96499 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96500 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96501 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96502 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96503 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96504 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96505 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96506 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96507 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96508 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96509 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96510 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96511 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96512 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96513 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96514 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96515 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96516 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96517 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96518 +atmel_read16_11981 atmel_read16 0 11981 NULL
96519 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96520 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96521 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96522 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96523 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96524 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96525 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96526 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96527 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96528 +set_powered_12129 set_powered 4 12129 NULL
96529 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96530 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96531 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96532 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96533 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96534 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96535 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96536 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96537 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96538 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96539 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96540 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96541 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96542 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96543 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96544 +receive_copy_12216 receive_copy 3 12216 NULL
96545 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96546 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96547 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96548 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96549 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96550 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96551 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96552 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96553 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96554 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96555 +split_bvec_12312 split_bvec 6 12312 NULL
96556 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96557 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96558 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96559 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96560 +receive_packet_12367 receive_packet 2 12367 NULL
96561 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96562 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96563 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96564 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96565 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96566 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96567 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96568 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96569 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96570 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96571 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96572 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96573 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96574 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96575 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96576 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96577 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96578 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96579 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96580 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96581 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96582 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96583 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96584 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96585 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96586 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96587 +ivtv_write_12721 ivtv_write 3 12721 NULL
96588 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96589 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96590 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96591 +listxattr_12769 listxattr 3 12769 NULL
96592 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96593 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96594 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96595 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96596 +readq_12825 readq 0 12825 NULL
96597 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96598 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96599 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96600 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96601 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96602 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96603 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96604 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96605 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96606 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96607 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96608 +bm_status_write_12964 bm_status_write 3 12964 NULL
96609 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96610 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96611 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96612 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96613 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96614 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96615 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96616 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96617 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96618 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96619 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96620 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96621 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96622 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96623 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96624 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96625 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96626 +blk_update_request_13146 blk_update_request 3 13146 NULL
96627 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96628 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96629 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96630 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96631 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96632 +comedi_read_13199 comedi_read 3 13199 NULL
96633 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96634 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96635 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96636 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96637 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96638 +fw_download_code_13249 fw_download_code 3 13249 NULL
96639 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96640 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96641 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96642 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96643 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96644 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96645 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96646 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96647 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96648 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96649 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96650 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96651 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96652 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96653 +sky2_receive_13407 sky2_receive 2 13407 NULL
96654 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96655 +keyring_read_13438 keyring_read 3 13438 NULL
96656 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96657 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96658 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96659 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96660 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96661 +core_status_13515 core_status 4 13515 NULL
96662 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96663 +bm_init_13529 bm_init 2 13529 NULL
96664 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96665 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96666 +alloc_tio_13564 alloc_tio 3 13564 NULL
96667 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96668 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96669 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96670 +cache_write_13589 cache_write 3 13589 NULL
96671 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96672 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96673 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96674 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96675 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96676 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96677 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96678 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96679 +packet_snd_13634 packet_snd 3 13634 NULL
96680 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96681 +cache_downcall_13666 cache_downcall 3 13666 NULL
96682 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96683 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96684 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96685 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96686 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96687 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96688 +random_read_13815 random_read 3 13815 NULL
96689 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96690 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96691 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96692 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96693 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96694 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96695 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96696 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96697 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96698 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96699 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96700 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96701 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96702 +com90xx_found_13974 com90xx_found 3 13974 NULL
96703 +qcam_read_13977 qcam_read 3 13977 NULL
96704 +dsp_read_13980 dsp_read 2 13980 NULL
96705 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96706 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96707 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96708 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96709 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96710 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96711 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96712 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96713 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96714 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96715 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96716 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96717 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96718 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96719 +em_canid_change_14150 em_canid_change 3 14150 NULL
96720 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96721 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96722 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96723 +alloc_async_14208 alloc_async 1 14208 NULL
96724 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96725 +pool_status_14230 pool_status 5 14230 NULL
96726 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96727 +inode_to_path_14235 inode_to_path 2 14235 NULL
96728 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96729 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96730 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96731 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96732 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96733 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96734 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96735 +rr_status_14293 rr_status 5 14293 NULL
96736 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96737 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96738 +oo_objects_14319 oo_objects 0 14319 NULL
96739 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96740 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96741 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96742 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96743 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96744 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96745 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96746 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96747 +block_size_14443 block_size 0 14443 NULL
96748 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96749 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96750 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96751 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96752 +stripe_status_14506 stripe_status 5 14506 NULL
96753 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96754 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96755 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96756 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96757 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96758 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96759 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96760 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96761 +dbJoin_14644 dbJoin 0 14644 NULL
96762 +profile_replace_14652 profile_replace 3 14652 NULL
96763 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96764 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96765 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96766 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96767 +vfd_write_14717 vfd_write 3 14717 NULL
96768 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96769 +raid1_resize_14740 raid1_resize 2 14740 NULL
96770 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96771 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96772 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96773 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96774 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96775 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96776 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96777 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96778 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96779 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96780 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96781 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96782 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96783 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96784 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96785 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96786 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96787 +unifi_read_14899 unifi_read 3 14899 NULL
96788 +krealloc_14908 krealloc 2 14908 NULL
96789 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96790 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96791 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96792 +queue_cnt_14951 queue_cnt 0 14951 NULL
96793 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96794 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96795 +setkey_14987 setkey 3 14987 NULL nohasharray
96796 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96797 +vmap_15025 vmap 2 15025 NULL
96798 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96799 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96800 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96801 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96802 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96803 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96804 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96805 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96806 +start_port_15124 start_port 0 15124 NULL
96807 +memchr_15126 memchr 0 15126 NULL
96808 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96809 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96810 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96811 +reserve_resources_15194 reserve_resources 3 15194 NULL
96812 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96813 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96814 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96815 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96816 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96817 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96818 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96819 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96820 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96821 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96822 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96823 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96824 +ioread16_15342 ioread16 0 15342 NULL
96825 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96826 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96827 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96828 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96829 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96830 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96831 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96832 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96833 +get_modalias_15406 get_modalias 2 15406 NULL
96834 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96835 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96836 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96837 +memweight_15450 memweight 2 15450 NULL
96838 +vmalloc_15464 vmalloc 1 15464 NULL
96839 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96840 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96841 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96842 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96843 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96844 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96845 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96846 +persistent_status_15574 persistent_status 4 15574 NULL
96847 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96848 +vme_user_write_15587 vme_user_write 3 15587 NULL
96849 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96850 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96851 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96852 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96853 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96854 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96855 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96856 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96857 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96858 +fs_path_add_15648 fs_path_add 3 15648 NULL
96859 +xsd_read_15653 xsd_read 3 15653 NULL
96860 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96861 +unix_bind_15668 unix_bind 3 15668 NULL
96862 +dm_read_15674 dm_read 3 15674 NULL
96863 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96864 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96865 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96866 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96867 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96868 +do_test_15766 do_test 1 15766 NULL
96869 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96870 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96871 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96872 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96873 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96874 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96875 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96876 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96877 +table_size_15851 table_size 0-1-2 15851 NULL
96878 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96879 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96880 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96881 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96882 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96883 +native_read_msr_15905 native_read_msr 0 15905 NULL
96884 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96885 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96886 +power_read_15939 power_read 3 15939 NULL
96887 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96888 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96889 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96890 +set_spte_15977 set_spte 7-6 15977 NULL
96891 +frame_alloc_15981 frame_alloc 4 15981 NULL
96892 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96893 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96894 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96895 +got_frame_16028 got_frame 2 16028 NULL
96896 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96897 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96898 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96899 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96900 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96901 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96902 +fsm_init_16134 fsm_init 2 16134 NULL
96903 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96904 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96905 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96906 +mapping_level_16188 mapping_level 2 16188 NULL
96907 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96908 +create_table_16213 create_table 2 16213 NULL
96909 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96910 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96911 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96912 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96913 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96914 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96915 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96916 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96917 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96918 +account_16283 account 0-2-4 16283 NULL nohasharray
96919 +mirror_status_16283 mirror_status 5 16283 &account_16283
96920 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96921 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96922 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96923 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96924 +tps80031_update_16360 tps80031_update 3 16360 NULL
96925 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96926 +rbd_add_16366 rbd_add 3 16366 NULL
96927 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96928 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96929 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96930 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96931 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96932 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96933 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96934 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96935 +raid10_resize_16537 raid10_resize 2 16537 NULL
96936 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96937 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96938 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96939 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96940 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96941 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96942 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96943 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96944 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96945 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96946 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96947 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96948 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96949 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96950 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96951 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96952 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96953 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96954 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96955 +st_write_16874 st_write 3 16874 NULL
96956 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96957 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96958 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96959 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96960 +random32_16937 random32 0 16937 NULL
96961 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96962 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96963 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96964 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96965 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96966 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96967 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96968 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96969 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96970 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96971 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96972 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96973 +mac_address_string_17091 mac_address_string 0 17091 NULL
96974 +entry_length_17093 entry_length 0 17093 NULL
96975 +sys_preadv_17100 sys_preadv 3 17100 NULL
96976 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96977 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96978 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96979 +sep_read_17161 sep_read 3 17161 NULL
96980 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96981 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96982 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96983 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96984 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96985 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96986 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96987 +ms_rw_17220 ms_rw 3-4 17220 NULL
96988 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96989 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96990 +alloc_ep_17269 alloc_ep 1 17269 NULL
96991 +pg_read_17276 pg_read 3 17276 NULL
96992 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96993 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96994 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96995 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96996 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96997 +skb_pad_17302 skb_pad 2 17302 NULL
96998 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96999 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97000 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97001 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97002 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97003 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97004 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97005 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97006 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97007 +compat_cmd_17465 compat_cmd 2 17465 NULL
97008 +probe_bios_17467 probe_bios 1 17467 NULL
97009 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97010 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97011 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97012 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97013 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
97014 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
97015 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97016 +copy_from_user_17559 copy_from_user 3 17559 NULL
97017 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
97018 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97019 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97020 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97021 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97022 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97023 +osst_execute_17607 osst_execute 7-6 17607 NULL
97024 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97025 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97026 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97027 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97028 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97029 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97030 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97031 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97032 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97033 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97034 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97035 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97036 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97037 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
97038 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97039 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97040 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97041 +count_leafs_17842 count_leafs 0 17842 NULL
97042 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97043 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97044 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97045 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97046 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97047 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97048 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97049 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97050 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97051 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
97052 +recover_head_17904 recover_head 3 17904 NULL
97053 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97054 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97055 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97056 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97057 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97058 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97059 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97060 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97061 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97062 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97063 +prandom32_18007 prandom32 0 18007 NULL
97064 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97065 +fill_read_18019 fill_read 0 18019 NULL
97066 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97067 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97068 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97069 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97070 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97071 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97072 +packet_came_18072 packet_came 3 18072 NULL
97073 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
97074 +get_vm_area_18080 get_vm_area 1 18080 NULL
97075 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97076 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
97077 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97078 +svc_getnl_18120 svc_getnl 0 18120 NULL
97079 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97080 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97081 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
97082 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97083 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
97084 +_has_tag_18169 _has_tag 2 18169 NULL
97085 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97086 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
97087 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97088 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97089 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97090 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97091 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97092 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97093 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97094 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97095 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97096 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97097 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97098 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97099 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97100 +um_idi_write_18293 um_idi_write 3 18293 NULL
97101 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97102 +vga_r_18310 vga_r 0 18310 NULL
97103 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97104 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97105 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
97106 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97107 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97108 +ep_io_18367 ep_io 0 18367 NULL
97109 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
97110 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
97111 +__video_register_device_18399 __video_register_device 3 18399 NULL
97112 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
97113 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
97114 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97115 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97116 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97117 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97118 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97119 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97120 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97121 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97122 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97123 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97124 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97125 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97126 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97127 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97128 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97129 +debug_output_18575 debug_output 3 18575 NULL
97130 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97131 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97132 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97133 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97134 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97135 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97136 +from_buffer_18625 from_buffer 3 18625 NULL
97137 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97138 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97139 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97140 +unmap_page_18665 unmap_page 2-3 18665 NULL
97141 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97142 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97143 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97144 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97145 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97146 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97147 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97148 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97149 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97150 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97151 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97152 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97153 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97154 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97155 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97156 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97157 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97158 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97159 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97160 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97161 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97162 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97163 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97164 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97165 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97166 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97167 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97168 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97169 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97170 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97171 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97172 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97173 +huge_page_size_19008 huge_page_size 0 19008 NULL
97174 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97175 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97176 +revalidate_19043 revalidate 2 19043 NULL
97177 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97178 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97179 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97180 +copy_and_check_19089 copy_and_check 3 19089 NULL
97181 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97182 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97183 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97184 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97185 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97186 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97187 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97188 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97189 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97190 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97191 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97192 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97193 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97194 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97195 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97196 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97197 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97198 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97199 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97200 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97201 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97202 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97203 +qc_capture_19298 qc_capture 3 19298 NULL
97204 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97205 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97206 +debug_read_19322 debug_read 3 19322 NULL
97207 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97208 +read_zero_19366 read_zero 3 19366 NULL
97209 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97210 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97211 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97212 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97213 +__phys_addr_19434 __phys_addr 0 19434 NULL
97214 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97215 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97216 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97217 +sky2_read16_19475 sky2_read16 0 19475 NULL
97218 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97219 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97220 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97221 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97222 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97223 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97224 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97225 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97226 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97227 +nfsd_read_19568 nfsd_read 5 19568 NULL
97228 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97229 +bm_status_read_19583 bm_status_read 3 19583 NULL
97230 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97231 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97232 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97233 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97234 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97235 +read_reg_19723 read_reg 0 19723 NULL
97236 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97237 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97238 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97239 +p9_client_read_19750 p9_client_read 5 19750 NULL
97240 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97241 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97242 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97243 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97244 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97245 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97246 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97247 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97248 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97249 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97250 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97251 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97252 +__nla_put_19857 __nla_put 3 19857 NULL
97253 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97254 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97255 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97256 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97257 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97258 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97259 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97260 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97261 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97262 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97263 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97264 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97265 +team_options_register_20091 team_options_register 3 20091 NULL
97266 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97267 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97268 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97269 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97270 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97271 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97272 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97273 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97274 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97275 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97276 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97277 +resource_size_20256 resource_size 0 20256 NULL
97278 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97279 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97280 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97281 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97282 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97283 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97284 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97285 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97286 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97287 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97288 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97289 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97290 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97291 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97292 +read_buf_20469 read_buf 2 20469 NULL
97293 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97294 +fast_user_write_20494 fast_user_write 5 20494 NULL
97295 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97296 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97297 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97298 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97299 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97300 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97301 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97302 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97303 +venus_create_20555 venus_create 4 20555 NULL
97304 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97305 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97306 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97307 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97308 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97309 +lirc_write_20604 lirc_write 3 20604 NULL
97310 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97311 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97312 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97313 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97314 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97315 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97316 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97317 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97318 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97319 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97320 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97321 +cpumask_size_20683 cpumask_size 0 20683 NULL
97322 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97323 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97324 +__maestro_read_20700 __maestro_read 0 20700 NULL
97325 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97326 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97327 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97328 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97329 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97330 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97331 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97332 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97333 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97334 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97335 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97336 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97337 +sys_sendto_20809 sys_sendto 6 20809 NULL
97338 +strndup_user_20819 strndup_user 2 20819 NULL
97339 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97340 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97341 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97342 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97343 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97344 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97345 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97346 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97347 +htable_bits_20933 htable_bits 0 20933 NULL
97348 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97349 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97350 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97351 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97352 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97353 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97354 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97355 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97356 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97357 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97358 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97359 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97360 +multipath_status_21094 multipath_status 5 21094 NULL
97361 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97362 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97363 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97364 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97365 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97366 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97367 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97368 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97369 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97370 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97371 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97372 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97373 +input_ff_create_21240 input_ff_create 2 21240 NULL
97374 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97375 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97376 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97377 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97378 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97379 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97380 +add_res_range_21310 add_res_range 4 21310 NULL
97381 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97382 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97383 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97384 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97385 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97386 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97387 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97388 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97389 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97390 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97391 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97392 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97393 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97394 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97395 +concat_writev_21451 concat_writev 3 21451 NULL
97396 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97397 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97398 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97399 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97400 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97401 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97402 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97403 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97404 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97405 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97406 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97407 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97408 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97409 +validate_nnode_21638 validate_nnode 0 21638 NULL
97410 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97411 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97412 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97413 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97414 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97415 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97416 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97417 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97418 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97419 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97420 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97421 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97422 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97423 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97424 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97425 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97426 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97427 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97428 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97429 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97430 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97431 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97432 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97433 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97434 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97435 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97436 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97437 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97438 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97439 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97440 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97441 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97442 +ti_recv_22027 ti_recv 4 22027 NULL
97443 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97444 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97445 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97446 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97447 +mem_rw_22085 mem_rw 3 22085 NULL
97448 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97449 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97450 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97451 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97452 +compat_insn_22142 compat_insn 2 22142 NULL
97453 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97454 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97455 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97456 +fls_22210 fls 0 22210 NULL
97457 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97458 +mem_write_22232 mem_write 3 22232 NULL
97459 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97460 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97461 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97462 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97463 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97464 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97465 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97466 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97467 +get_segment_base_22324 get_segment_base 0 22324 NULL
97468 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97469 +atomic_read_22342 atomic_read 0 22342 NULL
97470 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97471 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97472 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97473 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97474 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97475 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97476 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97477 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97478 +zoran_write_22404 zoran_write 3 22404 NULL
97479 +queue_reply_22416 queue_reply 3 22416 NULL
97480 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97481 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97482 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97483 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97484 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97485 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97486 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97487 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97488 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97489 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97490 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97491 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97492 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97493 +snapshot_read_22601 snapshot_read 3 22601 NULL
97494 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97495 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97496 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97497 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97498 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97499 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97500 +fill_gap_22681 fill_gap 0 22681 NULL
97501 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97502 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97503 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97504 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97505 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97506 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97507 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97508 +print_frame_22769 print_frame 0 22769 NULL
97509 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97510 +retu_write_22800 retu_write 2 22800 NULL
97511 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97512 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97513 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97514 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97515 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97516 +create_attr_set_22861 create_attr_set 1 22861 NULL
97517 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97518 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97519 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97520 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97521 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97522 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97523 +vme_get_size_22964 vme_get_size 0 22964 NULL
97524 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97525 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97526 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97527 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97528 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97529 +st_status_23032 st_status 5 23032 NULL
97530 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97531 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97532 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97533 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97534 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97535 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97536 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97537 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97538 +fls_long_23096 fls_long 0 23096 NULL
97539 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97540 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97541 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97542 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97543 +__clear_user_23118 __clear_user 0 23118 NULL
97544 +dm_write_async_23120 dm_write_async 3 23120 NULL
97545 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97546 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97547 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97548 +read_file_ani_23161 read_file_ani 3 23161 NULL
97549 +ioremap_23172 ioremap 1-2 23172 NULL
97550 +usblp_write_23178 usblp_write 3 23178 NULL
97551 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97552 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97553 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97554 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97555 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97556 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97557 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97558 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97559 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97560 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97561 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97562 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97563 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97564 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97565 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97566 +doc_probe_23285 doc_probe 1 23285 NULL
97567 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97568 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97569 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97570 +page_readlink_23346 page_readlink 3 23346 NULL
97571 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97572 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97573 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97574 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97575 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97576 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97577 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97578 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97579 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97580 +event_filter_read_23494 event_filter_read 3 23494 NULL
97581 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97582 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97583 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97584 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97585 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97586 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97587 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97588 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97589 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97590 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97591 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97592 +sInW_23663 sInW 0 23663 NULL
97593 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97594 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97595 +cx18_read_23699 cx18_read 3 23699 NULL
97596 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97597 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97598 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97599 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97600 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97601 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97602 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97603 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97604 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97605 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97606 +p54_init_common_23850 p54_init_common 1 23850 NULL
97607 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97608 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97609 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97610 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97611 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97612 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97613 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97614 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97615 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97616 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97617 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97618 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97619 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97620 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97621 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97622 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97623 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97624 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97625 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97626 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97627 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97628 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97629 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97630 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97631 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97632 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97633 +mpu401_read_24126 mpu401_read 3 24126 NULL
97634 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97635 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97636 +adu_read_24177 adu_read 3 24177 NULL
97637 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97638 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97639 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97640 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97641 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97642 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97643 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97644 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97645 +thin_status_24278 thin_status 5 24278 NULL
97646 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97647 +msg_size_24288 msg_size 0 24288 NULL
97648 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97649 +map_page_24298 map_page 3-4 24298 NULL
97650 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97651 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97652 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97653 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97654 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97655 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97656 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97657 +igetword_24373 igetword 0 24373 NULL
97658 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97659 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97660 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97661 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97662 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97663 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97664 +smk_user_access_24440 smk_user_access 3 24440 NULL
97665 +page_address_24444 page_address 0 24444 NULL
97666 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97667 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97668 +pd_video_read_24510 pd_video_read 3 24510 NULL
97669 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97670 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97671 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97672 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97673 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97674 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97675 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97676 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97677 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97678 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97679 +context_alloc_24645 context_alloc 3 24645 NULL
97680 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97681 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97682 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97683 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97684 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97685 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97686 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97687 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97688 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97689 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97690 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97691 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97692 +cache_read_24790 cache_read 3 24790 NULL
97693 +unpack_str_24798 unpack_str 0 24798 NULL
97694 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97695 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97696 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97697 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97698 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97699 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97700 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97701 +queues_read_24877 queues_read 3 24877 NULL
97702 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97703 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97704 +next_token_24929 next_token 0 24929 NULL
97705 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97706 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97707 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97708 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97709 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97710 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97711 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97712 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97713 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97714 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97715 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97716 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97717 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97718 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97719 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97720 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97721 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97722 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97723 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97724 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97725 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97726 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97727 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97728 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97729 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97730 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97731 +stripe_status_25259 stripe_status 5 25259 NULL
97732 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97733 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97734 +vfs_writev_25278 vfs_writev 3 25278 NULL
97735 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97736 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97737 +help_25316 help 5 25316 NULL nohasharray
97738 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97739 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97740 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97741 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97742 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97743 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97744 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97745 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97746 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97747 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97748 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97749 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97750 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97751 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97752 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97753 +sb_permission_25523 sb_permission 0 25523 NULL
97754 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97755 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97756 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97757 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97758 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97759 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97760 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97761 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97762 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97763 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97764 +__direct_map_25647 __direct_map 5-6 25647 NULL
97765 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97766 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97767 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97768 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97769 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97770 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97771 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97772 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97773 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97774 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97775 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97776 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97777 +sg_read_25799 sg_read 3 25799 NULL
97778 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97779 +system_enable_read_25815 system_enable_read 3 25815 NULL
97780 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97781 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97782 +parport_read_25855 parport_read 0 25855 NULL
97783 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97784 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97785 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97786 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97787 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97788 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97789 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97790 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97791 +rcname_read_25919 rcname_read 3 25919 NULL
97792 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97793 +key_flags_read_25931 key_flags_read 3 25931 NULL
97794 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97795 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97796 +flush_25957 flush 2 25957 NULL
97797 +video_register_device_25971 video_register_device 3 25971 NULL
97798 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97799 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97800 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97801 +mirror_status_26010 mirror_status 5 26010 NULL
97802 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97803 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97804 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97805 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97806 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97807 +tun_do_read_26047 tun_do_read 5 26047 NULL
97808 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97809 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97810 +cpumask_next_26096 cpumask_next 1 26096 NULL
97811 +skb_cow_26138 skb_cow 2 26138 NULL
97812 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97813 +__fswab64_26155 __fswab64 0 26155 NULL
97814 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97815 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97816 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97817 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97818 +disk_devt_26180 disk_devt 0 26180 NULL
97819 +get_registers_26187 get_registers 3 26187 NULL
97820 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97821 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97822 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97823 +mce_write_26201 mce_write 3 26201 NULL
97824 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97825 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97826 +bio_split_26235 bio_split 2 26235 NULL
97827 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97828 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97829 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97830 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97831 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97832 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97833 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97834 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97835 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97836 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97837 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97838 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97839 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97840 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97841 +read_vmcore_26501 read_vmcore 3 26501 NULL
97842 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97843 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97844 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97845 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97846 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97847 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97848 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97849 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97850 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97851 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97852 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97853 +mmap_region_26649 mmap_region 0-2 26649 NULL
97854 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97855 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97856 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97857 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97858 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97859 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97860 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97861 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97862 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97863 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97864 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97865 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97866 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97867 +smk_write_load_26829 smk_write_load 3 26829 NULL
97868 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97869 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97870 +scnprint_id_26842 scnprint_id 3 26842 NULL
97871 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97872 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97873 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97874 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97875 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97876 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97877 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97878 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97879 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97880 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97881 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97882 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97883 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97884 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97885 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97886 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97887 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97888 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97889 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97890 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97891 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97892 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97893 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97894 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97895 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97896 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97897 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97898 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97899 +pms_capture_27142 pms_capture 4 27142 NULL
97900 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97901 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97902 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97903 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97904 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97905 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97906 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97907 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97908 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97909 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97910 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97911 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97912 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97913 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97914 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97915 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97916 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97917 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97918 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97919 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97920 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97921 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97922 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97923 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97924 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97925 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97926 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97927 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97928 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97929 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97930 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97931 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97932 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97933 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97934 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97935 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97936 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97937 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97938 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97939 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97940 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97941 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97942 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97943 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97944 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97945 +qword_get_27670 qword_get 0 27670 NULL
97946 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97947 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97948 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97949 +evm_write_key_27715 evm_write_key 3 27715 NULL
97950 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97951 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97952 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97953 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97954 +kcalloc_27770 kcalloc 1-2 27770 NULL
97955 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97956 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97957 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97958 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97959 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97960 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97961 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97962 +read_profile_27859 read_profile 3 27859 NULL
97963 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97964 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97965 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97966 +gluebi_write_27905 gluebi_write 3 27905 NULL
97967 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97968 +bm_find_next_27929 bm_find_next 2 27929 NULL
97969 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97970 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97971 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97972 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97973 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97974 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97975 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97976 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97977 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97978 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97979 +pool_status_28055 pool_status 5 28055 NULL
97980 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97981 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97982 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97983 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97984 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97985 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97986 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97987 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97988 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97989 +video_read_28148 video_read 3 28148 NULL
97990 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97991 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97992 +vread_28173 vread 0 28173 NULL
97993 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97994 +d_path_28198 d_path 0 28198 NULL
97995 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97996 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97997 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97998 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97999 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98000 +usemap_size_28281 usemap_size 0 28281 NULL
98001 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98002 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98003 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98004 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98005 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98006 +snapshot_write_28351 snapshot_write 3 28351 NULL
98007 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
98008 +sys_writev_28384 sys_writev 3 28384 NULL
98009 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98010 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98011 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98012 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98013 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98014 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98015 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98016 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98017 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98018 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98019 +max_response_pages_28492 max_response_pages 0 28492 NULL
98020 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98021 +__next_node_28521 __next_node 1 28521 NULL
98022 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98023 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
98024 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98025 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98026 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98027 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98028 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
98029 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98030 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98031 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98032 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98033 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
98034 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98035 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98036 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98037 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98038 +_set_range_28627 _set_range 3 28627 NULL
98039 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98040 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98041 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98042 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98043 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98044 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98045 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98046 +spi_execute_28736 spi_execute 5 28736 NULL
98047 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98048 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98049 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98050 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
98051 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98052 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98053 +sel_write_member_28800 sel_write_member 3 28800 NULL
98054 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98055 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
98056 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98057 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98058 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98059 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98060 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98061 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
98062 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98063 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98064 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98065 +push_rx_28939 push_rx 3 28939 NULL
98066 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98067 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98068 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98069 +bin_uuid_28999 bin_uuid 3 28999 NULL
98070 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98071 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98072 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98073 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98074 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98075 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98076 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
98077 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98078 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98079 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98080 +snprintf_29125 snprintf 0 29125 NULL
98081 +iov_shorten_29130 iov_shorten 0 29130 NULL
98082 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
98083 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98084 +reshape_ring_29147 reshape_ring 2 29147 NULL
98085 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98086 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98087 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98088 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98089 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98090 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
98091 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98092 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98093 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98094 +recover_peb_29238 recover_peb 6-7 29238 NULL
98095 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98096 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98097 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98098 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98099 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
98100 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98101 +tun_put_user_29337 tun_put_user 5 29337 NULL
98102 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98103 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98104 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98105 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98106 +mempool_create_29437 mempool_create 1 29437 NULL
98107 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98108 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98109 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98110 +do_register_entry_29478 do_register_entry 4 29478 NULL
98111 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98112 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98113 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98114 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98115 +ftrace_write_29551 ftrace_write 3 29551 NULL
98116 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98117 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98118 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98119 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98120 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98121 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
98122 +slots_per_page_29601 slots_per_page 0 29601 NULL
98123 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98124 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98125 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98126 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98127 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98128 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98129 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98130 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98131 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98132 +probes_write_29711 probes_write 3 29711 NULL
98133 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98134 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98135 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98136 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98137 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98138 +dbAlloc_29794 dbAlloc 0 29794 NULL
98139 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98140 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98141 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98142 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98143 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98144 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98145 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98146 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98147 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98148 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98149 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98150 +check586_29914 check586 2 29914 NULL
98151 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98152 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98153 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98154 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98155 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98156 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98157 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98158 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98159 +drp_wmove_30043 drp_wmove 4 30043 NULL
98160 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98161 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98162 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98163 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98164 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98165 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98166 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98167 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98168 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98169 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98170 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98171 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98172 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98173 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98174 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98175 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98176 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98177 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98178 +compat_readv_30273 compat_readv 3 30273 NULL
98179 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98180 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98181 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98182 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98183 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98184 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98185 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98186 +resource_from_user_30341 resource_from_user 3 30341 NULL
98187 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98188 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98189 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98190 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98191 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98192 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98193 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98194 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98195 +enable_write_30456 enable_write 3 30456 NULL
98196 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98197 +urandom_read_30462 urandom_read 3 30462 NULL
98198 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98199 +write_head_30481 write_head 4 30481 NULL
98200 +adu_write_30487 adu_write 3 30487 NULL
98201 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98202 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98203 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98204 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98205 +set_le_30581 set_le 4 30581 NULL
98206 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98207 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98208 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98209 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98210 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98211 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98212 +agp_remap_30665 agp_remap 2 30665 NULL
98213 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98214 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98215 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98216 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98217 +snapshot_status_30744 snapshot_status 5 30744 NULL
98218 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98219 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98220 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98221 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98222 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98223 +create_subvol_30836 create_subvol 4 30836 NULL
98224 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98225 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98226 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98227 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98228 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98229 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98230 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98231 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98232 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98233 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98234 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98235 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98236 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98237 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98238 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98239 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98240 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98241 +sys_mincore_31079 sys_mincore 1 31079 NULL
98242 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98243 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98244 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98245 +depth_read_31112 depth_read 3 31112 NULL
98246 +ssb_read16_31139 ssb_read16 0 31139 NULL
98247 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98248 +size_inside_page_31141 size_inside_page 0 31141 NULL
98249 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98250 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98251 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98252 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98253 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98254 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98255 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98256 +__read_reg_31216 __read_reg 0 31216 NULL
98257 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98258 +cyy_readb_31240 cyy_readb 0 31240 NULL
98259 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98260 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98261 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98262 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98263 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98264 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98265 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98266 +command_file_write_31318 command_file_write 3 31318 NULL
98267 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98268 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98269 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98270 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98271 +inb_31388 inb 0 31388 NULL
98272 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98273 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98274 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98275 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98276 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98277 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98278 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98279 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98280 +do_fcntl_31468 do_fcntl 3 31468 NULL
98281 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98282 +alg_setkey_31485 alg_setkey 3 31485 NULL
98283 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98284 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98285 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98286 +hidraw_write_31536 hidraw_write 3 31536 NULL
98287 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98288 +usbvision_read_31555 usbvision_read 3 31555 NULL
98289 +normalize_31566 normalize 0-1-2 31566 NULL
98290 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98291 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98292 +osst_write_31581 osst_write 3 31581 NULL
98293 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98294 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98295 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98296 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98297 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98298 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98299 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98300 +__lgread_31668 __lgread 4 31668 NULL
98301 +symbol_string_31670 symbol_string 0 31670 NULL
98302 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98303 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98304 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98305 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98306 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98307 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98308 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98309 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98310 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98311 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98312 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98313 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98314 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98315 +get_count_order_31800 get_count_order 0 31800 NULL
98316 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98317 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98318 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98319 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98320 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98321 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98322 +xattr_permission_31907 xattr_permission 0 31907 NULL
98323 +new_dir_31919 new_dir 3 31919 NULL
98324 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98325 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98326 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98327 +vb2_write_31948 vb2_write 3 31948 NULL
98328 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98329 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98330 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98331 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98332 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98333 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98334 +calc_hmac_32010 calc_hmac 3 32010 NULL
98335 +aead_len_32021 aead_len 0 32021 NULL
98336 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98337 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98338 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98339 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98340 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98341 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98342 +bio_alloc_32095 bio_alloc 2 32095 NULL
98343 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98344 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98345 +disk_status_32120 disk_status 4 32120 NULL
98346 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98347 +venus_link_32165 venus_link 5 32165 NULL
98348 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98349 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98350 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98351 +load_header_32183 load_header 0 32183 NULL
98352 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98353 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98354 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98355 +lm3533_write_32236 lm3533_write 2 32236 NULL
98356 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98357 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98358 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98359 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98360 +hex_string_32310 hex_string 0 32310 NULL
98361 +flakey_status_32315 flakey_status 5 32315 NULL
98362 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98363 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98364 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98365 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98366 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98367 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98368 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98369 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98370 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98371 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98372 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98373 +log_text_32428 log_text 0 32428 NULL
98374 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98375 +hid_input_report_32458 hid_input_report 4 32458 NULL
98376 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98377 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98378 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98379 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98380 +disconnect_32521 disconnect 4 32521 NULL
98381 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98382 +ilo_read_32531 ilo_read 3 32531 NULL
98383 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98384 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98385 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98386 +__first_node_32558 __first_node 0 32558 NULL
98387 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98388 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98389 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98390 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98391 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98392 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98393 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98394 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98395 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98396 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98397 +kvmalloc_32646 kvmalloc 1 32646 NULL
98398 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98399 +generic_readlink_32654 generic_readlink 3 32654 NULL
98400 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98401 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98402 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98403 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98404 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98405 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98406 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98407 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98408 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98409 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98410 +vga_rseq_32848 vga_rseq 0 32848 NULL
98411 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98412 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98413 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98414 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98415 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98416 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98417 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98418 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98419 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98420 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98421 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98422 +compat_filldir_32999 compat_filldir 3 32999 NULL
98423 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98424 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98425 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98426 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98427 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98428 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98429 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98430 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98431 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98432 +write_node_33121 write_node 4 33121 NULL
98433 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98434 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98435 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98436 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98437 +pp_read_33210 pp_read 3 33210 NULL
98438 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98439 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98440 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98441 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98442 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98443 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98444 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98445 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98446 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98447 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98448 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98449 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98450 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98451 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98452 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98453 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98454 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98455 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98456 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98457 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98458 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98459 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98460 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98461 +create_entry_33479 create_entry 2 33479 NULL
98462 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98463 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98464 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98465 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98466 +res_counter_read_33499 res_counter_read 4 33499 NULL
98467 +fb_read_33506 fb_read 3 33506 NULL
98468 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98469 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98470 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98471 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98472 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98473 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98474 +dup_array_33551 dup_array 3 33551 NULL
98475 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98476 +count_subheaders_33591 count_subheaders 0 33591 NULL
98477 +scsi_execute_33596 scsi_execute 5 33596 NULL
98478 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98479 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98480 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98481 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98482 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98483 +inw_p_33668 inw_p 0 33668 NULL
98484 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98485 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98486 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98487 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98488 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98489 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98490 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98491 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98492 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98493 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98494 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98495 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98496 +Read_hfc_33755 Read_hfc 0 33755 NULL
98497 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98498 +hashtab_create_33769 hashtab_create 3 33769 NULL
98499 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98500 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98501 +find_next_offset_33804 find_next_offset 3 33804 NULL
98502 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98503 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98504 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98505 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98506 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98507 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98508 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98509 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98510 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98511 +config_proc_write_33878 config_proc_write 3 33878 NULL
98512 +get_user_pages_33908 get_user_pages 0 33908 NULL
98513 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98514 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98515 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98516 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98517 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98518 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98519 +ppp_write_34034 ppp_write 3 34034 NULL
98520 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98521 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98522 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98523 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98524 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98525 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98526 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98527 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98528 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98529 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98530 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98531 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98532 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98533 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98534 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98535 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98536 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98537 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98538 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98539 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98540 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98541 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98542 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98543 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98544 +ea_read_34378 ea_read 0 34378 NULL
98545 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98546 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98547 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98548 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98549 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98550 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98551 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98552 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98553 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98554 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98555 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98556 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98557 +alloc_buf_34532 alloc_buf 1 34532 NULL
98558 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98559 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98560 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98561 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98562 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98563 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98564 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98565 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98566 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98567 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98568 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98569 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98570 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98571 +port_print_34704 port_print 3 34704 NULL
98572 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98573 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98574 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98575 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98576 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98577 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98578 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98579 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98580 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98581 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98582 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98583 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98584 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98585 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98586 +msg_print_text_34889 msg_print_text 0 34889 NULL
98587 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98588 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98589 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98590 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98591 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98592 +Realloc_34961 Realloc 2 34961 NULL
98593 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98594 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98595 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98596 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98597 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98598 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98599 +store_ifalias_35088 store_ifalias 4 35088 NULL
98600 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98601 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98602 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98603 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98604 +pointer_35138 pointer 0 35138 NULL
98605 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98606 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98607 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98608 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98609 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98610 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98611 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98612 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98613 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98614 +set_fd_set_35249 set_fd_set 1 35249 NULL
98615 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98616 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98617 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98618 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98619 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98620 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98621 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98622 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98623 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98624 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98625 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98626 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98627 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98628 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98629 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98630 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98631 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98632 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98633 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98634 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98635 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98636 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98637 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98638 +async_setkey_35521 async_setkey 3 35521 NULL
98639 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98640 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98641 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98642 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98643 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98644 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98645 +ReadZReg_35604 ReadZReg 0 35604 NULL
98646 +kernel_readv_35617 kernel_readv 3 35617 NULL
98647 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98648 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98649 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98650 +store_debug_level_35652 store_debug_level 3 35652 NULL
98651 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98652 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98653 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98654 +dm_table_create_35687 dm_table_create 3 35687 NULL
98655 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98656 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98657 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98658 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98659 +read_file_stations_35795 read_file_stations 3 35795 NULL
98660 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98661 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98662 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98663 +fls64_35862 fls64 0 35862 NULL
98664 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98665 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98666 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98667 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98668 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98669 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98670 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98671 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98672 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98673 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98674 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98675 +acl_alloc_35979 acl_alloc 1 35979 NULL
98676 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98677 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98678 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98679 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98680 +sys_init_module_36047 sys_init_module 2 36047 NULL
98681 +account_shadowed_36048 account_shadowed 2 36048 NULL
98682 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98683 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98684 +write_emulate_36065 write_emulate 2-4 36065 NULL
98685 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98686 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98687 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98688 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98689 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98690 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98691 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98692 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98693 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98694 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98695 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98696 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98697 +twl_set_36154 twl_set 2 36154 NULL
98698 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98699 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98700 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98701 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98702 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98703 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98704 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98705 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98706 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98707 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98708 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98709 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98710 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98711 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98712 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98713 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98714 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98715 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98716 +lc_create_36332 lc_create 4 36332 NULL
98717 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98718 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98719 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98720 +to_sector_36361 to_sector 0-1 36361 NULL
98721 +tunables_read_36385 tunables_read 3 36385 NULL
98722 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98723 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98724 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98725 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98726 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98727 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98728 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98729 +get_param_l_36518 get_param_l 0 36518 NULL
98730 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98731 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98732 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98733 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98734 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98735 +get_entry_len_36549 get_entry_len 0 36549 NULL
98736 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98737 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98738 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98739 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98740 +__erst_read_36579 __erst_read 0 36579 NULL
98741 +put_cmsg_36589 put_cmsg 4 36589 NULL
98742 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98743 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98744 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98745 +format_decode_36638 format_decode 0 36638 NULL
98746 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98747 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98748 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98749 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98750 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98751 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98752 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98753 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98754 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98755 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98756 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98757 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98758 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98759 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98760 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98761 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98762 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98763 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98764 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98765 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98766 +cm_write_36858 cm_write 3 36858 NULL
98767 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98768 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98769 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98770 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98771 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98772 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98773 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98774 +div_u64_36951 div_u64 0 36951 NULL
98775 +write_leb_36957 write_leb 5 36957 NULL
98776 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98777 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98778 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98779 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98780 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98781 +setxattr_37006 setxattr 4 37006 NULL
98782 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98783 +parse_command_37079 parse_command 2 37079 NULL
98784 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98785 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98786 +tun_get_user_37094 tun_get_user 5 37094 NULL
98787 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98788 +msg_word_37164 msg_word 0 37164 NULL
98789 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98790 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98791 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98792 +__do_replace_37227 __do_replace 5 37227 NULL
98793 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98794 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98795 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98796 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98797 +c101_run_37279 c101_run 2 37279 NULL
98798 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98799 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98800 +send_msg_37323 send_msg 4 37323 NULL
98801 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98802 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98803 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98804 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98805 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98806 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98807 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98808 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98809 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98810 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98811 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98812 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98813 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98814 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98815 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98816 +get_est_timing_37484 get_est_timing 0 37484 NULL
98817 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98818 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98819 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98820 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98821 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98822 +hdr_size_37536 hdr_size 0 37536 NULL
98823 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98824 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98825 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98826 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98827 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98828 +alloc_fd_37637 alloc_fd 1 37637 NULL
98829 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98830 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98831 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98832 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98833 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98834 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98835 +nametbl_header_37698 nametbl_header 2 37698 NULL
98836 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98837 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98838 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98839 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98840 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98841 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98842 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98843 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98844 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98845 +deny_write_access_37813 deny_write_access 0 37813 NULL
98846 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98847 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98848 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98849 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98850 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98851 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98852 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98853 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98854 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98855 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98856 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98857 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98858 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98859 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98860 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98861 +vfs_readv_38011 vfs_readv 3 38011 NULL
98862 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98863 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98864 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98865 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98866 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98867 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98868 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98869 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98870 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98871 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98872 +ep0_read_38095 ep0_read 3 38095 NULL
98873 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98874 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98875 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98876 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98877 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98878 +cdev_add_38176 cdev_add 2-3 38176 NULL
98879 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98880 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98881 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98882 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98883 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98884 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98885 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98886 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98887 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98888 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98889 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98890 +verity_status_38273 verity_status 5 38273 NULL
98891 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98892 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98893 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98894 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98895 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98896 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98897 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98898 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98899 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98900 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98901 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98902 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98903 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98904 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98905 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98906 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98907 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98908 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98909 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98910 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98911 +dev_names_read_38509 dev_names_read 3 38509 NULL
98912 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98913 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98914 +set_queue_count_38519 set_queue_count 0 38519 NULL
98915 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98916 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98917 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98918 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98919 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98920 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98921 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98922 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98923 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98924 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98925 +delay_status_38606 delay_status 5 38606 NULL
98926 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98927 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98928 +cma_create_area_38642 cma_create_area 2 38642 NULL
98929 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98930 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98931 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98932 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98933 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98934 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98935 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98936 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98937 +udf_readpages_38761 udf_readpages 4 38761 NULL
98938 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98939 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98940 +err_decode_38804 err_decode 2 38804 NULL
98941 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98942 +sys_select_38827 sys_select 1 38827 NULL
98943 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98944 +direct_entry_38836 direct_entry 3 38836 NULL
98945 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98946 +interfaces_38859 interfaces 2 38859 NULL
98947 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98948 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98949 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98950 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98951 +__fswab16_38898 __fswab16 0 38898 NULL
98952 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98953 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98954 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98955 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98956 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98957 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98958 +udf_new_block_38999 udf_new_block 4 38999 NULL
98959 +get_nodes_39012 get_nodes 3 39012 NULL
98960 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98961 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98962 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98963 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98964 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98965 +tun_get_user_39099 tun_get_user 4 39099 NULL
98966 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98967 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98968 +ea_foreach_39133 ea_foreach 0 39133 NULL
98969 +generic_permission_39150 generic_permission 0 39150 NULL
98970 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98971 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98972 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98973 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98974 +init_list_set_39188 init_list_set 2-3 39188 NULL
98975 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98976 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98977 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98978 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98979 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98980 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98981 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98982 +drm_order_39244 drm_order 0 39244 NULL
98983 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98984 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98985 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98986 +__skb_cow_39254 __skb_cow 2 39254 NULL
98987 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98988 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98989 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98990 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98991 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98992 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98993 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98994 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98995 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98996 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98997 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98998 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98999 +__send_to_port_39386 __send_to_port 3 39386 NULL
99000 +user_power_read_39414 user_power_read 3 39414 NULL
99001 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99002 +sys_semop_39457 sys_semop 3 39457 NULL
99003 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99004 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99005 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99006 +int_proc_write_39542 int_proc_write 3 39542 NULL
99007 +pp_write_39554 pp_write 3 39554 NULL
99008 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99009 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99010 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99011 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99012 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
99013 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99014 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99015 +ext_depth_39607 ext_depth 0 39607 NULL
99016 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99017 +sdio_readb_39618 sdio_readb 0 39618 NULL
99018 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99019 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99020 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99021 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99022 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99023 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99024 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99025 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99026 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99027 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99028 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99029 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99030 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99031 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99032 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99033 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99034 +pkt_add_39897 pkt_add 3 39897 NULL
99035 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99036 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99037 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99038 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99039 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99040 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99041 +__spi_async_39932 __spi_async 0 39932 NULL
99042 +__get_order_39935 __get_order 0 39935 NULL
99043 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99044 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99045 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99046 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99047 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99048 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99049 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99050 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99051 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99052 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99053 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99054 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99055 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99056 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99057 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99058 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
99059 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99060 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
99061 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99062 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99063 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99064 +pt_write_40159 pt_write 3 40159 NULL
99065 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99066 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99067 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99068 +allocate_probes_40204 allocate_probes 1 40204 NULL
99069 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
99070 +compat_put_long_40214 compat_put_long 1 40214 NULL
99071 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99072 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
99073 +osst_read_40237 osst_read 3 40237 NULL
99074 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99075 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99076 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99077 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99078 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99079 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99080 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99081 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99082 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99083 +mmio_read_40348 mmio_read 4 40348 NULL
99084 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99085 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99086 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99087 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99088 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99089 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99090 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99091 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99092 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99093 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99094 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99095 +tty_write_room_40495 tty_write_room 0 40495 NULL
99096 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99097 +sg_phys_40507 sg_phys 0 40507 NULL
99098 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99099 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99100 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99101 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99102 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99103 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
99104 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99105 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99106 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99107 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99108 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99109 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99110 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99111 +fops_read_40672 fops_read 3 40672 NULL
99112 +tps80031_write_40678 tps80031_write 3 40678 NULL
99113 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99114 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99115 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99116 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99117 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
99118 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99119 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99120 +card_send_command_40757 card_send_command 3 40757 NULL
99121 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99122 +pg_write_40766 pg_write 3 40766 NULL
99123 +show_list_40775 show_list 3 40775 NULL
99124 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99125 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99126 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99127 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99128 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99129 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99130 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99131 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99132 +read_file_queue_40895 read_file_queue 3 40895 NULL
99133 +waiters_read_40902 waiters_read 3 40902 NULL
99134 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99135 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99136 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99137 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99138 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99139 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99140 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99141 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99142 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99143 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99144 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99145 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99146 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99147 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99148 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99149 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99150 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99151 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99152 +dma_attach_41094 dma_attach 5-6 41094 NULL
99153 +provide_user_output_41105 provide_user_output 3 41105 NULL
99154 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99155 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99156 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99157 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99158 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99159 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99160 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99161 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99162 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99163 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99164 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99165 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99166 +erst_read_41260 erst_read 0 41260 NULL
99167 +__fprog_create_41263 __fprog_create 2 41263 NULL
99168 +alloc_context_41283 alloc_context 1 41283 NULL
99169 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99170 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99171 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99172 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99173 +kmp_init_41373 kmp_init 2 41373 NULL
99174 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99175 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99176 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99177 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99178 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99179 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99180 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99181 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99182 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99183 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99184 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99185 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99186 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99187 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99188 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99189 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99190 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99191 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99192 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99193 +gserial_setup_41558 gserial_setup 2 41558 NULL
99194 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99195 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99196 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99197 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99198 +vga_io_r_41609 vga_io_r 0 41609 NULL
99199 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99200 +a2mp_send_41615 a2mp_send 4 41615 NULL
99201 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99202 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99203 +get_std_timing_41654 get_std_timing 0 41654 NULL
99204 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99205 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99206 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99207 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99208 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99209 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99210 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99211 +fillonedir_41746 fillonedir 3 41746 NULL
99212 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99213 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99214 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99215 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99216 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99217 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99218 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99219 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99220 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99221 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99222 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99223 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99224 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99225 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99226 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99227 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99228 +portnames_read_41958 portnames_read 3 41958 NULL
99229 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99230 +dst_mtu_41969 dst_mtu 0 41969 NULL
99231 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99232 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99233 +lguest_map_42008 lguest_map 1-2 42008 NULL
99234 +pool_allocate_42012 pool_allocate 3 42012 NULL
99235 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99236 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99237 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99238 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99239 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99240 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99241 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99242 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99243 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99244 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99245 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99246 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99247 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99248 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99249 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99250 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99251 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99252 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99253 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99254 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99255 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99256 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99257 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99258 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99259 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99260 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99261 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99262 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99263 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99264 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99265 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99266 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99267 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99268 +krng_get_random_42420 krng_get_random 3 42420 NULL
99269 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99270 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99271 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99272 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99273 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99274 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99275 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99276 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99277 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99278 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99279 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99280 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99281 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99282 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99283 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99284 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99285 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99286 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99287 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99288 +map_state_42602 map_state 1 42602 NULL nohasharray
99289 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99290 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99291 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99292 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99293 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99294 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99295 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99296 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99297 +vb2_read_42703 vb2_read 3 42703 NULL
99298 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99299 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99300 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99301 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99302 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99303 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99304 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99305 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99306 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99307 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99308 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99309 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99310 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99311 +set_arg_42824 set_arg 3 42824 NULL
99312 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99313 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99314 +prandom_u32_42853 prandom_u32 0 42853 NULL
99315 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99316 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99317 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99318 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99319 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99320 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99321 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99322 +hd_end_request_42904 hd_end_request 2 42904 NULL
99323 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99324 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99325 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99326 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99327 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99328 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99329 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99330 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99331 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99332 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99333 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99334 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99335 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99336 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99337 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99338 +uuid_string_43154 uuid_string 0 43154 NULL
99339 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99340 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99341 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99342 +process_measurement_43190 process_measurement 0 43190 NULL
99343 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99344 +uio_write_43202 uio_write 3 43202 NULL
99345 +iso_callback_43208 iso_callback 3 43208 NULL
99346 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99347 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99348 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99349 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99350 +fixup_leb_43256 fixup_leb 3 43256 NULL
99351 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99352 +evtchn_write_43278 evtchn_write 3 43278 NULL
99353 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99354 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99355 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99356 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99357 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99358 +xenfb_write_43412 xenfb_write 3 43412 NULL
99359 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99360 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99361 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99362 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99363 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99364 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99365 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99366 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99367 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99368 +do_readlink_43518 do_readlink 2 43518 NULL
99369 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99370 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99371 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99372 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99373 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99374 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99375 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99376 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99377 +proc_read_43614 proc_read 3 43614 NULL
99378 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99379 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99380 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99381 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99382 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99383 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99384 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99385 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99386 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99387 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99388 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99389 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99390 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99391 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99392 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99393 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99394 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99395 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99396 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99397 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99398 +read_flush_43851 read_flush 3 43851 NULL
99399 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99400 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99401 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99402 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99403 +SendString_43928 SendString 3 43928 NULL
99404 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99405 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99406 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99407 +nla_reserve_43984 nla_reserve 3 43984 NULL
99408 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99409 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99410 +emit_flags_44006 emit_flags 4-3 44006 NULL
99411 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99412 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99413 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99414 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99415 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99416 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99417 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99418 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99419 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99420 +__set_free_44211 __set_free 2 44211 NULL
99421 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99422 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99423 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99424 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99425 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99426 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99427 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99428 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99429 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99430 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99431 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99432 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99433 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99434 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99435 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99436 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99437 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99438 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99439 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99440 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99441 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99442 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99443 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99444 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99445 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99446 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99447 +spidev_write_44510 spidev_write 3 44510 NULL
99448 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99449 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99450 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99451 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99452 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99453 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99454 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99455 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99456 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99457 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99458 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99459 +mpi_resize_44674 mpi_resize 2 44674 NULL
99460 +ts_read_44687 ts_read 3 44687 NULL
99461 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99462 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99463 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99464 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99465 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99466 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99467 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99468 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99469 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99470 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99471 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99472 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99473 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99474 +sisusb_write_44834 sisusb_write 3 44834 NULL
99475 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99476 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99477 +skb_availroom_44883 skb_availroom 0 44883 NULL
99478 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99479 +do_tty_write_44896 do_tty_write 5 44896 NULL
99480 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99481 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99482 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99483 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99484 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99485 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99486 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99487 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99488 +sel_write_user_45060 sel_write_user 3 45060 NULL
99489 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99490 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99491 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99492 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99493 +usbdev_read_45114 usbdev_read 3 45114 NULL
99494 +send_to_tty_45141 send_to_tty 3 45141 NULL
99495 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99496 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99497 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99498 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99499 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99500 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99501 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99502 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99503 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99504 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99505 +add_child_45201 add_child 4 45201 NULL
99506 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99507 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99508 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99509 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99510 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99511 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99512 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99513 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99514 +keymap_store_45406 keymap_store 4 45406 NULL
99515 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99516 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99517 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99518 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99519 +__node_remap_45458 __node_remap 4 45458 NULL
99520 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99521 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99522 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99523 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99524 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99525 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99526 +clone_bio_45516 clone_bio 6 45516 NULL
99527 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99528 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99529 +copy_macs_45534 copy_macs 4 45534 NULL
99530 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99531 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99532 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99533 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99534 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99535 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99536 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99537 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99538 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99539 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99540 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99541 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99542 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99543 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99544 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99545 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99546 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99547 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99548 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99549 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99550 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99551 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99552 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99553 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99554 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99555 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99556 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99557 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99558 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99559 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99560 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99561 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99562 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99563 +amthi_read_45831 amthi_read 4 45831 NULL
99564 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99565 +isdn_write_45863 isdn_write 3 45863 NULL
99566 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99567 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99568 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99569 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99570 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99571 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99572 +alloc_mr_45935 alloc_mr 1 45935 NULL
99573 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99574 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99575 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99576 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99577 +get_free_entries_46030 get_free_entries 1 46030 NULL
99578 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99579 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99580 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99581 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99582 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99583 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99584 +slhc_toss_46066 slhc_toss 0 46066 NULL
99585 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99586 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99587 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99588 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99589 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99590 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99591 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99592 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99593 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99594 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99595 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99596 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99597 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99598 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99599 +dsp_write_46218 dsp_write 2 46218 NULL
99600 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99601 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99602 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99603 +ReadReg_46277 ReadReg 0 46277 NULL
99604 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99605 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99606 +twl6040_write_46351 twl6040_write 2 46351 NULL
99607 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99608 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99609 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99610 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99611 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99612 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99613 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99614 +filldir64_46469 filldir64 3 46469 NULL
99615 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99616 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99617 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99618 +kmsg_read_46514 kmsg_read 3 46514 NULL
99619 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99620 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99621 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99622 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99623 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99624 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99625 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99626 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99627 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99628 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99629 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99630 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99631 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99632 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99633 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99634 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99635 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99636 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99637 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99638 +prepare_copy_46725 prepare_copy 2 46725 NULL
99639 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99640 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99641 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99642 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99643 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99644 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99645 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99646 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99647 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99648 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99649 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99650 +spi_async_46857 spi_async 0 46857 NULL
99651 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99652 +vsnprintf_46863 vsnprintf 0 46863 NULL
99653 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99654 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99655 +rvmalloc_46873 rvmalloc 1 46873 NULL
99656 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99657 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99658 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99659 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99660 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99661 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99662 +fb_write_46924 fb_write 3 46924 NULL
99663 +raid_status_46930 raid_status 5 46930 NULL
99664 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99665 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99666 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99667 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99668 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99669 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99670 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99671 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99672 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99673 +__map_single_47020 __map_single 3-4-7 47020 NULL
99674 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99675 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99676 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99677 +fs_path_len_47060 fs_path_len 0 47060 NULL
99678 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99679 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99680 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99681 +mousedev_read_47123 mousedev_read 3 47123 NULL
99682 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99683 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99684 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99685 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99686 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99687 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99688 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99689 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99690 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99691 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99692 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99693 +l2headersize_47238 l2headersize 0 47238 NULL
99694 +options_write_47243 options_write 3 47243 NULL
99695 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99696 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99697 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99698 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99699 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99700 +vsnprintf_47291 vsnprintf 0 47291 NULL
99701 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99702 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99703 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99704 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99705 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99706 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99707 +nametbl_list_47391 nametbl_list 2 47391 NULL
99708 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99709 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99710 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99711 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99712 +vzalloc_47421 vzalloc 1 47421 NULL
99713 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99714 +newpart_47485 newpart 6 47485 NULL
99715 +core_sys_select_47494 core_sys_select 1 47494 NULL
99716 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99717 +unlink_simple_47506 unlink_simple 3 47506 NULL
99718 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99719 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99720 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99721 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99722 +oz_events_read_47535 oz_events_read 3 47535 NULL
99723 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99724 +cycx_setup_47562 cycx_setup 4 47562 NULL
99725 +read_ldt_47570 read_ldt 2 47570 NULL
99726 +pci_iomap_47575 pci_iomap 3 47575 NULL
99727 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99728 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99729 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99730 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99731 +uea_request_47613 uea_request 4 47613 NULL
99732 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99733 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99734 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99735 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99736 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99737 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99738 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99739 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99740 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99741 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99742 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99743 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99744 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99745 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99746 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99747 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99748 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99749 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99750 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99751 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99752 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99753 +vhci_read_47878 vhci_read 3 47878 NULL
99754 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99755 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99756 +timeout_read_47915 timeout_read 3 47915 NULL
99757 +comedi_write_47926 comedi_write 3 47926 NULL
99758 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99759 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99760 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99761 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99762 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99763 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99764 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99765 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99766 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99767 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99768 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99769 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99770 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99771 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99772 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99773 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99774 +set_discoverable_48141 set_discoverable 4 48141 NULL
99775 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99776 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99777 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99778 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99779 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99780 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99781 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99782 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99783 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99784 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99785 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99786 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99787 +read_file_recv_48232 read_file_recv 3 48232 NULL
99788 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99789 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99790 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99791 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99792 +send_set_info_48288 send_set_info 7 48288 NULL
99793 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99794 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99795 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99796 +hash_setkey_48310 hash_setkey 3 48310 NULL
99797 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99798 +skb_add_data_48363 skb_add_data 3 48363 NULL
99799 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99800 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99801 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99802 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99803 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99804 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99805 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99806 +send_control_msg_48498 send_control_msg 6 48498 NULL
99807 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99808 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99809 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99810 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99811 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99812 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99813 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99814 +named_distribute_48544 named_distribute 4 48544 NULL
99815 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99816 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99817 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99818 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99819 +mtd_read_48655 mtd_read 0 48655 NULL
99820 +lc_create_48662 lc_create 3 48662 NULL
99821 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99822 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99823 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99824 +altera_drscan_48698 altera_drscan 2 48698 NULL
99825 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99826 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99827 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99828 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99829 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99830 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99831 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99832 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99833 +azx_get_position_48841 azx_get_position 0 48841 NULL
99834 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99835 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99836 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99837 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99838 +get_num_ops_48886 get_num_ops 0 48886 NULL
99839 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99840 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99841 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99842 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99843 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99844 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99845 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99846 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99847 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99848 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99849 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99850 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99851 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99852 +xd_rw_49020 xd_rw 3-4 49020 NULL
99853 +transient_status_49027 transient_status 4 49027 NULL
99854 +ubi_read_49061 ubi_read 0 49061 NULL
99855 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99856 +calc_layout_49074 calc_layout 4 49074 NULL
99857 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99858 +scsi_register_49094 scsi_register 2 49094 NULL
99859 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99860 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99861 +pt_read_49136 pt_read 3 49136 NULL
99862 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99863 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99864 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99865 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99866 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99867 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99868 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99869 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99870 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99871 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99872 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99873 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99874 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99875 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99876 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99877 +uio_read_49300 uio_read 3 49300 NULL
99878 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99879 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99880 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99881 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99882 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99883 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99884 +px_raw_event_49371 px_raw_event 4 49371 NULL
99885 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99886 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99887 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99888 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99889 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99890 +md_domain_init_49432 md_domain_init 2 49432 NULL
99891 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99892 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99893 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99894 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99895 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99896 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99897 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99898 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99899 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99900 +smk_write_access_49561 smk_write_access 3 49561 NULL
99901 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99902 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99903 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99904 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99905 +heap_init_49617 heap_init 2 49617 NULL
99906 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99907 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99908 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99909 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99910 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99911 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99912 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99913 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99914 +check_frame_49741 check_frame 0 49741 NULL
99915 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99916 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99917 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99918 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99919 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99920 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99921 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99922 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99923 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99924 +add_uuid_49831 add_uuid 4 49831 NULL
99925 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99926 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99927 +twl4030_write_49846 twl4030_write 2 49846 NULL
99928 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99929 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99930 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99931 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99932 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99933 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99934 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99935 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99936 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99937 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99938 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99939 +__module_alloc_50004 __module_alloc 1 50004 NULL
99940 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99941 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99942 +isdn_read_50021 isdn_read 3 50021 NULL
99943 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99944 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99945 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99946 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99947 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99948 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99949 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99950 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99951 +read_file_slot_50111 read_file_slot 3 50111 NULL
99952 +copy_items_50140 copy_items 6 50140 NULL
99953 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99954 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99955 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99956 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99957 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99958 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99959 +odev_update_50169 odev_update 2 50169 NULL
99960 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99961 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99962 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99963 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99964 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99965 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99966 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99967 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99968 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99969 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99970 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99971 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99972 +do_launder_page_50329 do_launder_page 0 50329 NULL
99973 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99974 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99975 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99976 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99977 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99978 +tpm_read_50344 tpm_read 3 50344 NULL
99979 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99980 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99981 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99982 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99983 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99984 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99985 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99986 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99987 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99988 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99989 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99990 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99991 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99992 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99993 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99994 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99995 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99996 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99997 +fat_readpages_50582 fat_readpages 4 50582 NULL
99998 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99999 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100000 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100001 +__ffs_50625 __ffs 0 50625 NULL
100002 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100003 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100004 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100005 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100006 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100007 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100008 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100009 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100010 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100011 +skb_padto_50759 skb_padto 2 50759 NULL
100012 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100013 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100014 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100015 +tpm_write_50798 tpm_write 3 50798 NULL
100016 +tun_do_read_50800 tun_do_read 4 50800 NULL
100017 +write_flush_50803 write_flush 3 50803 NULL
100018 +dvb_play_50814 dvb_play 3 50814 NULL
100019 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100020 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100021 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
100022 +dma_attach_50831 dma_attach 6-7 50831 NULL
100023 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100024 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100025 +self_check_write_50856 self_check_write 5 50856 NULL
100026 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100027 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100028 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100029 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100030 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100031 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100032 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100033 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
100034 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100035 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100036 +timeout_write_50991 timeout_write 3 50991 NULL
100037 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
100038 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
100039 +proc_write_51003 proc_write 3 51003 NULL
100040 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100041 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100042 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100043 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100044 +dump_midi_51040 dump_midi 3 51040 NULL
100045 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100046 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100047 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100048 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100049 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100050 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100051 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
100052 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100053 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100054 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100055 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100056 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100057 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
100058 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100059 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100060 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100061 +tipc_send_51238 tipc_send 4 51238 NULL
100062 +drm_property_create_51239 drm_property_create 4 51239 NULL
100063 +st_read_51251 st_read 3 51251 NULL
100064 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100065 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100066 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100067 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100068 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100069 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
100070 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100071 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100072 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100073 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100074 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100075 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100076 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100077 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100078 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100079 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100080 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100081 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100082 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100083 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100084 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100085 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100086 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100087 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100088 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100089 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100090 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100091 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100092 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100093 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100094 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100095 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100096 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100097 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100098 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100099 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100100 +sel_write_access_51704 sel_write_access 3 51704 NULL
100101 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100102 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100103 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100104 +msg_set_51725 msg_set 3 51725 NULL
100105 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
100106 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100107 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
100108 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100109 +if_write_51756 if_write 3 51756 NULL
100110 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100111 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100112 +__fswab32_51781 __fswab32 0 51781 NULL
100113 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100114 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100115 +wm2000_write_51834 wm2000_write 2 51834 NULL
100116 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100117 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100118 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100119 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100120 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100121 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100122 +user_read_51881 user_read 3 51881 NULL
100123 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100124 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100125 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100126 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100127 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100128 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100129 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100130 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100131 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100132 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100133 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100134 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100135 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100136 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100137 +rdmalt_52022 rdmalt 0 52022 NULL
100138 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100139 +override_release_52032 override_release 2 52032 NULL
100140 +end_port_52042 end_port 0 52042 NULL
100141 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100142 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100143 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100144 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100145 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100146 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100147 +retry_count_read_52129 retry_count_read 3 52129 NULL
100148 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100149 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100150 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100151 +htable_size_52148 htable_size 0-1 52148 NULL
100152 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100153 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100154 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100155 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100156 +print_prefix_52176 print_prefix 0 52176 NULL
100157 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100158 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100159 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100160 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100161 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100162 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100163 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100164 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100165 +read_file_reset_52310 read_file_reset 3 52310 NULL
100166 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100167 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100168 +hwflags_read_52318 hwflags_read 3 52318 NULL
100169 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100170 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100171 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100172 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100173 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100174 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100175 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100176 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100177 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100178 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100179 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100180 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100181 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100182 +delay_status_52431 delay_status 5 52431 NULL
100183 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100184 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100185 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100186 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100187 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100188 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100189 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100190 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100191 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100192 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100193 +emit_code_52583 emit_code 0-3 52583 NULL
100194 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100195 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100196 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100197 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100198 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100199 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100200 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100201 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100202 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100203 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100204 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100205 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100206 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100207 +twlreg_write_52880 twlreg_write 3 52880 NULL
100208 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100209 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100210 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100211 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100212 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100213 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100214 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100215 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100216 +send_packet_52960 send_packet 4 52960 NULL
100217 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100218 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100219 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100220 +num_node_state_52989 num_node_state 0 52989 NULL
100221 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100222 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100223 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100224 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100225 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100226 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100227 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100228 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100229 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100230 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100231 +verity_status_53120 verity_status 5 53120 NULL
100232 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100233 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100234 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100235 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100236 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100237 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100238 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100239 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100240 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100241 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100242 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100243 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100244 +vm_mmap_53339 vm_mmap 0 53339 NULL
100245 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100246 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100247 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100248 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100249 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100250 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100251 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100252 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100253 +n2_run_53459 n2_run 3 53459 NULL
100254 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100255 +wm831x_write_53469 wm831x_write 2 53469 NULL
100256 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100257 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100258 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100259 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100260 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100261 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100262 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100263 +check_acl_53512 check_acl 0 53512 NULL
100264 +set_registers_53582 set_registers 3 53582 NULL
100265 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100266 +__readw_53594 __readw 0 53594 NULL
100267 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100268 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100269 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100270 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100271 +_preload_range_53676 _preload_range 2-3 53676 NULL
100272 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100273 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100274 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100275 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100276 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100277 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100278 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100279 +wdm_write_53735 wdm_write 3 53735 NULL
100280 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100281 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100282 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100283 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100284 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100285 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100286 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100287 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100288 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100289 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100290 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100291 +pms_read_53873 pms_read 3 53873 NULL
100292 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100293 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100294 +proc_file_read_53905 proc_file_read 3 53905 NULL
100295 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100296 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100297 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100298 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100299 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100300 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100301 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100302 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100303 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100304 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100305 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100306 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100307 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100308 +_malloc_54077 _malloc 1 54077 NULL
100309 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100310 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100311 +create_xattr_54106 create_xattr 5 54106 NULL
100312 +strn_len_54122 strn_len 0 54122 NULL
100313 +isku_receive_54130 isku_receive 4 54130 NULL
100314 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100315 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100316 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100317 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100318 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100319 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100320 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100321 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100322 +reada_add_block_54247 reada_add_block 2 54247 NULL
100323 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100324 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100325 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100326 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100327 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100328 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100329 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100330 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100331 +sprintf_54306 sprintf 0 54306 NULL
100332 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100333 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100334 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100335 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100336 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100337 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100338 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100339 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100340 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100341 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100342 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100343 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100344 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100345 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100346 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100347 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100348 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100349 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100350 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100351 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100352 +viacam_read_54526 viacam_read 3 54526 NULL
100353 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100354 +setsockopt_54539 setsockopt 5 54539 NULL
100355 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100356 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100357 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100358 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100359 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100360 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100361 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100362 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100363 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100364 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100365 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100366 +evm_read_key_54674 evm_read_key 3 54674 NULL
100367 +resource_string_54699 resource_string 0 54699 NULL
100368 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100369 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100370 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100371 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100372 +kzalloc_54740 kzalloc 1 54740 NULL
100373 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100374 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100375 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100376 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100377 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100378 +domain_init_54797 domain_init 2 54797 NULL
100379 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100380 +nfsd_write_54809 nfsd_write 6 54809 NULL
100381 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100382 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100383 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100384 +write_rio_54837 write_rio 3 54837 NULL
100385 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100386 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100387 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100388 +printer_read_54851 printer_read 3 54851 NULL
100389 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100390 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100391 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100392 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100393 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100394 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100395 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100396 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100397 +add_port_54941 add_port 2 54941 NULL
100398 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100399 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100400 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100401 +c4_add_card_54968 c4_add_card 3 54968 NULL
100402 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100403 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100404 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100405 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100406 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100407 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100408 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100409 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100410 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100411 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100412 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100413 +corrupt_data_55120 corrupt_data 0 55120 NULL
100414 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100415 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100416 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100417 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100418 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100419 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100420 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100421 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100422 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100423 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100424 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100425 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100426 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100427 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100428 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100429 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100430 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100431 +ptrace_request_55288 ptrace_request 3 55288 NULL
100432 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100433 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100434 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100435 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100436 +vme_user_read_55338 vme_user_read 3 55338 NULL
100437 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100438 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100439 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100440 +__send_to_port_55383 __send_to_port 3 55383 NULL
100441 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100442 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100443 +alloc_skb_55439 alloc_skb 1 55439 NULL
100444 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100445 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100446 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100447 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100448 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100449 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100450 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100451 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100452 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100453 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100454 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100455 +ea_get_55522 ea_get 0 55522 NULL
100456 +buffer_size_55534 buffer_size 0 55534 NULL
100457 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100458 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100459 +add_partition_55588 add_partition 2 55588 NULL
100460 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100461 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100462 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100463 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100464 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100465 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100466 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100467 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100468 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100469 +read_oldmem_55658 read_oldmem 3 55658 NULL
100470 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100471 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100472 +get_info_55681 get_info 3 55681 NULL
100473 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100474 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100475 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100476 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100477 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100478 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100479 +set_local_name_55757 set_local_name 4 55757 NULL
100480 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100481 +strlen_55778 strlen 0 55778 NULL nohasharray
100482 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100483 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100484 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100485 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100486 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100487 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100488 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100489 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100490 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100491 +hsc_write_55875 hsc_write 3 55875 NULL
100492 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100493 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100494 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100495 +handle_response_55951 handle_response 5 55951 NULL
100496 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100497 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100498 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100499 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100500 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100501 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100502 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100503 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100504 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100505 +map_addr_56144 map_addr 7 56144 NULL
100506 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100507 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100508 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100509 +skb_headroom_56200 skb_headroom 0 56200 NULL
100510 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100511 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100512 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100513 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100514 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100515 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100516 +fd_copyin_56247 fd_copyin 3 56247 NULL
100517 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100518 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100519 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100520 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100521 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100522 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100523 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100524 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100525 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100526 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100527 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100528 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100529 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100530 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100531 +dev_read_56369 dev_read 3 56369 NULL
100532 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100533 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100534 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100535 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100536 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100537 +store_msg_56417 store_msg 3 56417 NULL
100538 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100539 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100540 +fl_create_56435 fl_create 5 56435 NULL
100541 +gnttab_map_56439 gnttab_map 2 56439 NULL
100542 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100543 +set_connectable_56458 set_connectable 4 56458 NULL
100544 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100545 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100546 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100547 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100548 +ip_options_get_56538 ip_options_get 4 56538 NULL
100549 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100550 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100551 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100552 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100553 +event_filter_write_56609 event_filter_write 3 56609 NULL
100554 +gather_array_56641 gather_array 3 56641 NULL
100555 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100556 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100557 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100558 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100559 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100560 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100561 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100562 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100563 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100564 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100565 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100566 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100567 +do_syslog_56807 do_syslog 3 56807 NULL
100568 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100569 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100570 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100571 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100572 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100573 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100574 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100575 +strcspn_56913 strcspn 0 56913 NULL
100576 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100577 +check_header_56930 check_header 2 56930 NULL
100578 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100579 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100580 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100581 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100582 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100583 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100584 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100585 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100586 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100587 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100588 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100589 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100590 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100591 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100592 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100593 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100594 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100595 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100596 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100597 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100598 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100599 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100600 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100601 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100602 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100603 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100604 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100605 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100606 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100607 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100608 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100609 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100610 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100611 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100612 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100613 +fw_file_size_57307 fw_file_size 0 57307 NULL
100614 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100615 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100616 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100617 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100618 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100619 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100620 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100621 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100622 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100623 +read_file_blob_57406 read_file_blob 3 57406 NULL
100624 +enclosure_register_57412 enclosure_register 3 57412 NULL
100625 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100626 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100627 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100628 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100629 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100630 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100631 +ReadReg_57453 ReadReg 0 57453 NULL
100632 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100633 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100634 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100635 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100636 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100637 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100638 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100639 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100640 +skb_headlen_57501 skb_headlen 0 57501 NULL
100641 +copy_in_user_57502 copy_in_user 3 57502 NULL
100642 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100643 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100644 +init_tag_map_57515 init_tag_map 3 57515 NULL
100645 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100646 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100647 +inode_permission_57531 inode_permission 0 57531 NULL
100648 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100649 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100650 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100651 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100652 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100653 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100654 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100655 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100656 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100657 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100658 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100659 +mem_read_57631 mem_read 3 57631 NULL
100660 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100661 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100662 +r3964_write_57662 r3964_write 4 57662 NULL
100663 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100664 +__lgwrite_57669 __lgwrite 4 57669 NULL
100665 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100666 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100667 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100668 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100669 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100670 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100671 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100672 +ld2_57794 ld2 0 57794 NULL
100673 +ivtv_read_57796 ivtv_read 3 57796 NULL
100674 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100675 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100676 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100677 +copy_to_user_57835 copy_to_user 3 57835 NULL
100678 +flash_read_57843 flash_read 3 57843 NULL
100679 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100680 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100681 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100682 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100683 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100684 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100685 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100686 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100687 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100688 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100689 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100690 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100691 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100692 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100693 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100694 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100695 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100696 +mc13783_write_58033 mc13783_write 2 58033 NULL
100697 +mce_async_out_58056 mce_async_out 3 58056 NULL
100698 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100699 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100700 +cm4040_write_58079 cm4040_write 3 58079 NULL
100701 +udi_log_event_58105 udi_log_event 3 58105 NULL
100702 +savemem_58129 savemem 3 58129 NULL
100703 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100704 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100705 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100706 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100707 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100708 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100709 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100710 +read_file_debug_58256 read_file_debug 3 58256 NULL
100711 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100712 +profile_load_58267 profile_load 3 58267 NULL
100713 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100714 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100715 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100716 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100717 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100718 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100719 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100720 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100721 +next_pidmap_58347 next_pidmap 2 58347 NULL
100722 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100723 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100724 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100725 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100726 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100727 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100728 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100729 +capabilities_read_58457 capabilities_read 3 58457 NULL
100730 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100731 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100732 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100733 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100734 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100735 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100736 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100737 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100738 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100739 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100740 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100741 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100742 +xip_file_read_58592 xip_file_read 3 58592 NULL
100743 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100744 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100745 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100746 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100747 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100748 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100749 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100750 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100751 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100752 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100753 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100754 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100755 +acpi_map_58725 acpi_map 1-2 58725 NULL
100756 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100757 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100758 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100759 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100760 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100761 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100762 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100763 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100764 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100765 +ep_read_58813 ep_read 3 58813 NULL
100766 +command_write_58841 command_write 3 58841 NULL
100767 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100768 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100769 +hw_write_58881 hw_write 2 58881 NULL
100770 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100771 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100772 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100773 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100774 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100775 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100776 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100777 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100778 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100779 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100780 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100781 +ep_write_59008 ep_write 3 59008 NULL
100782 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100783 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100784 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100785 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100786 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100787 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100788 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100789 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100790 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100791 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100792 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100793 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100794 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100795 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100796 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100797 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100798 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100799 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100800 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100801 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100802 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100803 +dt3155_read_59226 dt3155_read 3 59226 NULL
100804 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100805 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100806 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100807 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100808 +nla_len_59258 nla_len 0 59258 NULL
100809 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100810 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100811 +fd_copyout_59323 fd_copyout 3 59323 NULL
100812 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100813 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100814 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100815 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100816 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100817 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100818 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100819 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100820 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100821 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100822 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100823 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100824 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100825 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100826 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100827 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100828 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100829 +tunables_write_59563 tunables_write 3 59563 NULL
100830 +memdup_user_59590 memdup_user 2 59590 NULL
100831 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100832 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100833 +mtrr_write_59622 mtrr_write 3 59622 NULL
100834 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100835 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100836 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100837 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100838 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100839 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100840 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100841 +wm8400_write_59675 wm8400_write 2 59675 NULL
100842 +sriov_enable_59689 sriov_enable 2 59689 NULL
100843 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100844 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100845 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100846 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100847 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100848 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100849 +strnlen_59746 strnlen 0 59746 NULL
100850 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100851 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100852 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100853 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100854 +venus_remove_59781 venus_remove 4 59781 NULL
100855 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100856 +ipw_write_59807 ipw_write 3 59807 NULL
100857 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100858 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100859 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100860 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100861 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100862 +tun_put_user_59849 tun_put_user 4 59849 NULL
100863 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100864 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100865 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100866 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100867 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100868 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100869 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100870 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100871 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100872 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100873 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100874 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100875 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100876 +register_device_60015 register_device 2-3 60015 NULL
100877 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100878 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100879 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100880 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100881 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100882 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100883 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100884 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100885 +load_module_60056 load_module 2 60056 NULL nohasharray
100886 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100887 +compat_writev_60063 compat_writev 3 60063 NULL
100888 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100889 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100890 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100891 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100892 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100893 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100894 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100895 +init_state_60165 init_state 2 60165 NULL
100896 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100897 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100898 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100899 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100900 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100901 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100902 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100903 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100904 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100905 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100906 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100907 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100908 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100909 +printer_write_60276 printer_write 3 60276 NULL
100910 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100911 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100912 +getDataLength_60301 getDataLength 0 60301 NULL
100913 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100914 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100915 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100916 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100917 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100918 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100919 +driver_names_read_60399 driver_names_read 3 60399 NULL
100920 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100921 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100922 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100923 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100924 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100925 +rx_data_60442 rx_data 4 60442 NULL
100926 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100927 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100928 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100929 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100930 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100931 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100932 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100933 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100934 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100935 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100936 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100937 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100938 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100939 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100940 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100941 +init_data_container_60709 init_data_container 1 60709 NULL
100942 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100943 +raid_status_60755 raid_status 5 60755 NULL
100944 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100945 +opticon_write_60775 opticon_write 4 60775 NULL
100946 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100947 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100948 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100949 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100950 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100951 +generic_writepages_60871 generic_writepages 0 60871 NULL
100952 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100953 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100954 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100955 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100956 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100957 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100958 +pti_char_write_60960 pti_char_write 3 60960 NULL
100959 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100960 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100961 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100962 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100963 +symtab_init_61050 symtab_init 2 61050 NULL
100964 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100965 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100966 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100967 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100968 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100969 +get_derived_key_61100 get_derived_key 4 61100 NULL
100970 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100971 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100972 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100973 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100974 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100975 +__vmalloc_61168 __vmalloc 1 61168 NULL
100976 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100977 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100978 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100979 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100980 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100981 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100982 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100983 +sys_add_key_61288 sys_add_key 4 61288 NULL
100984 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100985 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100986 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100987 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100988 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100989 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100990 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100991 +change_xattr_61390 change_xattr 5 61390 NULL
100992 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100993 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100994 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100995 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100996 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100997 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100998 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100999 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
101000 +erst_errno_61526 erst_errno 0 61526 NULL
101001 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101002 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101003 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101004 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101005 +seq_open_private_61589 seq_open_private 3 61589 NULL
101006 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101007 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101008 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101009 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101010 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101011 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
101012 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101013 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101014 +resize_stripes_61650 resize_stripes 2 61650 NULL
101015 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101016 +insert_one_name_61668 insert_one_name 7 61668 NULL
101017 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
101018 +lock_loop_61681 lock_loop 1 61681 NULL
101019 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
101020 +filter_read_61692 filter_read 3 61692 NULL
101021 +iov_length_61716 iov_length 0 61716 NULL
101022 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101023 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101024 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101025 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
101026 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101027 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101028 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101029 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101030 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101031 +get_fw_name_61874 get_fw_name 3 61874 NULL
101032 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101033 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101034 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101035 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101036 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101037 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101038 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101039 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101040 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101041 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101042 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101043 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101044 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101045 +cow_file_range_61979 cow_file_range 3 61979 NULL
101046 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101047 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101048 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101049 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101050 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101051 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101052 +do_pselect_62061 do_pselect 1 62061 NULL
101053 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
101054 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
101055 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101056 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101057 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101058 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101059 +ql_status_62135 ql_status 5 62135 NULL
101060 +video_usercopy_62151 video_usercopy 2 62151 NULL
101061 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101062 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
101063 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101064 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101065 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101066 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101067 +allocate_partition_62245 allocate_partition 4 62245 NULL
101068 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101069 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101070 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101071 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101072 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101073 +subseq_list_62332 subseq_list 3-0 62332 NULL
101074 +flash_write_62354 flash_write 3 62354 NULL
101075 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101076 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101077 +altera_irscan_62396 altera_irscan 2 62396 NULL
101078 +set_ssp_62411 set_ssp 4 62411 NULL
101079 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
101080 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101081 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101082 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101083 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101084 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101085 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101086 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
101087 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101088 +debugfs_read_62535 debugfs_read 3 62535 NULL
101089 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101090 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101091 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101092 +get_subdir_62581 get_subdir 3 62581 NULL
101093 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101094 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101095 +get_desc_base_62617 get_desc_base 0 62617 NULL
101096 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101097 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101098 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101099 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101100 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
101101 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101102 +write_62671 write 3 62671 NULL
101103 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101104 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101105 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101106 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101107 +rdm_62719 rdm 0 62719 NULL
101108 +key_replays_read_62746 key_replays_read 3 62746 NULL
101109 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101110 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101111 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101112 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101113 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101114 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101115 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101116 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101117 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101118 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
101119 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
101120 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101121 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101122 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101123 +getdqbuf_62908 getdqbuf 1 62908 NULL
101124 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101125 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101126 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101127 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101128 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101129 +unlink1_63059 unlink1 3 63059 NULL
101130 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101131 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101132 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101133 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101134 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101135 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101136 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101137 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101138 +vme_master_read_63221 vme_master_read 0 63221 NULL
101139 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101140 +ptp_read_63251 ptp_read 4 63251 NULL
101141 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101142 +raid5_resize_63306 raid5_resize 2 63306 NULL
101143 +proc_info_read_63344 proc_info_read 3 63344 NULL
101144 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101145 +idmouse_read_63374 idmouse_read 3 63374 NULL
101146 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101147 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101148 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101149 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101150 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101151 +kone_send_63435 kone_send 4 63435 NULL
101152 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101153 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101154 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101155 +read_kcore_63488 read_kcore 3 63488 NULL
101156 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101157 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101158 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101159 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101160 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101161 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101162 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101163 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101164 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101165 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101166 +module_alloc_63630 module_alloc 1 63630 NULL
101167 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101168 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101169 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101170 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101171 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101172 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101173 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101174 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101175 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101176 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101177 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101178 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101179 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101180 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101181 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101182 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101183 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101184 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101185 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101186 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101187 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101188 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101189 +sel_write_load_63830 sel_write_load 3 63830 NULL
101190 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101191 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101192 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101193 +divas_write_63901 divas_write 3 63901 NULL
101194 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101195 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101196 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101197 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101198 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101199 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101200 +__team_options_register_63941 __team_options_register 3 63941 NULL
101201 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101202 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101203 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101204 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101205 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101206 +kmemdup_64015 kmemdup 2 64015 NULL
101207 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101208 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101209 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101210 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101211 +get_u8_64076 get_u8 0 64076 NULL
101212 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101213 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101214 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101215 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101216 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101217 +init_bch_64130 init_bch 1-2 64130 NULL
101218 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101219 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101220 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101221 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101222 +read_pulse_64227 read_pulse 0-3 64227 NULL
101223 +header_len_64232 header_len 0 64232 NULL
101224 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101225 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101226 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101227 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101228 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101229 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101230 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101231 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101232 +ffz_64324 ffz 0 64324 NULL
101233 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101234 +ts_write_64336 ts_write 3 64336 NULL
101235 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101236 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101237 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101238 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101239 +ilo_write_64378 ilo_write 3 64378 NULL
101240 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101241 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101242 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101243 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101244 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101245 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101246 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101247 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101248 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101249 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101250 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101251 +cap_capable_64462 cap_capable 0 64462 NULL
101252 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101253 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101254 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101255 +remove_uuid_64505 remove_uuid 4 64505 NULL
101256 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101257 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101258 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101259 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101260 +__spi_sync_64561 __spi_sync 0 64561 NULL
101261 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101262 +fanotify_write_64623 fanotify_write 3 64623 NULL
101263 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101264 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101265 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101266 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101267 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101268 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101269 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101270 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101271 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101272 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101273 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101274 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101275 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101276 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101277 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101278 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101279 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101280 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101281 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101282 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101283 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101284 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101285 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101286 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101287 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101288 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101289 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101290 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101291 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101292 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101293 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101294 +pskb_pull_65005 pskb_pull 2 65005 NULL
101295 +unifi_write_65012 unifi_write 3 65012 NULL
101296 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101297 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101298 +insert_dent_65034 insert_dent 7 65034 NULL
101299 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101300 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101301 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101302 +make_idx_node_65068 make_idx_node 0 65068 NULL
101303 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101304 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101305 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101306 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101307 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101308 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101309 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101310 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101311 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101312 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101313 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101314 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101315 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101316 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101317 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101318 +get_var_len_65304 get_var_len 0 65304 NULL
101319 +unpack_array_65318 unpack_array 0 65318 NULL
101320 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101321 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101322 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101323 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101324 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101325 +strchr_65372 strchr 0 65372 NULL
101326 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101327 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101328 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101329 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101330 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101331 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101332 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101333 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101334 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101335 +regmap_write_65478 regmap_write 2 65478 NULL
101336 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101337 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101338 +alloc_dr_65495 alloc_dr 2 65495 NULL
101339 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101340 new file mode 100644
101341 index 0000000..9db0d0e
101342 --- /dev/null
101343 +++ b/tools/gcc/size_overflow_plugin.c
101344 @@ -0,0 +1,2114 @@
101345 +/*
101346 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101347 + * Licensed under the GPL v2, or (at your option) v3
101348 + *
101349 + * Homepage:
101350 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101351 + *
101352 + * Documentation:
101353 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101354 + *
101355 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101356 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101357 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101358 + *
101359 + * Usage:
101360 + * $ 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
101361 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101362 + */
101363 +
101364 +#include "gcc-plugin.h"
101365 +#include "config.h"
101366 +#include "system.h"
101367 +#include "coretypes.h"
101368 +#include "tree.h"
101369 +#include "tree-pass.h"
101370 +#include "intl.h"
101371 +#include "plugin-version.h"
101372 +#include "tm.h"
101373 +#include "toplev.h"
101374 +#include "function.h"
101375 +#include "tree-flow.h"
101376 +#include "plugin.h"
101377 +#include "gimple.h"
101378 +#include "diagnostic.h"
101379 +#include "cfgloop.h"
101380 +
101381 +#if BUILDING_GCC_VERSION >= 4008
101382 +#define TODO_dump_func 0
101383 +#endif
101384 +
101385 +struct size_overflow_hash {
101386 + const struct size_overflow_hash * const next;
101387 + const char * const name;
101388 + const unsigned int param;
101389 +};
101390 +
101391 +#include "size_overflow_hash.h"
101392 +
101393 +enum mark {
101394 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101395 +};
101396 +
101397 +enum err_code_conditions {
101398 + CAST_ONLY, FROM_CONST
101399 +};
101400 +
101401 +static unsigned int call_count = 0;
101402 +
101403 +#define __unused __attribute__((__unused__))
101404 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101405 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101406 +#define BEFORE_STMT true
101407 +#define AFTER_STMT false
101408 +#define CREATE_NEW_VAR NULL_TREE
101409 +#define CODES_LIMIT 32
101410 +#define MAX_PARAM 31
101411 +#define MY_STMT GF_PLF_1
101412 +#define NO_CAST_CHECK GF_PLF_2
101413 +#define FROM_ARG true
101414 +#define FROM_RET false
101415 +
101416 +#if BUILDING_GCC_VERSION == 4005
101417 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101418 +#endif
101419 +
101420 +int plugin_is_GPL_compatible;
101421 +void debug_gimple_stmt(gimple gs);
101422 +
101423 +static tree expand(struct pointer_set_t *visited, tree lhs);
101424 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101425 +static tree report_size_overflow_decl;
101426 +static const_tree const_char_ptr_type_node;
101427 +static unsigned int handle_function(void);
101428 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101429 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101430 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101431 +static void print_missing_msg(tree func, unsigned int argnum);
101432 +
101433 +static struct plugin_info size_overflow_plugin_info = {
101434 + .version = "20130410beta",
101435 + .help = "no-size-overflow\tturn off size overflow checking\n",
101436 +};
101437 +
101438 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101439 +{
101440 + unsigned int arg_count;
101441 + enum tree_code code = TREE_CODE(*node);
101442 +
101443 + switch (code) {
101444 + case FUNCTION_DECL:
101445 + arg_count = type_num_arguments(TREE_TYPE(*node));
101446 + break;
101447 + case FUNCTION_TYPE:
101448 + case METHOD_TYPE:
101449 + arg_count = type_num_arguments(*node);
101450 + break;
101451 + default:
101452 + *no_add_attrs = true;
101453 + error("%s: %qE attribute only applies to functions", __func__, name);
101454 + return NULL_TREE;
101455 + }
101456 +
101457 + for (; args; args = TREE_CHAIN(args)) {
101458 + tree position = TREE_VALUE(args);
101459 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101460 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101461 + *no_add_attrs = true;
101462 + }
101463 + }
101464 + return NULL_TREE;
101465 +}
101466 +
101467 +static const char* get_asm_name(tree node)
101468 +{
101469 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101470 +}
101471 +
101472 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101473 +{
101474 + unsigned int arg_count, arg_num;
101475 + enum tree_code code = TREE_CODE(*node);
101476 +
101477 + switch (code) {
101478 + case FUNCTION_DECL:
101479 + arg_count = type_num_arguments(TREE_TYPE(*node));
101480 + break;
101481 + case FUNCTION_TYPE:
101482 + case METHOD_TYPE:
101483 + arg_count = type_num_arguments(*node);
101484 + break;
101485 + case FIELD_DECL:
101486 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101487 + if (arg_num != 0) {
101488 + *no_add_attrs = true;
101489 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101490 + }
101491 + return NULL_TREE;
101492 + default:
101493 + *no_add_attrs = true;
101494 + error("%qE attribute only applies to functions", name);
101495 + return NULL_TREE;
101496 + }
101497 +
101498 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101499 + return NULL_TREE;
101500 +
101501 + for (; args; args = TREE_CHAIN(args)) {
101502 + tree position = TREE_VALUE(args);
101503 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101504 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101505 + *no_add_attrs = true;
101506 + }
101507 + }
101508 + return NULL_TREE;
101509 +}
101510 +
101511 +static struct attribute_spec size_overflow_attr = {
101512 + .name = "size_overflow",
101513 + .min_length = 1,
101514 + .max_length = -1,
101515 + .decl_required = true,
101516 + .type_required = false,
101517 + .function_type_required = false,
101518 + .handler = handle_size_overflow_attribute,
101519 +#if BUILDING_GCC_VERSION >= 4007
101520 + .affects_type_identity = false
101521 +#endif
101522 +};
101523 +
101524 +static struct attribute_spec intentional_overflow_attr = {
101525 + .name = "intentional_overflow",
101526 + .min_length = 1,
101527 + .max_length = -1,
101528 + .decl_required = true,
101529 + .type_required = false,
101530 + .function_type_required = false,
101531 + .handler = handle_intentional_overflow_attribute,
101532 +#if BUILDING_GCC_VERSION >= 4007
101533 + .affects_type_identity = false
101534 +#endif
101535 +};
101536 +
101537 +static void register_attributes(void __unused *event_data, void __unused *data)
101538 +{
101539 + register_attribute(&size_overflow_attr);
101540 + register_attribute(&intentional_overflow_attr);
101541 +}
101542 +
101543 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101544 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101545 +{
101546 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101547 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101548 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101549 +
101550 + unsigned int m = 0x57559429;
101551 + unsigned int n = 0x5052acdb;
101552 + const unsigned int *key4 = (const unsigned int *)key;
101553 + unsigned int h = len;
101554 + unsigned int k = len + seed + n;
101555 + unsigned long long p;
101556 +
101557 + while (len >= 8) {
101558 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101559 + len -= 8;
101560 + }
101561 + if (len >= 4) {
101562 + cwmixb(key4[0]) key4 += 1;
101563 + len -= 4;
101564 + }
101565 + if (len)
101566 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101567 + cwmixb(h ^ (k + n));
101568 + return k ^ h;
101569 +
101570 +#undef cwfold
101571 +#undef cwmixa
101572 +#undef cwmixb
101573 +}
101574 +
101575 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101576 +{
101577 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101578 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101579 + return fn ^ codes;
101580 +}
101581 +
101582 +static inline tree get_original_function_decl(tree fndecl)
101583 +{
101584 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101585 + return DECL_ABSTRACT_ORIGIN(fndecl);
101586 + return fndecl;
101587 +}
101588 +
101589 +static inline gimple get_def_stmt(const_tree node)
101590 +{
101591 + gcc_assert(node != NULL_TREE);
101592 + if (TREE_CODE(node) != SSA_NAME)
101593 + return NULL;
101594 + return SSA_NAME_DEF_STMT(node);
101595 +}
101596 +
101597 +static unsigned char get_tree_code(const_tree type)
101598 +{
101599 + switch (TREE_CODE(type)) {
101600 + case ARRAY_TYPE:
101601 + return 0;
101602 + case BOOLEAN_TYPE:
101603 + return 1;
101604 + case ENUMERAL_TYPE:
101605 + return 2;
101606 + case FUNCTION_TYPE:
101607 + return 3;
101608 + case INTEGER_TYPE:
101609 + return 4;
101610 + case POINTER_TYPE:
101611 + return 5;
101612 + case RECORD_TYPE:
101613 + return 6;
101614 + case UNION_TYPE:
101615 + return 7;
101616 + case VOID_TYPE:
101617 + return 8;
101618 + case REAL_TYPE:
101619 + return 9;
101620 + case VECTOR_TYPE:
101621 + return 10;
101622 + case REFERENCE_TYPE:
101623 + return 11;
101624 + case OFFSET_TYPE:
101625 + return 12;
101626 + case COMPLEX_TYPE:
101627 + return 13;
101628 + default:
101629 + debug_tree((tree)type);
101630 + gcc_unreachable();
101631 + }
101632 +}
101633 +
101634 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101635 +{
101636 + gcc_assert(type != NULL_TREE);
101637 +
101638 + while (type && len < CODES_LIMIT) {
101639 + tree_codes[len] = get_tree_code(type);
101640 + len++;
101641 + type = TREE_TYPE(type);
101642 + }
101643 + return len;
101644 +}
101645 +
101646 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101647 +{
101648 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101649 + enum tree_code code = TREE_CODE(type);
101650 + size_t len = 0;
101651 +
101652 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101653 +
101654 + arg = TYPE_ARG_TYPES(type);
101655 + // skip builtins __builtin_constant_p
101656 + if (!arg && DECL_BUILT_IN(fndecl))
101657 + return 0;
101658 +
101659 + if (TREE_CODE_CLASS(code) == tcc_type)
101660 + result = type;
101661 + else
101662 + result = DECL_RESULT(fndecl);
101663 +
101664 + gcc_assert(result != NULL_TREE);
101665 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101666 +
101667 + if (arg == NULL_TREE) {
101668 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101669 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101670 + if (arg_field == NULL_TREE)
101671 + return 0;
101672 + arg = TREE_TYPE(arg_field);
101673 + len = add_type_codes(arg, tree_codes, len);
101674 + gcc_assert(len != 0);
101675 + return len;
101676 + }
101677 +
101678 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101679 + while (arg && len < CODES_LIMIT) {
101680 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101681 + arg = TREE_CHAIN(arg);
101682 + }
101683 +
101684 + gcc_assert(len != 0);
101685 + return len;
101686 +}
101687 +
101688 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101689 +{
101690 + unsigned int hash;
101691 + const struct size_overflow_hash *entry;
101692 + unsigned char tree_codes[CODES_LIMIT];
101693 + size_t len;
101694 + const char *func_name;
101695 +
101696 + fndecl = get_original_function_decl(fndecl);
101697 + len = get_function_decl(fndecl, tree_codes);
101698 + if (len == 0)
101699 + return NULL;
101700 +
101701 + func_name = get_asm_name(fndecl);
101702 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101703 +
101704 + entry = size_overflow_hash[hash];
101705 + while (entry) {
101706 + if (!strcmp(entry->name, func_name))
101707 + return entry;
101708 + entry = entry->next;
101709 + }
101710 +
101711 + return NULL;
101712 +}
101713 +
101714 +static bool is_bool(const_tree node)
101715 +{
101716 + const_tree type;
101717 +
101718 + if (node == NULL_TREE)
101719 + return false;
101720 +
101721 + type = TREE_TYPE(node);
101722 + if (!INTEGRAL_TYPE_P(type))
101723 + return false;
101724 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101725 + return true;
101726 + if (TYPE_PRECISION(type) == 1)
101727 + return true;
101728 + return false;
101729 +}
101730 +
101731 +static bool skip_types(const_tree var)
101732 +{
101733 + tree type;
101734 +
101735 + if (is_gimple_constant(var))
101736 + return true;
101737 +
101738 + switch (TREE_CODE(var)) {
101739 + case ADDR_EXPR:
101740 +#if BUILDING_GCC_VERSION >= 4006
101741 + case MEM_REF:
101742 +#endif
101743 + case ARRAY_REF:
101744 + case BIT_FIELD_REF:
101745 + case INDIRECT_REF:
101746 + case TARGET_MEM_REF:
101747 + return true;
101748 + case PARM_DECL:
101749 + case VAR_DECL:
101750 + case COMPONENT_REF:
101751 + return false;
101752 + default:
101753 + break;
101754 + }
101755 +
101756 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101757 +
101758 + type = TREE_TYPE(var);
101759 + switch (TREE_CODE(type)) {
101760 + case INTEGER_TYPE:
101761 + case ENUMERAL_TYPE:
101762 + return false;
101763 + case BOOLEAN_TYPE:
101764 + return is_bool(var);
101765 + default:
101766 + break;
101767 + }
101768 +
101769 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101770 +
101771 + type = TREE_TYPE(type);
101772 + gcc_assert(type != NULL_TREE);
101773 + switch (TREE_CODE(type)) {
101774 + case RECORD_TYPE:
101775 + case POINTER_TYPE:
101776 + case ARRAY_TYPE:
101777 + return true;
101778 + case VOID_TYPE:
101779 + case INTEGER_TYPE:
101780 + case UNION_TYPE:
101781 + return false;
101782 + default:
101783 + break;
101784 + }
101785 +
101786 + debug_tree((tree)var);
101787 + gcc_unreachable();
101788 +}
101789 +
101790 +static unsigned int find_arg_number(const_tree arg, tree func)
101791 +{
101792 + tree var;
101793 + unsigned int argnum = 1;
101794 +
101795 + if (TREE_CODE(arg) == SSA_NAME)
101796 + arg = SSA_NAME_VAR(arg);
101797 +
101798 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101799 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101800 + continue;
101801 + if (!skip_types(var))
101802 + return argnum;
101803 + }
101804 +
101805 + return 0;
101806 +}
101807 +
101808 +static tree create_new_var(tree type)
101809 +{
101810 + tree new_var = create_tmp_var(type, "cicus");
101811 +
101812 +#if BUILDING_GCC_VERSION <= 4007
101813 + add_referenced_var(new_var);
101814 + mark_sym_for_renaming(new_var);
101815 +#endif
101816 + return new_var;
101817 +}
101818 +
101819 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101820 +{
101821 + gimple assign;
101822 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101823 + tree type = TREE_TYPE(rhs1);
101824 + tree lhs = create_new_var(type);
101825 +
101826 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101827 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101828 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101829 +
101830 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101831 + update_stmt(assign);
101832 + gimple_set_plf(assign, MY_STMT, true);
101833 + return assign;
101834 +}
101835 +
101836 +static tree cast_a_tree(tree type, tree var)
101837 +{
101838 + gcc_assert(type != NULL_TREE);
101839 + gcc_assert(var != NULL_TREE);
101840 + gcc_assert(fold_convertible_p(type, var));
101841 +
101842 + return fold_convert(type, var);
101843 +}
101844 +
101845 +static tree get_lhs(const_gimple stmt)
101846 +{
101847 + switch (gimple_code(stmt)) {
101848 + case GIMPLE_ASSIGN:
101849 + return gimple_get_lhs(stmt);
101850 + case GIMPLE_PHI:
101851 + return gimple_phi_result(stmt);
101852 + case GIMPLE_CALL:
101853 + return gimple_call_lhs(stmt);
101854 + default:
101855 + return NULL_TREE;
101856 + }
101857 +}
101858 +
101859 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101860 +{
101861 + const_gimple def_stmt = get_def_stmt(rhs);
101862 +
101863 + if (force)
101864 + return false;
101865 +
101866 + if (is_gimple_constant(rhs))
101867 + return false;
101868 +
101869 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101870 + return false;
101871 +
101872 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101873 + return false;
101874 +
101875 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101876 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101877 + return false;
101878 +
101879 + return true;
101880 +}
101881 +
101882 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101883 +{
101884 + gimple assign, def_stmt;
101885 +
101886 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101887 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101888 + gcc_unreachable();
101889 +
101890 + def_stmt = get_def_stmt(rhs);
101891 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101892 + return def_stmt;
101893 +
101894 + if (lhs == CREATE_NEW_VAR)
101895 + lhs = create_new_var(dst_type);
101896 +
101897 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101898 +
101899 + if (!gsi_end_p(*gsi)) {
101900 + location_t loc = gimple_location(gsi_stmt(*gsi));
101901 + gimple_set_location(assign, loc);
101902 + }
101903 +
101904 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101905 +
101906 + if (before)
101907 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101908 + else
101909 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101910 + update_stmt(assign);
101911 + gimple_set_plf(assign, MY_STMT, true);
101912 +
101913 + return assign;
101914 +}
101915 +
101916 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101917 +{
101918 + gimple_stmt_iterator gsi;
101919 + tree lhs;
101920 + const_gimple new_stmt;
101921 +
101922 + if (rhs == NULL_TREE)
101923 + return NULL_TREE;
101924 +
101925 + gsi = gsi_for_stmt(stmt);
101926 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101927 +
101928 + lhs = get_lhs(new_stmt);
101929 + gcc_assert(lhs != NULL_TREE);
101930 + return lhs;
101931 +}
101932 +
101933 +static tree cast_to_TI_type(gimple stmt, tree node)
101934 +{
101935 + gimple_stmt_iterator gsi;
101936 + gimple cast_stmt;
101937 + tree type = TREE_TYPE(node);
101938 +
101939 + if (types_compatible_p(type, intTI_type_node))
101940 + return node;
101941 +
101942 + gsi = gsi_for_stmt(stmt);
101943 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101944 + return gimple_get_lhs(cast_stmt);
101945 +}
101946 +
101947 +static void check_function_hash(const_gimple stmt)
101948 +{
101949 + tree func;
101950 + const struct size_overflow_hash *hash;
101951 +
101952 + if (gimple_code(stmt) != GIMPLE_CALL)
101953 + return;
101954 +
101955 + func = gimple_call_fndecl(stmt);
101956 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101957 + if (func == NULL_TREE)
101958 + return;
101959 +
101960 + hash = get_function_hash(func);
101961 + if (!hash)
101962 + print_missing_msg(func, 0);
101963 +}
101964 +
101965 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101966 +{
101967 + tree lhs, new_lhs;
101968 + gimple_stmt_iterator gsi;
101969 +
101970 + if (rhs1 == NULL_TREE) {
101971 + debug_gimple_stmt(oldstmt);
101972 + error("%s: rhs1 is NULL_TREE", __func__);
101973 + gcc_unreachable();
101974 + }
101975 +
101976 + switch (gimple_code(oldstmt)) {
101977 + case GIMPLE_ASM:
101978 + lhs = rhs1;
101979 + break;
101980 + case GIMPLE_CALL:
101981 + lhs = gimple_call_lhs(oldstmt);
101982 + break;
101983 + case GIMPLE_ASSIGN:
101984 + lhs = gimple_get_lhs(oldstmt);
101985 + break;
101986 + default:
101987 + debug_gimple_stmt(oldstmt);
101988 + gcc_unreachable();
101989 + }
101990 +
101991 + gsi = gsi_for_stmt(oldstmt);
101992 + pointer_set_insert(visited, oldstmt);
101993 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101994 + basic_block next_bb, cur_bb;
101995 + const_edge e;
101996 +
101997 + gcc_assert(before == false);
101998 + gcc_assert(stmt_can_throw_internal(oldstmt));
101999 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102000 + gcc_assert(!gsi_end_p(gsi));
102001 +
102002 + cur_bb = gimple_bb(oldstmt);
102003 + next_bb = cur_bb->next_bb;
102004 + e = find_edge(cur_bb, next_bb);
102005 + gcc_assert(e != NULL);
102006 + gcc_assert(e->flags & EDGE_FALLTHRU);
102007 +
102008 + gsi = gsi_after_labels(next_bb);
102009 + gcc_assert(!gsi_end_p(gsi));
102010 +
102011 + before = true;
102012 + oldstmt = gsi_stmt(gsi);
102013 + }
102014 +
102015 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102016 + return new_lhs;
102017 +}
102018 +
102019 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102020 +{
102021 + gimple stmt;
102022 + gimple_stmt_iterator gsi;
102023 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102024 +
102025 + if (gimple_plf(oldstmt, MY_STMT))
102026 + return lhs;
102027 +
102028 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102029 + rhs1 = gimple_assign_rhs1(oldstmt);
102030 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102031 + }
102032 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102033 + rhs2 = gimple_assign_rhs2(oldstmt);
102034 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102035 + }
102036 +
102037 + stmt = gimple_copy(oldstmt);
102038 + gimple_set_location(stmt, gimple_location(oldstmt));
102039 + gimple_set_plf(stmt, MY_STMT, true);
102040 +
102041 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102042 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102043 +
102044 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102045 +
102046 + new_var = create_new_var(size_overflow_type);
102047 + new_var = make_ssa_name(new_var, stmt);
102048 + gimple_set_lhs(stmt, new_var);
102049 +
102050 + if (rhs1 != NULL_TREE)
102051 + gimple_assign_set_rhs1(stmt, rhs1);
102052 +
102053 + if (rhs2 != NULL_TREE)
102054 + gimple_assign_set_rhs2(stmt, rhs2);
102055 +#if BUILDING_GCC_VERSION >= 4007
102056 + if (rhs3 != NULL_TREE)
102057 + gimple_assign_set_rhs3(stmt, rhs3);
102058 +#endif
102059 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102060 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102061 +
102062 + gsi = gsi_for_stmt(oldstmt);
102063 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102064 + update_stmt(stmt);
102065 + pointer_set_insert(visited, oldstmt);
102066 + return gimple_get_lhs(stmt);
102067 +}
102068 +
102069 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102070 +{
102071 + basic_block first_bb;
102072 + gimple assign;
102073 + gimple_stmt_iterator gsi;
102074 +
102075 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102076 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102077 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102078 +
102079 + gsi = gsi_start_bb(first_bb);
102080 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102081 + return gimple_get_lhs(assign);
102082 +}
102083 +
102084 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102085 +{
102086 + gimple_stmt_iterator gsi;
102087 + const_gimple assign;
102088 + gimple def_stmt = get_def_stmt(new_arg);
102089 +
102090 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102091 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102092 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102093 + } else {
102094 + gsi = gsi_for_stmt(def_stmt);
102095 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102096 + }
102097 +
102098 + return gimple_get_lhs(assign);
102099 +}
102100 +
102101 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102102 +{
102103 + basic_block bb;
102104 + gimple_stmt_iterator gsi;
102105 + const_gimple assign, def_stmt;
102106 +
102107 + def_stmt = get_def_stmt(arg);
102108 + bb = gimple_bb(def_stmt);
102109 + gcc_assert(bb->index != 0);
102110 + gsi = gsi_after_labels(bb);
102111 +
102112 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102113 + return gimple_get_lhs(assign);
102114 +}
102115 +
102116 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102117 +{
102118 + tree size_overflow_type;
102119 + const_gimple def_stmt = get_def_stmt(arg);
102120 +
102121 + if (phi_ssa_name != NULL_TREE)
102122 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102123 +
102124 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102125 +
102126 + if (new_arg != NULL_TREE) {
102127 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102128 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102129 + }
102130 +
102131 + switch(gimple_code(def_stmt)) {
102132 + case GIMPLE_PHI:
102133 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102134 + case GIMPLE_NOP:
102135 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102136 + default:
102137 + debug_gimple_stmt((gimple)def_stmt);
102138 + gcc_unreachable();
102139 + }
102140 +}
102141 +
102142 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102143 +{
102144 + basic_block bb;
102145 + gimple phi;
102146 + gimple_seq seq;
102147 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102148 +
102149 + bb = gsi_bb(gsi);
102150 +
102151 + phi = create_phi_node(result, bb);
102152 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102153 + seq = phi_nodes(bb);
102154 + gsi = gsi_last(seq);
102155 + gsi_remove(&gsi, false);
102156 +
102157 + gsi = gsi_for_stmt(oldstmt);
102158 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102159 + gimple_set_bb(phi, bb);
102160 + gimple_set_plf(phi, MY_STMT, true);
102161 + return phi;
102162 +}
102163 +
102164 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102165 +{
102166 + gimple new_phi = NULL;
102167 + gimple oldstmt = get_def_stmt(orig_result);
102168 + tree phi_ssa_name = NULL_TREE;
102169 + unsigned int i;
102170 +
102171 + pointer_set_insert(visited, oldstmt);
102172 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102173 + tree arg, new_arg;
102174 +
102175 + arg = gimple_phi_arg_def(oldstmt, i);
102176 +
102177 + new_arg = expand(visited, arg);
102178 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102179 + if (i == 0) {
102180 + phi_ssa_name = new_arg;
102181 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102182 + }
102183 +
102184 + gcc_assert(new_phi != NULL);
102185 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102186 + }
102187 +
102188 + gcc_assert(new_phi != NULL);
102189 + update_stmt(new_phi);
102190 + return gimple_phi_result(new_phi);
102191 +}
102192 +
102193 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102194 +{
102195 + const_gimple assign;
102196 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102197 + tree origtype = TREE_TYPE(orig_rhs);
102198 +
102199 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102200 +
102201 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102202 + return gimple_get_lhs(assign);
102203 +}
102204 +
102205 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102206 +{
102207 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102208 + enum machine_mode lhs_mode, rhs_mode;
102209 + gimple def_stmt = get_def_stmt(no_const_rhs);
102210 +
102211 + if (!gimple_assign_cast_p(def_stmt))
102212 + return false;
102213 +
102214 + rhs1 = gimple_assign_rhs1(def_stmt);
102215 + lhs = gimple_get_lhs(def_stmt);
102216 + rhs1_type = TREE_TYPE(rhs1);
102217 + lhs_type = TREE_TYPE(lhs);
102218 + rhs_mode = TYPE_MODE(rhs1_type);
102219 + lhs_mode = TYPE_MODE(lhs_type);
102220 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102221 + return false;
102222 +
102223 + return true;
102224 +}
102225 +
102226 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102227 +{
102228 + tree rhs1 = gimple_assign_rhs1(stmt);
102229 + tree lhs = gimple_get_lhs(stmt);
102230 + const_tree rhs1_type = TREE_TYPE(rhs1);
102231 + const_tree lhs_type = TREE_TYPE(lhs);
102232 +
102233 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102234 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102235 +
102236 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102237 +}
102238 +
102239 +static bool no_uses(tree node)
102240 +{
102241 + imm_use_iterator imm_iter;
102242 + use_operand_p use_p;
102243 +
102244 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102245 + const_gimple use_stmt = USE_STMT(use_p);
102246 + if (use_stmt == NULL)
102247 + return true;
102248 + if (is_gimple_debug(use_stmt))
102249 + continue;
102250 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102251 + continue;
102252 + return false;
102253 + }
102254 + return true;
102255 +}
102256 +
102257 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102258 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102259 +{
102260 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102261 + gimple def_stmt = get_def_stmt(lhs);
102262 +
102263 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102264 + return false;
102265 +
102266 + rhs1 = gimple_assign_rhs1(def_stmt);
102267 + rhs_type = TREE_TYPE(rhs1);
102268 + lhs_type = TREE_TYPE(lhs);
102269 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102270 + return false;
102271 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102272 + return false;
102273 +
102274 + def_stmt = get_def_stmt(rhs1);
102275 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102276 + return false;
102277 +
102278 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102279 + return false;
102280 +
102281 + rhs1 = gimple_assign_rhs1(def_stmt);
102282 + rhs2 = gimple_assign_rhs2(def_stmt);
102283 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102284 + return false;
102285 +
102286 + if (is_gimple_constant(rhs2))
102287 + not_const_rhs = rhs1;
102288 + else
102289 + not_const_rhs = rhs2;
102290 +
102291 + return no_uses(not_const_rhs);
102292 +}
102293 +
102294 +static bool skip_lhs_cast_check(const_gimple stmt)
102295 +{
102296 + const_tree rhs = gimple_assign_rhs1(stmt);
102297 + const_gimple def_stmt = get_def_stmt(rhs);
102298 +
102299 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102300 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102301 + return true;
102302 +
102303 + if (is_const_plus_unsigned_signed_truncation(rhs))
102304 + return true;
102305 +
102306 + return false;
102307 +}
102308 +
102309 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102310 +{
102311 + bool cast_lhs, cast_rhs;
102312 + tree lhs = gimple_get_lhs(stmt);
102313 + tree rhs = gimple_assign_rhs1(stmt);
102314 + const_tree lhs_type = TREE_TYPE(lhs);
102315 + const_tree rhs_type = TREE_TYPE(rhs);
102316 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102317 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102318 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102319 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102320 +
102321 + static bool check_lhs[3][4] = {
102322 + // ss su us uu
102323 + { false, true, true, false }, // lhs > rhs
102324 + { false, false, false, false }, // lhs = rhs
102325 + { true, true, true, true }, // lhs < rhs
102326 + };
102327 +
102328 + static bool check_rhs[3][4] = {
102329 + // ss su us uu
102330 + { true, false, true, true }, // lhs > rhs
102331 + { true, false, true, true }, // lhs = rhs
102332 + { true, false, true, true }, // lhs < rhs
102333 + };
102334 +
102335 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102336 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102337 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102338 +
102339 + if (lhs_size > rhs_size) {
102340 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102341 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102342 + } else if (lhs_size == rhs_size) {
102343 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102344 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102345 + } else {
102346 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102347 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102348 + }
102349 +
102350 + if (!cast_lhs && !cast_rhs)
102351 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102352 +
102353 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102354 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102355 +
102356 + if (cast_rhs)
102357 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102358 +
102359 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102360 +}
102361 +
102362 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102363 +{
102364 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102365 +
102366 + if (gimple_plf(stmt, MY_STMT))
102367 + return lhs;
102368 +
102369 + rhs1 = gimple_assign_rhs1(stmt);
102370 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102371 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102372 +
102373 + new_rhs1 = expand(visited, rhs1);
102374 +
102375 + if (new_rhs1 == NULL_TREE)
102376 + return create_cast_assign(visited, stmt);
102377 +
102378 + if (gimple_plf(stmt, NO_CAST_CHECK))
102379 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102380 +
102381 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102382 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102383 +
102384 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102385 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102386 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102387 + }
102388 +
102389 + if (!gimple_assign_cast_p(stmt))
102390 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102391 +
102392 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102393 +}
102394 +
102395 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102396 +{
102397 + tree rhs1, lhs = gimple_get_lhs(stmt);
102398 + gimple def_stmt = get_def_stmt(lhs);
102399 +
102400 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102401 + rhs1 = gimple_assign_rhs1(def_stmt);
102402 +
102403 + if (is_gimple_constant(rhs1))
102404 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102405 +
102406 + switch (TREE_CODE(rhs1)) {
102407 + case SSA_NAME:
102408 + return handle_unary_rhs(visited, def_stmt);
102409 + case ARRAY_REF:
102410 + case BIT_FIELD_REF:
102411 + case ADDR_EXPR:
102412 + case COMPONENT_REF:
102413 + case INDIRECT_REF:
102414 +#if BUILDING_GCC_VERSION >= 4006
102415 + case MEM_REF:
102416 +#endif
102417 + case TARGET_MEM_REF:
102418 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102419 + case PARM_DECL:
102420 + case VAR_DECL:
102421 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102422 +
102423 + default:
102424 + debug_gimple_stmt(def_stmt);
102425 + debug_tree(rhs1);
102426 + gcc_unreachable();
102427 + }
102428 +}
102429 +
102430 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102431 +{
102432 + gimple cond_stmt;
102433 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102434 +
102435 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102436 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102437 + update_stmt(cond_stmt);
102438 +}
102439 +
102440 +static tree create_string_param(tree string)
102441 +{
102442 + tree i_type, a_type;
102443 + const int length = TREE_STRING_LENGTH(string);
102444 +
102445 + gcc_assert(length > 0);
102446 +
102447 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102448 + a_type = build_array_type(char_type_node, i_type);
102449 +
102450 + TREE_TYPE(string) = a_type;
102451 + TREE_CONSTANT(string) = 1;
102452 + TREE_READONLY(string) = 1;
102453 +
102454 + return build1(ADDR_EXPR, ptr_type_node, string);
102455 +}
102456 +
102457 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102458 +{
102459 + gimple func_stmt;
102460 + const_gimple def_stmt;
102461 + const_tree loc_line;
102462 + tree loc_file, ssa_name, current_func;
102463 + expanded_location xloc;
102464 + char *ssa_name_buf;
102465 + int len;
102466 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102467 +
102468 + def_stmt = get_def_stmt(arg);
102469 + xloc = expand_location(gimple_location(def_stmt));
102470 +
102471 + if (!gimple_has_location(def_stmt)) {
102472 + xloc = expand_location(gimple_location(stmt));
102473 + if (!gimple_has_location(stmt))
102474 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102475 + }
102476 +
102477 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102478 +
102479 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102480 + loc_file = create_string_param(loc_file);
102481 +
102482 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102483 + current_func = create_string_param(current_func);
102484 +
102485 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102486 + call_count++;
102487 + 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);
102488 + gcc_assert(len > 0);
102489 + ssa_name = build_string(len + 1, ssa_name_buf);
102490 + free(ssa_name_buf);
102491 + ssa_name = create_string_param(ssa_name);
102492 +
102493 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102494 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102495 +
102496 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102497 +}
102498 +
102499 +static void __unused print_the_code_insertions(const_gimple stmt)
102500 +{
102501 + location_t loc = gimple_location(stmt);
102502 +
102503 + inform(loc, "Integer size_overflow check applied here.");
102504 +}
102505 +
102506 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102507 +{
102508 + basic_block cond_bb, join_bb, bb_true;
102509 + edge e;
102510 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102511 +
102512 + cond_bb = gimple_bb(stmt);
102513 + if (before)
102514 + gsi_prev(&gsi);
102515 + if (gsi_end_p(gsi))
102516 + e = split_block_after_labels(cond_bb);
102517 + else
102518 + e = split_block(cond_bb, gsi_stmt(gsi));
102519 + cond_bb = e->src;
102520 + join_bb = e->dest;
102521 + e->flags = EDGE_FALSE_VALUE;
102522 + e->probability = REG_BR_PROB_BASE;
102523 +
102524 + bb_true = create_empty_bb(cond_bb);
102525 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102526 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102527 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102528 +
102529 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102530 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102531 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102532 +
102533 + if (current_loops != NULL) {
102534 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102535 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102536 + }
102537 +
102538 + insert_cond(cond_bb, arg, cond_code, type_value);
102539 + insert_cond_result(bb_true, stmt, arg, min);
102540 +
102541 +// print_the_code_insertions(stmt);
102542 +}
102543 +
102544 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102545 +{
102546 + const_tree rhs_type = TREE_TYPE(rhs);
102547 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102548 +
102549 + gcc_assert(rhs_type != NULL_TREE);
102550 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102551 + return;
102552 +
102553 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102554 +
102555 + if (is_const_plus_unsigned_signed_truncation(rhs))
102556 + return;
102557 +
102558 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102559 + // typemax (-1) < typemin (0)
102560 + if (TREE_OVERFLOW(type_max))
102561 + return;
102562 +
102563 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102564 +
102565 + cast_rhs_type = TREE_TYPE(cast_rhs);
102566 + type_max_type = TREE_TYPE(type_max);
102567 + type_min_type = TREE_TYPE(type_min);
102568 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102569 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102570 +
102571 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102572 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102573 +}
102574 +
102575 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102576 +{
102577 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102578 + return false;
102579 + if (!is_gimple_constant(rhs))
102580 + return false;
102581 + return true;
102582 +}
102583 +
102584 +static tree get_def_stmt_rhs(const_tree var)
102585 +{
102586 + tree rhs1, def_stmt_rhs1;
102587 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102588 +
102589 + def_stmt = get_def_stmt(var);
102590 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102591 +
102592 + rhs1 = gimple_assign_rhs1(def_stmt);
102593 + rhs1_def_stmt = get_def_stmt(rhs1);
102594 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102595 + return rhs1;
102596 +
102597 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102598 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102599 +
102600 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102601 + case GIMPLE_CALL:
102602 + case GIMPLE_NOP:
102603 + case GIMPLE_ASM:
102604 + case GIMPLE_PHI:
102605 + return def_stmt_rhs1;
102606 + case GIMPLE_ASSIGN:
102607 + return rhs1;
102608 + default:
102609 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102610 + gcc_unreachable();
102611 + }
102612 +}
102613 +
102614 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102615 +{
102616 + tree new_rhs, orig_rhs;
102617 + void (*gimple_assign_set_rhs)(gimple, tree);
102618 + tree rhs1 = gimple_assign_rhs1(stmt);
102619 + tree rhs2 = gimple_assign_rhs2(stmt);
102620 + tree lhs = gimple_get_lhs(stmt);
102621 +
102622 + if (!check_overflow)
102623 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102624 +
102625 + if (change_rhs == NULL_TREE)
102626 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102627 +
102628 + if (new_rhs2 == NULL_TREE) {
102629 + orig_rhs = rhs1;
102630 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102631 + } else {
102632 + orig_rhs = rhs2;
102633 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102634 + }
102635 +
102636 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102637 +
102638 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102639 + gimple_assign_set_rhs(stmt, new_rhs);
102640 + update_stmt(stmt);
102641 +
102642 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102643 +}
102644 +
102645 +static bool is_subtraction_special(const_gimple stmt)
102646 +{
102647 + gimple rhs1_def_stmt, rhs2_def_stmt;
102648 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102649 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102650 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102651 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102652 +
102653 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102654 + return false;
102655 +
102656 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102657 +
102658 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102659 + return false;
102660 +
102661 + rhs1_def_stmt = get_def_stmt(rhs1);
102662 + rhs2_def_stmt = get_def_stmt(rhs2);
102663 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102664 + return false;
102665 +
102666 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102667 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102668 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102669 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102670 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102671 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102672 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102673 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102674 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102675 + return false;
102676 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102677 + return false;
102678 +
102679 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102680 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102681 + return true;
102682 +}
102683 +
102684 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102685 +{
102686 + tree new_rhs1, new_rhs2;
102687 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102688 + gimple assign, stmt = get_def_stmt(lhs);
102689 + tree rhs1 = gimple_assign_rhs1(stmt);
102690 + tree rhs2 = gimple_assign_rhs2(stmt);
102691 +
102692 + if (!is_subtraction_special(stmt))
102693 + return NULL_TREE;
102694 +
102695 + new_rhs1 = expand(visited, rhs1);
102696 + new_rhs2 = expand(visited, rhs2);
102697 +
102698 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102699 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102700 +
102701 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102702 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102703 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102704 + }
102705 +
102706 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102707 + new_lhs = gimple_get_lhs(assign);
102708 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102709 +
102710 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102711 +}
102712 +
102713 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102714 +{
102715 + const_gimple def_stmt;
102716 +
102717 + if (TREE_CODE(rhs) != SSA_NAME)
102718 + return false;
102719 +
102720 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102721 + return false;
102722 +
102723 + def_stmt = get_def_stmt(rhs);
102724 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102725 + return false;
102726 +
102727 + return true;
102728 +}
102729 +
102730 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102731 +{
102732 + tree rhs1, rhs2, new_lhs;
102733 + gimple def_stmt = get_def_stmt(lhs);
102734 + tree new_rhs1 = NULL_TREE;
102735 + tree new_rhs2 = NULL_TREE;
102736 +
102737 + rhs1 = gimple_assign_rhs1(def_stmt);
102738 + rhs2 = gimple_assign_rhs2(def_stmt);
102739 +
102740 + /* no DImode/TImode division in the 32/64 bit kernel */
102741 + switch (gimple_assign_rhs_code(def_stmt)) {
102742 + case RDIV_EXPR:
102743 + case TRUNC_DIV_EXPR:
102744 + case CEIL_DIV_EXPR:
102745 + case FLOOR_DIV_EXPR:
102746 + case ROUND_DIV_EXPR:
102747 + case TRUNC_MOD_EXPR:
102748 + case CEIL_MOD_EXPR:
102749 + case FLOOR_MOD_EXPR:
102750 + case ROUND_MOD_EXPR:
102751 + case EXACT_DIV_EXPR:
102752 + case POINTER_PLUS_EXPR:
102753 + case BIT_AND_EXPR:
102754 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102755 + default:
102756 + break;
102757 + }
102758 +
102759 + new_lhs = handle_integer_truncation(visited, lhs);
102760 + if (new_lhs != NULL_TREE)
102761 + return new_lhs;
102762 +
102763 + if (TREE_CODE(rhs1) == SSA_NAME)
102764 + new_rhs1 = expand(visited, rhs1);
102765 + if (TREE_CODE(rhs2) == SSA_NAME)
102766 + new_rhs2 = expand(visited, rhs2);
102767 +
102768 + if (is_a_neg_overflow(def_stmt, rhs2))
102769 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102770 + if (is_a_neg_overflow(def_stmt, rhs1))
102771 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102772 +
102773 +
102774 + if (is_a_constant_overflow(def_stmt, rhs2))
102775 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102776 + if (is_a_constant_overflow(def_stmt, rhs1))
102777 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102778 +
102779 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102780 +}
102781 +
102782 +#if BUILDING_GCC_VERSION >= 4007
102783 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102784 +{
102785 + if (is_gimple_constant(rhs))
102786 + return cast_a_tree(size_overflow_type, rhs);
102787 + if (TREE_CODE(rhs) != SSA_NAME)
102788 + return NULL_TREE;
102789 + return expand(visited, rhs);
102790 +}
102791 +
102792 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102793 +{
102794 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102795 + gimple def_stmt = get_def_stmt(lhs);
102796 +
102797 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102798 +
102799 + rhs1 = gimple_assign_rhs1(def_stmt);
102800 + rhs2 = gimple_assign_rhs2(def_stmt);
102801 + rhs3 = gimple_assign_rhs3(def_stmt);
102802 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102803 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102804 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102805 +
102806 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102807 +}
102808 +#endif
102809 +
102810 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102811 +{
102812 + const_tree type;
102813 + tree new_type;
102814 +
102815 + gcc_assert(node != NULL_TREE);
102816 +
102817 + type = TREE_TYPE(node);
102818 +
102819 + if (gimple_plf(stmt, MY_STMT))
102820 + return TREE_TYPE(node);
102821 +
102822 + switch (TYPE_MODE(type)) {
102823 + case QImode:
102824 + new_type = intHI_type_node;
102825 + break;
102826 + case HImode:
102827 + new_type = intSI_type_node;
102828 + break;
102829 + case SImode:
102830 + new_type = intDI_type_node;
102831 + break;
102832 + case DImode:
102833 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102834 + new_type = intDI_type_node;
102835 + else
102836 + new_type = intTI_type_node;
102837 + break;
102838 + default:
102839 + debug_tree((tree)node);
102840 + error("%s: unsupported gcc configuration.", __func__);
102841 + gcc_unreachable();
102842 + }
102843 +
102844 + if (TYPE_QUALS(type) != 0)
102845 + return build_qualified_type(new_type, TYPE_QUALS(type));
102846 + return new_type;
102847 +}
102848 +
102849 +static tree expand_visited(gimple def_stmt)
102850 +{
102851 + const_gimple next_stmt;
102852 + gimple_stmt_iterator gsi;
102853 + enum gimple_code code = gimple_code(def_stmt);
102854 +
102855 + if (code == GIMPLE_ASM)
102856 + return NULL_TREE;
102857 +
102858 + gsi = gsi_for_stmt(def_stmt);
102859 + gsi_next(&gsi);
102860 +
102861 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102862 + return NULL_TREE;
102863 + gcc_assert(!gsi_end_p(gsi));
102864 + next_stmt = gsi_stmt(gsi);
102865 +
102866 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102867 + return NULL_TREE;
102868 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102869 +
102870 + return get_lhs(next_stmt);
102871 +}
102872 +
102873 +static tree expand(struct pointer_set_t *visited, tree lhs)
102874 +{
102875 + gimple def_stmt;
102876 +
102877 + if (skip_types(lhs))
102878 + return NULL_TREE;
102879 +
102880 + def_stmt = get_def_stmt(lhs);
102881 +
102882 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102883 + return NULL_TREE;
102884 +
102885 + if (gimple_plf(def_stmt, MY_STMT))
102886 + return lhs;
102887 +
102888 + if (pointer_set_contains(visited, def_stmt))
102889 + return expand_visited(def_stmt);
102890 +
102891 + switch (gimple_code(def_stmt)) {
102892 + case GIMPLE_PHI:
102893 + return handle_phi(visited, lhs);
102894 + case GIMPLE_CALL:
102895 + case GIMPLE_ASM:
102896 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102897 + case GIMPLE_ASSIGN:
102898 + switch (gimple_num_ops(def_stmt)) {
102899 + case 2:
102900 + return handle_unary_ops(visited, def_stmt);
102901 + case 3:
102902 + return handle_binary_ops(visited, lhs);
102903 +#if BUILDING_GCC_VERSION >= 4007
102904 + case 4:
102905 + return handle_ternary_ops(visited, lhs);
102906 +#endif
102907 + }
102908 + default:
102909 + debug_gimple_stmt(def_stmt);
102910 + error("%s: unknown gimple code", __func__);
102911 + gcc_unreachable();
102912 + }
102913 +}
102914 +
102915 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102916 +{
102917 + const_gimple assign;
102918 + tree orig_type = TREE_TYPE(orig_node);
102919 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102920 +
102921 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102922 + return gimple_get_lhs(assign);
102923 +}
102924 +
102925 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102926 +{
102927 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102928 + update_stmt(stmt);
102929 +}
102930 +
102931 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102932 +{
102933 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102934 + update_stmt(stmt);
102935 +}
102936 +
102937 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102938 +{
102939 + tree arg;
102940 + const_tree origarg;
102941 +
102942 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102943 + return true;
102944 +
102945 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102946 + while (origarg && *argnum) {
102947 + (*argnum)--;
102948 + origarg = TREE_CHAIN(origarg);
102949 + }
102950 +
102951 + gcc_assert(*argnum == 0);
102952 +
102953 + gcc_assert(origarg != NULL_TREE);
102954 + *argnum = 0;
102955 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102956 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102957 + return true;
102958 + return false;
102959 +}
102960 +
102961 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102962 +{
102963 + gimple phi = get_def_stmt(result);
102964 + unsigned int i, n = gimple_phi_num_args(phi);
102965 +
102966 + if (!phi)
102967 + return MARK_NO;
102968 +
102969 + pointer_set_insert(visited, phi);
102970 + for (i = 0; i < n; i++) {
102971 + enum mark marked;
102972 + const_tree arg = gimple_phi_arg_def(phi, i);
102973 + marked = pre_expand(visited, search_err_code, arg);
102974 + if (marked != MARK_NO)
102975 + return marked;
102976 + }
102977 + return MARK_NO;
102978 +}
102979 +
102980 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102981 +{
102982 + gimple def_stmt = get_def_stmt(lhs);
102983 + const_tree rhs;
102984 +
102985 + if (!def_stmt)
102986 + return MARK_NO;
102987 +
102988 + rhs = gimple_assign_rhs1(def_stmt);
102989 +
102990 + def_stmt = get_def_stmt(rhs);
102991 + if (is_gimple_constant(rhs))
102992 + search_err_code[FROM_CONST] = true;
102993 +
102994 + return pre_expand(visited, search_err_code, rhs);
102995 +}
102996 +
102997 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102998 +{
102999 + gimple def_stmt = get_def_stmt(lhs);
103000 + const_tree rhs1, rhs2;
103001 + enum mark marked;
103002 +
103003 + if (!def_stmt)
103004 + return MARK_NO;
103005 +
103006 + search_err_code[CAST_ONLY] = false;
103007 +
103008 + rhs1 = gimple_assign_rhs1(def_stmt);
103009 + rhs2 = gimple_assign_rhs2(def_stmt);
103010 + marked = pre_expand(visited, search_err_code, rhs1);
103011 + if (marked != MARK_NO)
103012 + return marked;
103013 + return pre_expand(visited, search_err_code, rhs2);
103014 +}
103015 +
103016 +static const_tree search_field_decl(const_tree comp_ref)
103017 +{
103018 + const_tree field = NULL_TREE;
103019 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103020 +
103021 + for (i = 0; i < len; i++) {
103022 + field = TREE_OPERAND(comp_ref, i);
103023 + if (TREE_CODE(field) == FIELD_DECL)
103024 + break;
103025 + }
103026 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103027 + return field;
103028 +}
103029 +
103030 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103031 +{
103032 + const_tree attr, p;
103033 +
103034 + // 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);
103035 + if (fndecl == NULL_TREE)
103036 + return MARK_NO;
103037 +
103038 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103039 + if (!attr || !TREE_VALUE(attr))
103040 + return MARK_NO;
103041 +
103042 + p = TREE_VALUE(attr);
103043 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103044 + return MARK_TURN_OFF;
103045 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103046 + return MARK_NOT_INTENTIONAL;
103047 + if (argnum == 0) {
103048 + gcc_assert(current_function_decl == fndecl);
103049 + return MARK_NO;
103050 + }
103051 +
103052 + do {
103053 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103054 + return MARK_YES;
103055 + p = TREE_CHAIN(p);
103056 + } while (p);
103057 +
103058 + return MARK_NO;
103059 +}
103060 +
103061 +static void print_missing_msg(tree func, unsigned int argnum)
103062 +{
103063 + unsigned int new_hash;
103064 + size_t len;
103065 + unsigned char tree_codes[CODES_LIMIT];
103066 + location_t loc;
103067 + const char *curfunc;
103068 +
103069 + func = get_original_function_decl(func);
103070 + loc = DECL_SOURCE_LOCATION(func);
103071 + curfunc = get_asm_name(func);
103072 +
103073 + len = get_function_decl(func, tree_codes);
103074 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103075 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103076 +}
103077 +
103078 +static unsigned int search_missing_attribute(const_tree arg)
103079 +{
103080 + unsigned int argnum;
103081 + const struct size_overflow_hash *hash;
103082 + const_tree type = TREE_TYPE(arg);
103083 + tree func = get_original_function_decl(current_function_decl);
103084 +
103085 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103086 +
103087 + if (TREE_CODE(type) == POINTER_TYPE)
103088 + return 0;
103089 +
103090 + argnum = find_arg_number(arg, func);
103091 + if (argnum == 0)
103092 + return 0;
103093 +
103094 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103095 + return argnum;
103096 +
103097 + hash = get_function_hash(func);
103098 + if (!hash || !(hash->param & (1U << argnum))) {
103099 + print_missing_msg(func, argnum);
103100 + return 0;
103101 + }
103102 + return argnum;
103103 +}
103104 +
103105 +static enum mark is_already_marked(const_tree lhs)
103106 +{
103107 + unsigned int argnum;
103108 + const_tree fndecl;
103109 +
103110 + argnum = search_missing_attribute(lhs);
103111 + fndecl = get_original_function_decl(current_function_decl);
103112 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103113 + return MARK_YES;
103114 + return MARK_NO;
103115 +}
103116 +
103117 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103118 +{
103119 + const_gimple def_stmt;
103120 +
103121 + if (skip_types(lhs))
103122 + return MARK_NO;
103123 +
103124 + if (TREE_CODE(lhs) == PARM_DECL)
103125 + return is_already_marked(lhs);
103126 +
103127 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103128 + const_tree field, attr;
103129 +
103130 + field = search_field_decl(lhs);
103131 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103132 + if (!attr || !TREE_VALUE(attr))
103133 + return MARK_NO;
103134 + return MARK_YES;
103135 + }
103136 +
103137 + def_stmt = get_def_stmt(lhs);
103138 +
103139 + if (!def_stmt)
103140 + return MARK_NO;
103141 +
103142 + if (pointer_set_contains(visited, def_stmt))
103143 + return MARK_NO;
103144 +
103145 + switch (gimple_code(def_stmt)) {
103146 + case GIMPLE_NOP:
103147 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103148 + return is_already_marked(lhs);
103149 + return MARK_NO;
103150 + case GIMPLE_PHI:
103151 + return walk_phi(visited, search_err_code, lhs);
103152 + case GIMPLE_CALL:
103153 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103154 + return MARK_TURN_OFF;
103155 + check_function_hash(def_stmt);
103156 + return MARK_NO;
103157 + case GIMPLE_ASM:
103158 + search_err_code[CAST_ONLY] = false;
103159 + return MARK_NO;
103160 + case GIMPLE_ASSIGN:
103161 + switch (gimple_num_ops(def_stmt)) {
103162 + case 2:
103163 + return walk_unary_ops(visited, search_err_code, lhs);
103164 + case 3:
103165 + return walk_binary_ops(visited, search_err_code, lhs);
103166 + }
103167 + default:
103168 + debug_gimple_stmt((gimple)def_stmt);
103169 + error("%s: unknown gimple code", __func__);
103170 + gcc_unreachable();
103171 + }
103172 +}
103173 +
103174 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103175 +static bool skip_asm(const_tree arg)
103176 +{
103177 + gimple def_stmt = get_def_stmt(arg);
103178 +
103179 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103180 + return false;
103181 +
103182 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103183 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103184 +}
103185 +
103186 +/*
103187 +0</MARK_YES: no dup, search attributes (so, int)
103188 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103189 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103190 +*/
103191 +
103192 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103193 +{
103194 + struct pointer_set_t *visited;
103195 + enum mark is_marked, is_found;
103196 + location_t loc;
103197 + bool search_err_code[2] = {true, false};
103198 +
103199 + is_marked = mark_status(current_function_decl, 0);
103200 + if (is_marked == MARK_TURN_OFF)
103201 + return true;
103202 +
103203 + is_marked = mark_status(fndecl, argnum + 1);
103204 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103205 + return true;
103206 +
103207 + visited = pointer_set_create();
103208 + is_found = pre_expand(visited, search_err_code, arg);
103209 + pointer_set_destroy(visited);
103210 +
103211 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103212 + return true;
103213 +
103214 + if (where == FROM_ARG && skip_asm(arg))
103215 + return true;
103216 +
103217 + if (is_found == MARK_TURN_OFF)
103218 + return true;
103219 +
103220 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103221 + return true;
103222 +
103223 + if (is_found == MARK_YES) {
103224 + loc = DECL_SOURCE_LOCATION(fndecl);
103225 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103226 + return true;
103227 + }
103228 + return false;
103229 +}
103230 +
103231 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103232 +{
103233 + struct pointer_set_t *visited;
103234 + tree arg, new_arg;
103235 + bool match;
103236 +
103237 + if (argnum == 0)
103238 + return;
103239 +
103240 + argnum--;
103241 +
103242 + match = get_function_arg(&argnum, fndecl);
103243 + if (!match)
103244 + return;
103245 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103246 + arg = gimple_call_arg(stmt, argnum);
103247 + if (arg == NULL_TREE)
103248 + return;
103249 +
103250 + if (skip_types(arg))
103251 + return;
103252 +
103253 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103254 + return;
103255 +
103256 + visited = pointer_set_create();
103257 + new_arg = expand(visited, arg);
103258 + pointer_set_destroy(visited);
103259 +
103260 + if (new_arg == NULL_TREE)
103261 + return;
103262 +
103263 + change_function_arg(stmt, arg, argnum, new_arg);
103264 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103265 +}
103266 +
103267 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103268 +{
103269 + tree p = TREE_VALUE(attr);
103270 + do {
103271 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103272 + p = TREE_CHAIN(p);
103273 + } while (p);
103274 +}
103275 +
103276 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103277 +{
103278 + unsigned int num;
103279 + const struct size_overflow_hash *hash;
103280 +
103281 + hash = get_function_hash(fndecl);
103282 + if (!hash)
103283 + return;
103284 +
103285 + for (num = 0; num <= MAX_PARAM; num++)
103286 + if (hash->param & (1U << num))
103287 + handle_function_arg(stmt, fndecl, num);
103288 +}
103289 +
103290 +static bool check_return_value(void)
103291 +{
103292 + const struct size_overflow_hash *hash;
103293 +
103294 + hash = get_function_hash(current_function_decl);
103295 + if (!hash || !(hash->param & 1U << 0))
103296 + return false;
103297 +
103298 + return true;
103299 +}
103300 +
103301 +static void handle_return_value(gimple ret_stmt)
103302 +{
103303 + struct pointer_set_t *visited;
103304 + tree ret, new_ret;
103305 +
103306 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103307 + return;
103308 +
103309 + ret = gimple_return_retval(ret_stmt);
103310 +
103311 + if (skip_types(ret))
103312 + return;
103313 +
103314 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103315 + return;
103316 +
103317 + visited = pointer_set_create();
103318 + new_ret = expand(visited, ret);
103319 + pointer_set_destroy(visited);
103320 +
103321 + change_function_return(ret_stmt, ret, new_ret);
103322 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103323 +}
103324 +
103325 +static void set_plf_false(void)
103326 +{
103327 + basic_block bb;
103328 +
103329 + FOR_ALL_BB(bb) {
103330 + gimple_stmt_iterator si;
103331 +
103332 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103333 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103334 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103335 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103336 + }
103337 +}
103338 +
103339 +static unsigned int handle_function(void)
103340 +{
103341 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103342 + bool check_ret;
103343 +
103344 + set_plf_false();
103345 +
103346 + check_ret = check_return_value();
103347 +
103348 + do {
103349 + gimple_stmt_iterator gsi;
103350 + next = bb->next_bb;
103351 +
103352 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103353 + tree fndecl, attr;
103354 + gimple stmt = gsi_stmt(gsi);
103355 +
103356 + if (check_ret)
103357 + handle_return_value(stmt);
103358 +
103359 + if (!(is_gimple_call(stmt)))
103360 + continue;
103361 + fndecl = gimple_call_fndecl(stmt);
103362 + if (fndecl == NULL_TREE)
103363 + continue;
103364 + if (gimple_call_num_args(stmt) == 0)
103365 + continue;
103366 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103367 + if (!attr || !TREE_VALUE(attr))
103368 + handle_function_by_hash(stmt, fndecl);
103369 + else
103370 + handle_function_by_attribute(stmt, attr, fndecl);
103371 + gsi = gsi_for_stmt(stmt);
103372 + next = gimple_bb(stmt)->next_bb;
103373 + }
103374 + bb = next;
103375 + } while (bb);
103376 + return 0;
103377 +}
103378 +
103379 +static struct gimple_opt_pass size_overflow_pass = {
103380 + .pass = {
103381 + .type = GIMPLE_PASS,
103382 + .name = "size_overflow",
103383 +#if BUILDING_GCC_VERSION >= 4008
103384 + .optinfo_flags = OPTGROUP_NONE,
103385 +#endif
103386 + .gate = NULL,
103387 + .execute = handle_function,
103388 + .sub = NULL,
103389 + .next = NULL,
103390 + .static_pass_number = 0,
103391 + .tv_id = TV_NONE,
103392 + .properties_required = PROP_cfg,
103393 + .properties_provided = 0,
103394 + .properties_destroyed = 0,
103395 + .todo_flags_start = 0,
103396 + .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
103397 + }
103398 +};
103399 +
103400 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103401 +{
103402 + tree fntype;
103403 +
103404 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103405 +
103406 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103407 + fntype = build_function_type_list(void_type_node,
103408 + const_char_ptr_type_node,
103409 + unsigned_type_node,
103410 + const_char_ptr_type_node,
103411 + const_char_ptr_type_node,
103412 + NULL_TREE);
103413 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103414 +
103415 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103416 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103417 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103418 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103419 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103420 +}
103421 +
103422 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103423 +{
103424 + int i;
103425 + const char * const plugin_name = plugin_info->base_name;
103426 + const int argc = plugin_info->argc;
103427 + const struct plugin_argument * const argv = plugin_info->argv;
103428 + bool enable = true;
103429 +
103430 + struct register_pass_info size_overflow_pass_info = {
103431 + .pass = &size_overflow_pass.pass,
103432 + .reference_pass_name = "ssa",
103433 + .ref_pass_instance_number = 1,
103434 + .pos_op = PASS_POS_INSERT_AFTER
103435 + };
103436 +
103437 + if (!plugin_default_version_check(version, &gcc_version)) {
103438 + error(G_("incompatible gcc/plugin versions"));
103439 + return 1;
103440 + }
103441 +
103442 + for (i = 0; i < argc; ++i) {
103443 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103444 + enable = false;
103445 + continue;
103446 + }
103447 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103448 + }
103449 +
103450 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103451 + if (enable) {
103452 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103453 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103454 + }
103455 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103456 +
103457 + return 0;
103458 +}
103459 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103460 new file mode 100644
103461 index 0000000..ac2901e
103462 --- /dev/null
103463 +++ b/tools/gcc/stackleak_plugin.c
103464 @@ -0,0 +1,327 @@
103465 +/*
103466 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103467 + * Licensed under the GPL v2
103468 + *
103469 + * Note: the choice of the license means that the compilation process is
103470 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103471 + * but for the kernel it doesn't matter since it doesn't link against
103472 + * any of the gcc libraries
103473 + *
103474 + * gcc plugin to help implement various PaX features
103475 + *
103476 + * - track lowest stack pointer
103477 + *
103478 + * TODO:
103479 + * - initialize all local variables
103480 + *
103481 + * BUGS:
103482 + * - none known
103483 + */
103484 +#include "gcc-plugin.h"
103485 +#include "config.h"
103486 +#include "system.h"
103487 +#include "coretypes.h"
103488 +#include "tree.h"
103489 +#include "tree-pass.h"
103490 +#include "flags.h"
103491 +#include "intl.h"
103492 +#include "toplev.h"
103493 +#include "plugin.h"
103494 +//#include "expr.h" where are you...
103495 +#include "diagnostic.h"
103496 +#include "plugin-version.h"
103497 +#include "tm.h"
103498 +#include "function.h"
103499 +#include "basic-block.h"
103500 +#include "gimple.h"
103501 +#include "rtl.h"
103502 +#include "emit-rtl.h"
103503 +
103504 +#if BUILDING_GCC_VERSION >= 4008
103505 +#define TODO_dump_func 0
103506 +#endif
103507 +
103508 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103509 +
103510 +int plugin_is_GPL_compatible;
103511 +
103512 +static int track_frame_size = -1;
103513 +static const char track_function[] = "pax_track_stack";
103514 +static const char check_function[] = "pax_check_alloca";
103515 +static bool init_locals;
103516 +
103517 +static struct plugin_info stackleak_plugin_info = {
103518 + .version = "201302112000",
103519 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103520 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103521 +};
103522 +
103523 +static bool gate_stackleak_track_stack(void);
103524 +static unsigned int execute_stackleak_tree_instrument(void);
103525 +static unsigned int execute_stackleak_final(void);
103526 +
103527 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103528 + .pass = {
103529 + .type = GIMPLE_PASS,
103530 + .name = "stackleak_tree_instrument",
103531 +#if BUILDING_GCC_VERSION >= 4008
103532 + .optinfo_flags = OPTGROUP_NONE,
103533 +#endif
103534 + .gate = gate_stackleak_track_stack,
103535 + .execute = execute_stackleak_tree_instrument,
103536 + .sub = NULL,
103537 + .next = NULL,
103538 + .static_pass_number = 0,
103539 + .tv_id = TV_NONE,
103540 + .properties_required = PROP_gimple_leh | PROP_cfg,
103541 + .properties_provided = 0,
103542 + .properties_destroyed = 0,
103543 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103544 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103545 + }
103546 +};
103547 +
103548 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103549 + .pass = {
103550 + .type = RTL_PASS,
103551 + .name = "stackleak_final",
103552 +#if BUILDING_GCC_VERSION >= 4008
103553 + .optinfo_flags = OPTGROUP_NONE,
103554 +#endif
103555 + .gate = gate_stackleak_track_stack,
103556 + .execute = execute_stackleak_final,
103557 + .sub = NULL,
103558 + .next = NULL,
103559 + .static_pass_number = 0,
103560 + .tv_id = TV_NONE,
103561 + .properties_required = 0,
103562 + .properties_provided = 0,
103563 + .properties_destroyed = 0,
103564 + .todo_flags_start = 0,
103565 + .todo_flags_finish = TODO_dump_func
103566 + }
103567 +};
103568 +
103569 +static bool gate_stackleak_track_stack(void)
103570 +{
103571 + return track_frame_size >= 0;
103572 +}
103573 +
103574 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103575 +{
103576 + gimple check_alloca;
103577 + tree fntype, fndecl, alloca_size;
103578 +
103579 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103580 + fndecl = build_fn_decl(check_function, fntype);
103581 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103582 +
103583 + // insert call to void pax_check_alloca(unsigned long size)
103584 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103585 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103586 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103587 +}
103588 +
103589 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103590 +{
103591 + gimple track_stack;
103592 + tree fntype, fndecl;
103593 +
103594 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103595 + fndecl = build_fn_decl(track_function, fntype);
103596 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103597 +
103598 + // insert call to void pax_track_stack(void)
103599 + track_stack = gimple_build_call(fndecl, 0);
103600 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103601 +}
103602 +
103603 +#if BUILDING_GCC_VERSION == 4005
103604 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103605 +{
103606 + tree fndecl;
103607 +
103608 + if (!is_gimple_call(stmt))
103609 + return false;
103610 + fndecl = gimple_call_fndecl(stmt);
103611 + if (!fndecl)
103612 + return false;
103613 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103614 + return false;
103615 +// print_node(stderr, "pax", fndecl, 4);
103616 + return DECL_FUNCTION_CODE(fndecl) == code;
103617 +}
103618 +#endif
103619 +
103620 +static bool is_alloca(gimple stmt)
103621 +{
103622 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103623 + return true;
103624 +
103625 +#if BUILDING_GCC_VERSION >= 4007
103626 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103627 + return true;
103628 +#endif
103629 +
103630 + return false;
103631 +}
103632 +
103633 +static unsigned int execute_stackleak_tree_instrument(void)
103634 +{
103635 + basic_block bb, entry_bb;
103636 + bool prologue_instrumented = false, is_leaf = true;
103637 +
103638 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103639 +
103640 + // 1. loop through BBs and GIMPLE statements
103641 + FOR_EACH_BB(bb) {
103642 + gimple_stmt_iterator gsi;
103643 +
103644 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103645 + gimple stmt;
103646 +
103647 + stmt = gsi_stmt(gsi);
103648 +
103649 + if (is_gimple_call(stmt))
103650 + is_leaf = false;
103651 +
103652 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103653 + if (!is_alloca(stmt))
103654 + continue;
103655 +
103656 + // 2. insert stack overflow check before each __builtin_alloca call
103657 + stackleak_check_alloca(&gsi);
103658 +
103659 + // 3. insert track call after each __builtin_alloca call
103660 + stackleak_add_instrumentation(&gsi);
103661 + if (bb == entry_bb)
103662 + prologue_instrumented = true;
103663 + }
103664 + }
103665 +
103666 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103667 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103668 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103669 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103670 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103671 + return 0;
103672 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103673 + return 0;
103674 +
103675 + // 4. insert track call at the beginning
103676 + if (!prologue_instrumented) {
103677 + gimple_stmt_iterator gsi;
103678 +
103679 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103680 + if (dom_info_available_p(CDI_DOMINATORS))
103681 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103682 + gsi = gsi_start_bb(bb);
103683 + stackleak_add_instrumentation(&gsi);
103684 + }
103685 +
103686 + return 0;
103687 +}
103688 +
103689 +static unsigned int execute_stackleak_final(void)
103690 +{
103691 + rtx insn, next;
103692 +
103693 + if (cfun->calls_alloca)
103694 + return 0;
103695 +
103696 + // keep calls only if function frame is big enough
103697 + if (get_frame_size() >= track_frame_size)
103698 + return 0;
103699 +
103700 + // 1. find pax_track_stack calls
103701 + for (insn = get_insns(); insn; insn = next) {
103702 + // 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))
103703 + rtx body;
103704 +
103705 + next = NEXT_INSN(insn);
103706 + if (!CALL_P(insn))
103707 + continue;
103708 + body = PATTERN(insn);
103709 + if (GET_CODE(body) != CALL)
103710 + continue;
103711 + body = XEXP(body, 0);
103712 + if (GET_CODE(body) != MEM)
103713 + continue;
103714 + body = XEXP(body, 0);
103715 + if (GET_CODE(body) != SYMBOL_REF)
103716 + continue;
103717 + if (strcmp(XSTR(body, 0), track_function))
103718 + continue;
103719 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103720 + // 2. delete call
103721 + delete_insn_and_edges(insn);
103722 +#if BUILDING_GCC_VERSION >= 4007
103723 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103724 + insn = next;
103725 + next = NEXT_INSN(insn);
103726 + delete_insn_and_edges(insn);
103727 + }
103728 +#endif
103729 + }
103730 +
103731 +// print_simple_rtl(stderr, get_insns());
103732 +// print_rtl(stderr, get_insns());
103733 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103734 +
103735 + return 0;
103736 +}
103737 +
103738 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103739 +{
103740 + const char * const plugin_name = plugin_info->base_name;
103741 + const int argc = plugin_info->argc;
103742 + const struct plugin_argument * const argv = plugin_info->argv;
103743 + int i;
103744 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103745 + .pass = &stackleak_tree_instrument_pass.pass,
103746 +// .reference_pass_name = "tree_profile",
103747 + .reference_pass_name = "optimized",
103748 + .ref_pass_instance_number = 1,
103749 + .pos_op = PASS_POS_INSERT_BEFORE
103750 + };
103751 + struct register_pass_info stackleak_final_pass_info = {
103752 + .pass = &stackleak_final_rtl_opt_pass.pass,
103753 + .reference_pass_name = "final",
103754 + .ref_pass_instance_number = 1,
103755 + .pos_op = PASS_POS_INSERT_BEFORE
103756 + };
103757 +
103758 + if (!plugin_default_version_check(version, &gcc_version)) {
103759 + error(G_("incompatible gcc/plugin versions"));
103760 + return 1;
103761 + }
103762 +
103763 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103764 +
103765 + for (i = 0; i < argc; ++i) {
103766 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103767 + if (!argv[i].value) {
103768 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103769 + continue;
103770 + }
103771 + track_frame_size = atoi(argv[i].value);
103772 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103773 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103774 + continue;
103775 + }
103776 + if (!strcmp(argv[i].key, "initialize-locals")) {
103777 + if (argv[i].value) {
103778 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103779 + continue;
103780 + }
103781 + init_locals = true;
103782 + continue;
103783 + }
103784 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103785 + }
103786 +
103787 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103788 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103789 +
103790 + return 0;
103791 +}
103792 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103793 new file mode 100644
103794 index 0000000..b07fe22
103795 --- /dev/null
103796 +++ b/tools/gcc/structleak_plugin.c
103797 @@ -0,0 +1,276 @@
103798 +/*
103799 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103800 + * Licensed under the GPL v2
103801 + *
103802 + * Note: the choice of the license means that the compilation process is
103803 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103804 + * but for the kernel it doesn't matter since it doesn't link against
103805 + * any of the gcc libraries
103806 + *
103807 + * gcc plugin to forcibly initialize certain local variables that could
103808 + * otherwise leak kernel stack to userland if they aren't properly initialized
103809 + * by later code
103810 + *
103811 + * Homepage: http://pax.grsecurity.net/
103812 + *
103813 + * Usage:
103814 + * $ # for 4.5/4.6/C based 4.7
103815 + * $ 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
103816 + * $ # for C++ based 4.7/4.8+
103817 + * $ 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
103818 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103819 + *
103820 + * TODO: eliminate redundant initializers
103821 + * increase type coverage
103822 + */
103823 +
103824 +#include "gcc-plugin.h"
103825 +#include "config.h"
103826 +#include "system.h"
103827 +#include "coretypes.h"
103828 +#include "tree.h"
103829 +#include "tree-pass.h"
103830 +#include "intl.h"
103831 +#include "plugin-version.h"
103832 +#include "tm.h"
103833 +#include "toplev.h"
103834 +#include "function.h"
103835 +#include "tree-flow.h"
103836 +#include "plugin.h"
103837 +#include "gimple.h"
103838 +#include "diagnostic.h"
103839 +#include "cfgloop.h"
103840 +#include "langhooks.h"
103841 +
103842 +#if BUILDING_GCC_VERSION >= 4008
103843 +#define TODO_dump_func 0
103844 +#endif
103845 +
103846 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103847 +
103848 +// unused type flag in all versions 4.5-4.8
103849 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103850 +
103851 +int plugin_is_GPL_compatible;
103852 +void debug_gimple_stmt(gimple gs);
103853 +
103854 +static struct plugin_info structleak_plugin_info = {
103855 + .version = "201304082245",
103856 + .help = "disable\tdo not activate plugin\n",
103857 +};
103858 +
103859 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103860 +{
103861 + *no_add_attrs = true;
103862 +
103863 + // check for types? for now accept everything linux has to offer
103864 + if (TREE_CODE(*node) != FIELD_DECL)
103865 + return NULL_TREE;
103866 +
103867 + *no_add_attrs = false;
103868 + return NULL_TREE;
103869 +}
103870 +
103871 +static struct attribute_spec user_attr = {
103872 + .name = "user",
103873 + .min_length = 0,
103874 + .max_length = 0,
103875 + .decl_required = false,
103876 + .type_required = false,
103877 + .function_type_required = false,
103878 + .handler = handle_user_attribute,
103879 +#if BUILDING_GCC_VERSION >= 4007
103880 + .affects_type_identity = true
103881 +#endif
103882 +};
103883 +
103884 +static void register_attributes(void *event_data, void *data)
103885 +{
103886 + register_attribute(&user_attr);
103887 +// register_attribute(&force_attr);
103888 +}
103889 +
103890 +static tree get_field_type(tree field)
103891 +{
103892 + return strip_array_types(TREE_TYPE(field));
103893 +}
103894 +
103895 +static bool is_userspace_type(tree type)
103896 +{
103897 + tree field;
103898 +
103899 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103900 + tree fieldtype = get_field_type(field);
103901 + enum tree_code code = TREE_CODE(fieldtype);
103902 +
103903 + if (code == RECORD_TYPE || code == UNION_TYPE)
103904 + if (is_userspace_type(fieldtype))
103905 + return true;
103906 +
103907 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103908 + return true;
103909 + }
103910 + return false;
103911 +}
103912 +
103913 +static void finish_type(void *event_data, void *data)
103914 +{
103915 + tree type = (tree)event_data;
103916 +
103917 + if (TYPE_USERSPACE(type))
103918 + return;
103919 +
103920 + if (is_userspace_type(type))
103921 + TYPE_USERSPACE(type) = 1;
103922 +}
103923 +
103924 +static void initialize(tree var)
103925 +{
103926 + basic_block bb;
103927 + gimple_stmt_iterator gsi;
103928 + tree initializer;
103929 + gimple init_stmt;
103930 +
103931 + // this is the original entry bb before the forced split
103932 + // TODO: check further BBs in case more splits occured before us
103933 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103934 +
103935 + // first check if the variable is already initialized, warn otherwise
103936 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103937 + gimple stmt = gsi_stmt(gsi);
103938 + tree rhs1 = gimple_assign_rhs1(stmt);
103939 +
103940 + // we're looking for an assignment of a single rhs...
103941 + if (!gimple_assign_single_p(stmt))
103942 + continue;
103943 +#if BUILDING_GCC_VERSION >= 4007
103944 + // ... of a non-clobbering expression...
103945 + if (TREE_CLOBBER_P(rhs1))
103946 + continue;
103947 +#endif
103948 + // ... to our variable...
103949 + if (gimple_get_lhs(stmt) != var)
103950 + continue;
103951 + // if it's an initializer then we're good
103952 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103953 + return;
103954 + }
103955 +
103956 + // these aren't the 0days you're looking for
103957 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
103958 +
103959 + // build the initializer expression
103960 + initializer = build_constructor(TREE_TYPE(var), NULL);
103961 +
103962 + // build the initializer stmt
103963 + init_stmt = gimple_build_assign(var, initializer);
103964 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103965 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103966 + update_stmt(init_stmt);
103967 +}
103968 +
103969 +static unsigned int handle_function(void)
103970 +{
103971 + basic_block bb;
103972 + unsigned int ret = 0;
103973 + tree var;
103974 +
103975 +#if BUILDING_GCC_VERSION == 4005
103976 + tree vars;
103977 +#else
103978 + unsigned int i;
103979 +#endif
103980 +
103981 + // split the first bb where we can put the forced initializers
103982 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103983 + if (dom_info_available_p(CDI_DOMINATORS))
103984 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103985 +
103986 + // enumarate all local variables and forcibly initialize our targets
103987 +#if BUILDING_GCC_VERSION == 4005
103988 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103989 + var = TREE_VALUE(vars);
103990 +#else
103991 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103992 +#endif
103993 + tree type = TREE_TYPE(var);
103994 +
103995 + gcc_assert(DECL_P(var));
103996 + if (!auto_var_in_fn_p(var, current_function_decl))
103997 + continue;
103998 +
103999 + // only care about structure types
104000 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104001 + continue;
104002 +
104003 + // if the type is of interest, examine the variable
104004 + if (TYPE_USERSPACE(type))
104005 + initialize(var);
104006 + }
104007 +
104008 + return ret;
104009 +}
104010 +
104011 +static struct gimple_opt_pass structleak_pass = {
104012 + .pass = {
104013 + .type = GIMPLE_PASS,
104014 + .name = "structleak",
104015 +#if BUILDING_GCC_VERSION >= 4008
104016 + .optinfo_flags = OPTGROUP_NONE,
104017 +#endif
104018 + .gate = NULL,
104019 + .execute = handle_function,
104020 + .sub = NULL,
104021 + .next = NULL,
104022 + .static_pass_number = 0,
104023 + .tv_id = TV_NONE,
104024 + .properties_required = PROP_cfg,
104025 + .properties_provided = 0,
104026 + .properties_destroyed = 0,
104027 + .todo_flags_start = 0,
104028 + .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
104029 + }
104030 +};
104031 +
104032 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104033 +{
104034 + int i;
104035 + const char * const plugin_name = plugin_info->base_name;
104036 + const int argc = plugin_info->argc;
104037 + const struct plugin_argument * const argv = plugin_info->argv;
104038 + bool enable = true;
104039 +
104040 + struct register_pass_info structleak_pass_info = {
104041 + .pass = &structleak_pass.pass,
104042 + .reference_pass_name = "ssa",
104043 + .ref_pass_instance_number = 1,
104044 + .pos_op = PASS_POS_INSERT_AFTER
104045 + };
104046 +
104047 + if (!plugin_default_version_check(version, &gcc_version)) {
104048 + error(G_("incompatible gcc/plugin versions"));
104049 + return 1;
104050 + }
104051 +
104052 + if (strcmp(lang_hooks.name, "GNU C")) {
104053 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104054 + enable = false;
104055 + }
104056 +
104057 + for (i = 0; i < argc; ++i) {
104058 + if (!strcmp(argv[i].key, "disable")) {
104059 + enable = false;
104060 + continue;
104061 + }
104062 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104063 + }
104064 +
104065 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104066 + if (enable) {
104067 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104068 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104069 + }
104070 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104071 +
104072 + return 0;
104073 +}
104074 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104075 index 6789d78..4afd019e 100644
104076 --- a/tools/perf/util/include/asm/alternative-asm.h
104077 +++ b/tools/perf/util/include/asm/alternative-asm.h
104078 @@ -5,4 +5,7 @@
104079
104080 #define altinstruction_entry #
104081
104082 + .macro pax_force_retaddr rip=0, reload=0
104083 + .endm
104084 +
104085 #endif
104086 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104087 index 96b919d..c49bb74 100644
104088 --- a/tools/perf/util/include/linux/compiler.h
104089 +++ b/tools/perf/util/include/linux/compiler.h
104090 @@ -18,4 +18,12 @@
104091 #define __force
104092 #endif
104093
104094 +#ifndef __size_overflow
104095 +# define __size_overflow(...)
104096 +#endif
104097 +
104098 +#ifndef __intentional_overflow
104099 +# define __intentional_overflow(...)
104100 +#endif
104101 +
104102 #endif
104103 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104104 index 10afa34..f29c524 100644
104105 --- a/virt/kvm/kvm_main.c
104106 +++ b/virt/kvm/kvm_main.c
104107 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104108
104109 static cpumask_var_t cpus_hardware_enabled;
104110 static int kvm_usage_count = 0;
104111 -static atomic_t hardware_enable_failed;
104112 +static atomic_unchecked_t hardware_enable_failed;
104113
104114 struct kmem_cache *kvm_vcpu_cache;
104115 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104116
104117 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104118 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104119 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104120 +static struct preempt_ops kvm_preempt_ops = {
104121 + .sched_in = kvm_sched_in,
104122 + .sched_out = kvm_sched_out,
104123 +};
104124
104125 struct dentry *kvm_debugfs_dir;
104126
104127 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104128 /* We can read the guest memory with __xxx_user() later on. */
104129 if (user_alloc &&
104130 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104131 - !access_ok(VERIFY_WRITE,
104132 + !__access_ok(VERIFY_WRITE,
104133 (void __user *)(unsigned long)mem->userspace_addr,
104134 mem->memory_size)))
104135 goto out;
104136 @@ -1810,7 +1815,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104137 return 0;
104138 }
104139
104140 -static struct file_operations kvm_vcpu_fops = {
104141 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104142 .release = kvm_vcpu_release,
104143 .unlocked_ioctl = kvm_vcpu_ioctl,
104144 #ifdef CONFIG_COMPAT
104145 @@ -2331,7 +2336,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104146 return 0;
104147 }
104148
104149 -static struct file_operations kvm_vm_fops = {
104150 +static file_operations_no_const kvm_vm_fops __read_only = {
104151 .release = kvm_vm_release,
104152 .unlocked_ioctl = kvm_vm_ioctl,
104153 #ifdef CONFIG_COMPAT
104154 @@ -2429,7 +2434,7 @@ out:
104155 return r;
104156 }
104157
104158 -static struct file_operations kvm_chardev_ops = {
104159 +static file_operations_no_const kvm_chardev_ops __read_only = {
104160 .unlocked_ioctl = kvm_dev_ioctl,
104161 .compat_ioctl = kvm_dev_ioctl,
104162 .llseek = noop_llseek,
104163 @@ -2455,7 +2460,7 @@ static void hardware_enable_nolock(void *junk)
104164
104165 if (r) {
104166 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104167 - atomic_inc(&hardware_enable_failed);
104168 + atomic_inc_unchecked(&hardware_enable_failed);
104169 printk(KERN_INFO "kvm: enabling virtualization on "
104170 "CPU%d failed\n", cpu);
104171 }
104172 @@ -2509,10 +2514,10 @@ static int hardware_enable_all(void)
104173
104174 kvm_usage_count++;
104175 if (kvm_usage_count == 1) {
104176 - atomic_set(&hardware_enable_failed, 0);
104177 + atomic_set_unchecked(&hardware_enable_failed, 0);
104178 on_each_cpu(hardware_enable_nolock, NULL, 1);
104179
104180 - if (atomic_read(&hardware_enable_failed)) {
104181 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104182 hardware_disable_all_nolock();
104183 r = -EBUSY;
104184 }
104185 @@ -2870,7 +2875,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104186 kvm_arch_vcpu_put(vcpu);
104187 }
104188
104189 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104190 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104191 struct module *module)
104192 {
104193 int r;
104194 @@ -2906,7 +2911,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104195 if (!vcpu_align)
104196 vcpu_align = __alignof__(struct kvm_vcpu);
104197 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104198 - 0, NULL);
104199 + SLAB_USERCOPY, NULL);
104200 if (!kvm_vcpu_cache) {
104201 r = -ENOMEM;
104202 goto out_free_3;
104203 @@ -2916,9 +2921,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104204 if (r)
104205 goto out_free;
104206
104207 + pax_open_kernel();
104208 kvm_chardev_ops.owner = module;
104209 kvm_vm_fops.owner = module;
104210 kvm_vcpu_fops.owner = module;
104211 + pax_close_kernel();
104212
104213 r = misc_register(&kvm_dev);
104214 if (r) {
104215 @@ -2928,9 +2935,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104216
104217 register_syscore_ops(&kvm_syscore_ops);
104218
104219 - kvm_preempt_ops.sched_in = kvm_sched_in;
104220 - kvm_preempt_ops.sched_out = kvm_sched_out;
104221 -
104222 r = kvm_init_debug();
104223 if (r) {
104224 printk(KERN_ERR "kvm: create debugfs files failed\n");